From 964c2b06db46bed3ba6f8ae06b58615d37aece95 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 1 Jun 2021 19:57:20 +0530 Subject: [PATCH] Fix some semgrep issues (#17695) Automatic Merge --- app/email_batching_test.go | 13 ++----------- app/plugin_requests.go | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/email_batching_test.go b/app/email_batching_test.go index eabbc1c450..b7085e4dd9 100644 --- a/app/email_batching_test.go +++ b/app/email_batching_test.go @@ -166,7 +166,6 @@ func TestCheckPendingNotifications(t *testing.T) { } received := make(chan *model.Post, 2) - timeout := make(chan bool) job.checkPendingNotifications(time.Unix(10130, 0), func(s string, notifications []*batchedNotification) { for _, notification := range notifications { @@ -174,27 +173,19 @@ func TestCheckPendingNotifications(t *testing.T) { } }) - go func() { - // start a timeout to make sure that we don't get stuck here on a failed test - time.Sleep(5 * time.Second) - timeout <- true - }() - require.Nil(t, job.pendingNotifications[th.BasicUser.Id], "shouldn't have sent queued post") select { case post := <-received: require.Equal(t, post.Message, "post1", "should've received post1 first") - - case <-timeout: + case <-time.After(5 * time.Second): require.Fail(t, "timed out waiting for first post notification") } select { case post := <-received: require.Equal(t, post.Message, "post2", "should've received post2 second") - - case <-timeout: + case <-time.After(5 * time.Second): require.Fail(t, "timed out waiting for second post notification") } } diff --git a/app/plugin_requests.go b/app/plugin_requests.go index d49221233a..66389356e5 100644 --- a/app/plugin_requests.go +++ b/app/plugin_requests.go @@ -147,7 +147,7 @@ func (s *Server) servePluginRequest(w http.ResponseWriter, r *http.Request, hand csrfCheckPassed := false - if err == nil && cookieAuth && r.Method != "GET" { + if session != nil && err == nil && cookieAuth && r.Method != "GET" { sentToken := "" if r.Header.Get(model.HEADER_CSRF_TOKEN) == "" { @@ -172,7 +172,7 @@ func (s *Server) servePluginRequest(w http.ResponseWriter, r *http.Request, hand sid := "" userID := "" - if session != nil { + if session.Id != "" { sid = session.Id userID = session.UserId }