From 71b3a323ebdd4dfe9f32424d0ef9dd39f5086ad0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 17 Dec 2018 17:14:17 +0100 Subject: dashboard/app: CC kernel tree specific mailing list on reports Add ability to CC particular emails for crashes on particular kernel trees. Fixes #828 --- dashboard/app/app_test.go | 1 + dashboard/app/config.go | 8 ++++++++ dashboard/app/email_test.go | 37 ++++++++++++++++++++----------------- dashboard/app/reporting.go | 5 +++-- 4 files changed, 32 insertions(+), 19 deletions(-) (limited to 'dashboard') diff --git a/dashboard/app/app_test.go b/dashboard/app/app_test.go index 57202e7c4..e030ddaa4 100644 --- a/dashboard/app/app_test.go +++ b/dashboard/app/app_test.go @@ -160,6 +160,7 @@ var testConfig = &GlobalConfig{ KernelRepos: map[string]KernelRepo{ "repo10/branch10": { Alias: "repo10alias", + CC: []string{"maintainers@repo10.org", "bugs@repo10.org"}, }, }, } diff --git a/dashboard/app/config.go b/dashboard/app/config.go index fc92d189c..26487ae6b 100644 --- a/dashboard/app/config.go +++ b/dashboard/app/config.go @@ -6,6 +6,7 @@ package dash import ( "encoding/json" "fmt" + "net/mail" "regexp" "time" @@ -118,6 +119,8 @@ type KernelRepo struct { // ReportingPriority says if we need to prefer to report crashes in this // repo over crashes in repos with lower value. Must be in [0-9] range. ReportingPriority int + // Additional CC list to add to all bugs reported on this repo. + CC []string } var ( @@ -182,6 +185,11 @@ func installConfig(cfg *GlobalConfig) { if prio := info.ReportingPriority; prio < 0 || prio > 9 { panic(fmt.Sprintf("bad kernel repo reporting priority %v for %q", prio, repo)) } + for _, email := range info.CC { + if _, err := mail.ParseAddress(email); err != nil { + panic(fmt.Sprintf("bad email address %q: %v", email, err)) + } + } } config = cfg initEmailReporting() diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go index 40b2a9947..560dc54ca 100644 --- a/dashboard/app/email_test.go +++ b/dashboard/app/email_test.go @@ -117,6 +117,10 @@ For more options, visit https://groups.google.com/d/optout. c.incomingEmail(sender0, body0) // Now report syz reproducer and check updated email. + build2 := testBuild(10) + build2.KernelCommitTitle = "a really long title, longer than 80 chars, really long-long-long-long-long-long title" + c.client2.UploadBuild(build2) + crash.BuildID = build2.ID crash.ReproOpts = []byte("repro opts") crash.ReproSyz = []byte("getpid()") syzRepro := []byte(fmt.Sprintf("%s#%s\n%s", syzReproPrefix, crash.ReproOpts, crash.ReproSyz)) @@ -148,14 +152,14 @@ For more options, visit https://groups.google.com/d/optout. c.expectEQ(msg.Headers["In-Reply-To"], []string{"<1234>"}) body := fmt.Sprintf(`syzbot has found a reproducer for the following crash on: -HEAD commit: 111111111111 kernel_commit_title1 -git tree: repo1 branch1 +HEAD commit: 101010101010 a really long title, longer than 80 chars, re.. +git tree: repo10alias console output: %[3]v kernel config: %[4]v dashboard link: https://testapp.appspot.com/bug?extid=%[1]v -compiler: compiler1 +compiler: compiler10 syz repro: %[2]v -CC: [bar@foo.com foo@bar.com] +CC: [bar@foo.com foo@bar.com maintainers@repo10.org bugs@repo10.org] IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+%[1]v@testapp.appspotmail.com @@ -167,7 +171,7 @@ report1 } c.checkURLContents(reproSyzLink, syzRepro) c.checkURLContents(crashLogLink, crash.Log) - c.checkURLContents(kernelConfigLink, build.KernelConfig) + c.checkURLContents(kernelConfigLink, build2.KernelConfig) } // Now upstream the bug and check that it reaches the next reporting. @@ -192,20 +196,21 @@ report1 crashLogLink := externalLink(c.ctx, textCrashLog, dbCrash.Log) kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig) c.expectEQ(sender, fromAddr(c.ctx)) - c.expectEQ(msg.To, []string{"bar@foo.com", "bugs@syzkaller.com", - "default@maintainers.com", "foo@bar.com"}) + c.expectEQ(msg.To, []string{ + "bar@foo.com", "bugs@repo10.org", "bugs@syzkaller.com", + "default@maintainers.com", "foo@bar.com", "maintainers@repo10.org"}) c.expectEQ(msg.Subject, crash.Title) c.expectEQ(len(msg.Attachments), 0) body := fmt.Sprintf(`Hello, syzbot found the following crash on: -HEAD commit: 111111111111 kernel_commit_title1 -git tree: repo1 branch1 +HEAD commit: 101010101010 a really long title, longer than 80 chars, re.. +git tree: repo10alias console output: %[3]v kernel config: %[4]v dashboard link: https://testapp.appspot.com/bug?extid=%[1]v -compiler: compiler1 +compiler: compiler10 syz repro: %[2]v IMPORTANT: if you fix the bug, please add the following tag to the commit: @@ -228,7 +233,7 @@ https://goo.gl/tpsmEJ#testing-patches`, } c.checkURLContents(reproSyzLink, syzRepro) c.checkURLContents(crashLogLink, crash.Log) - c.checkURLContents(kernelConfigLink, build.KernelConfig) + c.checkURLContents(kernelConfigLink, build2.KernelConfig) } // Model that somebody adds more emails to CC list. @@ -247,10 +252,6 @@ Content-Type: text/plain c.expectOK(c.POST("/_ah/mail/", incoming3)) // Now upload a C reproducer. - build2 := testBuild(10) - build2.KernelCommitTitle = "a really long title, longer than 80 chars, really long-long-long-long-long-long title" - c.client2.UploadBuild(build2) - crash.BuildID = build2.ID crash.ReproC = []byte("int main() {}") crash.Maintainers = []string{"\"qux\" "} c.client2.ReportCrash(crash) @@ -270,8 +271,10 @@ Content-Type: text/plain crashLogLink := externalLink(c.ctx, textCrashLog, dbCrash.Log) kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig) c.expectEQ(sender, fromAddr(c.ctx)) - c.expectEQ(msg.To, []string{"another@another.com", "bar@foo.com", "bugs@syzkaller.com", - "default@maintainers.com", "foo@bar.com", "new@new.com", "qux@qux.com"}) + c.expectEQ(msg.To, []string{ + "another@another.com", "bar@foo.com", "bugs@repo10.org", + "bugs@syzkaller.com", "default@maintainers.com", "foo@bar.com", + "maintainers@repo10.org", "new@new.com", "qux@qux.com"}) c.expectEQ(msg.Subject, "Re: "+crash.Title) c.expectEQ(len(msg.Attachments), 0) body := fmt.Sprintf(`syzbot has found a reproducer for the following crash on: diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index 4ae3ae29f..fafd9c8a3 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -237,6 +237,7 @@ func createBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *datast return nil, err } + kernelRepo := kernelRepoInfo(build) rep := &dashapi.BugReport{ Namespace: bug.Namespace, Config: reportingConfig, @@ -248,13 +249,13 @@ func createBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *datast LogLink: externalLink(c, textCrashLog, crash.Log), Report: report, ReportLink: externalLink(c, textCrashReport, crash.Report), - Maintainers: crash.Maintainers, + Maintainers: append(crash.Maintainers, kernelRepo.CC...), OS: build.OS, Arch: build.Arch, VMArch: build.VMArch, CompilerID: build.CompilerID, KernelRepo: build.KernelRepo, - KernelRepoAlias: kernelRepoInfo(build).Alias, + KernelRepoAlias: kernelRepo.Alias, KernelBranch: build.KernelBranch, KernelCommit: build.KernelCommit, KernelCommitTitle: build.KernelCommitTitle, -- cgit mrf-deployment