aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-12-19 16:28:05 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2022-12-21 11:40:00 +0100
commitde7c95dd3774c15f5f8dda0952bdfbb36966504e (patch)
treea72f972474c2fdc2bf641171dcb22c2b01647ef1
parentd300808c627430a9c5a360db485538e04182363c (diff)
dashboard: include repositories to the bad commit message
-rw-r--r--dashboard/app/notifications_test.go43
-rw-r--r--dashboard/app/reporting_email.go54
2 files changed, 82 insertions, 15 deletions
diff --git a/dashboard/app/notifications_test.go b/dashboard/app/notifications_test.go
index 98543e8ce..d4f6b3227 100644
--- a/dashboard/app/notifications_test.go
+++ b/dashboard/app/notifications_test.go
@@ -9,6 +9,7 @@ import (
"testing"
"time"
+ "github.com/google/go-cmp/cmp"
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
)
@@ -73,11 +74,18 @@ func TestEmailNotifBadFix(t *testing.T) {
c := NewCtx(t)
defer c.Close()
+ client := c.publicClient
+
build := testBuild(1)
- c.client2.UploadBuild(build)
+ client.UploadBuild(build)
+
+ // Fake more active managers.
+ for i := 1; i < 5; i++ {
+ client.UploadBuild(testBuild(i + 1))
+ }
crash := testCrash(build, 1)
- c.client2.ReportCrash(crash)
+ client.ReportCrash(crash)
report := c.pollEmailBug()
c.expectEQ(report.To, []string{"test@syzkaller.com"})
_, extBugID, err := email.RemoveAddrContext(report.Sender)
@@ -97,17 +105,40 @@ func TestEmailNotifBadFix(t *testing.T) {
expectReply := fmt.Sprintf(`This bug is marked as fixed by commit:
some: commit title
-But I can't find it in any tested tree for more than 90 days.
+
+But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:
+
#syz fix: exact-commit-title
-Until then the bug is still considered open and new crashes with the same signature are ignored.
+Until then the bug is still considered open and new crashes with
+the same signature are ignored.
+Kernel: access-public-email
Dashboard link: https://testapp.appspot.com/bug?extid=%s
+
+---
+[1] I expect the commit to be present in:
+
+1. branch1 branch of
+repo1
+
+2. branch2 branch of
+repo2
+
+3. branch3 branch of
+repo3
+
+4. branch4 branch of
+repo4
+
+The full list of 5 trees can be found at
+https://testapp.appspot.com/access-public-email/repos
`, extBugID)
- if notif.Body != expectReply {
- t.Fatalf("bad notification text: %q, expected: %q", notif.Body, expectReply)
+ if diff := cmp.Diff(expectReply, notif.Body); diff != "" {
+ t.Errorf("wrong notification text: %s", diff)
+ fmt.Printf("received notification:\n%s\n", notif.Body)
}
// No notifications for another 14 days, then another one.
c.advanceTime(13 * 24 * time.Hour)
diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go
index e430dc963..bee0699d2 100644
--- a/dashboard/app/reporting_email.go
+++ b/dashboard/app/reporting_email.go
@@ -173,15 +173,11 @@ func emailSendBugNotif(c context.Context, notif *dashapi.BugNotification) error
body = "Sending this report upstream."
status = dashapi.BugStatusUpstream
case dashapi.BugNotifBadCommit:
- days := int(notifyAboutBadCommitPeriod / time.Hour / 24)
- body = fmt.Sprintf("This bug is marked as fixed by commit:\n%v\n"+
- "But I can't find it in any tested tree for more than %v days.\n"+
- "Is it a correct commit? Please update it by replying:\n"+
- "#syz fix: exact-commit-title\n\n"+
- "Until then the bug is still considered open and "+
- "new crashes with the same signature are ignored.\n\n"+
- "Dashboard link: "+notif.Link+"\n",
- notif.Text, days)
+ var err error
+ body, err = buildBadCommitMessage(c, notif)
+ if err != nil {
+ return err
+ }
case dashapi.BugNotifObsoleted:
body = "Auto-closing this bug as obsolete.\n"
statusReason = dashapi.BugStatusReason(notif.Text)
@@ -224,6 +220,46 @@ func emailSendBugNotif(c context.Context, notif *dashapi.BugNotification) error
return nil
}
+func buildBadCommitMessage(c context.Context, notif *dashapi.BugNotification) (string, error) {
+ var sb strings.Builder
+ days := int(notifyAboutBadCommitPeriod / time.Hour / 24)
+ nsConfig := config.Namespaces[notif.Namespace]
+ fmt.Fprintf(&sb, `This bug is marked as fixed by commit:
+%v
+
+But I can't find it in the tested trees[1] for more than %v days.
+Is it a correct commit? Please update it by replying:
+
+#syz fix: exact-commit-title
+
+Until then the bug is still considered open and new crashes with
+the same signature are ignored.
+
+Kernel: %s
+Dashboard link: %s
+
+---
+[1] I expect the commit to be present in:
+`, notif.Text, days, nsConfig.DisplayTitle, notif.Link)
+
+ repos, err := loadRepos(c, AccessPublic, notif.Namespace)
+ if err != nil {
+ return "", err
+ }
+ const maxShow = 4
+ for i, repo := range repos {
+ if i >= maxShow {
+ break
+ }
+ fmt.Fprintf(&sb, "\n%d. %s branch of\n%s\n", i+1, repo.Branch, repo.URL)
+ }
+ if len(repos) > maxShow {
+ fmt.Fprintf(&sb, "\nThe full list of %d trees can be found at\n%s\n",
+ len(repos), fmt.Sprintf("%v/%v/repos", appURL(c), notif.Namespace))
+ }
+ return sb.String(), nil
+}
+
func emailPollJobs(c context.Context) error {
jobs, err := pollCompletedJobs(c, emailType)
if err != nil {