From dc4aafee511399ae7135a8f8d9e4cdcd9cca8fee Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 11 Apr 2023 16:21:04 +0200 Subject: dashboard: ignore syzbot replies to unknown messages Don't create such discussion entities as they are typically syzbot replies to non-public patch testing requests. --- dashboard/app/discussion.go | 4 ++++ dashboard/app/discussion_test.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/dashboard/app/discussion.go b/dashboard/app/discussion.go index ca287f72e..b586d151d 100644 --- a/dashboard/app/discussion.go +++ b/dashboard/app/discussion.go @@ -38,6 +38,10 @@ func saveDiscussionMessage(c context.Context, msg *newDiscussionMessage) error { if err == nil { discUpdate.ID = d.ID discUpdate.Type = dashapi.DiscussionType(d.Type) + } else if !msg.external { + // Most likely it's a public bot's reply to a non-public + // patch testing request. Ignore it. + return nil } // If the original discussion is not in the DB, it means we // were likely only mentioned in some further discussion. diff --git a/dashboard/app/discussion_test.go b/dashboard/app/discussion_test.go index 3ab61d1c8..a06ee216e 100644 --- a/dashboard/app/discussion_test.go +++ b/dashboard/app/discussion_test.go @@ -323,3 +323,40 @@ Link: https://testapp.appspot.com/bug?extid=%v client.expectEQ(got[0].Link, "https://lore.kernel.org/all/2345/T/") client.expectEQ(got[0].Subject, "[PATCH v3] A lot of fixes") } + +func TestIgnoreBotReplies(t *testing.T) { + c := NewCtx(t) + defer c.Close() + + client := c.publicClient + + build := testBuild(1) + client.UploadBuild(build) + + crash := testCrash(build, 1) + client.ReportCrash(crash) + msg := client.pollEmailBug() + _, extBugID, err := email.RemoveAddrContext(msg.Sender) + c.expectOK(err) + + incoming1 := fmt.Sprintf(`Date: Tue, 15 Aug 2017 14:59:00 -0700 +Message-ID: <2345> +Subject: Re: Patch testing request +From: %v +To: lore@email.com +In-Reply-To: <1234> +Content-Type: text/plain + +Hello! +`, msg.Sender) + _, err = c.POST("/_ah/mail/lore@email.com", incoming1) + c.expectOK(err) + + bug, _, err := findBugByReportingID(c.ctx, extBugID) + c.expectOK(err) + + // We have not seen the start of the discussion, but it should not go ignored. + got, err := getBugDiscussionsUI(c.ctx, bug) + c.expectOK(err) + client.expectEQ(len(got), 0) +} -- cgit mrf-deployment