dashboard/app: rearrange attachment order

Some email clients show attachments inline.
Config is large, make it the last attachment.
As suggested by Theodore Ts'o in
https://groups.google.com/d/msg/syzkaller/5hjgr2v_oww/fn5QW6dvDQAJ
This commit is contained in:
Dmitry Vyukov 2018-01-18 09:29:25 +01:00
parent b134896b20
commit 0d1e95d2ba
3 changed files with 45 additions and 44 deletions

View File

@ -43,10 +43,10 @@ func TestEmailReport(t *testing.T) {
c.expectEQ(msg.To, []string{to})
c.expectEQ(msg.Subject, crash.Title)
c.expectEQ(len(msg.Attachments), 2)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[1].Data, crash.Log)
c.expectEQ(msg.Attachments[0].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[0].Data, crash.Log)
c.expectEQ(msg.Attachments[1].Name, "config.txt")
c.expectEQ(msg.Attachments[1].Data, build.KernelConfig)
body := fmt.Sprintf(`Hello,
syzbot hit the following crash on repo1/branch1 commit
@ -148,12 +148,12 @@ For more options, visit https://groups.google.com/d/optout.
c.expectEQ(msg.To, to)
c.expectEQ(msg.Subject, crash.Title)
c.expectEQ(len(msg.Attachments), 3)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[1].Data, crash.Log)
c.expectEQ(msg.Attachments[2].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[2].Data, syzRepro)
c.expectEQ(msg.Attachments[0].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[0].Data, crash.Log)
c.expectEQ(msg.Attachments[1].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[1].Data, syzRepro)
c.expectEQ(msg.Attachments[2].Name, "config.txt")
c.expectEQ(msg.Attachments[2].Data, build.KernelConfig)
c.expectEQ(msg.Headers["In-Reply-To"], []string{"<1234>"})
body := fmt.Sprintf(`syzbot has found reproducer for the following crash on repo1/branch1 commit
kernel_commit1 (Sat Feb 3 04:05:06 0001 +0000)
@ -198,12 +198,12 @@ report1
c.expectEQ(msg.To, []string{"bar@foo.com", "bugs@syzkaller.com", "foo@bar.com"})
c.expectEQ(msg.Subject, crash.Title)
c.expectEQ(len(msg.Attachments), 3)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[1].Data, crash.Log)
c.expectEQ(msg.Attachments[2].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[2].Data, syzRepro)
c.expectEQ(msg.Attachments[0].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[0].Data, crash.Log)
c.expectEQ(msg.Attachments[1].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[1].Data, syzRepro)
c.expectEQ(msg.Attachments[2].Name, "config.txt")
c.expectEQ(msg.Attachments[2].Data, build.KernelConfig)
body := fmt.Sprintf(`Hello,
syzbot hit the following crash on repo1/branch1 commit
@ -284,14 +284,14 @@ Content-Type: text/plain
c.expectEQ(msg.To, []string{"another@another.com", "bar@foo.com", "bugs@syzkaller.com", "foo@bar.com", "new@new.com", "qux@qux.com"})
c.expectEQ(msg.Subject, crash.Title)
c.expectEQ(len(msg.Attachments), 4)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build2.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[1].Data, crash.Log)
c.expectEQ(msg.Attachments[2].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[2].Data, syzRepro)
c.expectEQ(msg.Attachments[3].Name, "repro.c.txt")
c.expectEQ(msg.Attachments[3].Data, crash.ReproC)
c.expectEQ(msg.Attachments[0].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[0].Data, crash.Log)
c.expectEQ(msg.Attachments[1].Name, "repro.syz.txt")
c.expectEQ(msg.Attachments[1].Data, syzRepro)
c.expectEQ(msg.Attachments[2].Name, "repro.c.txt")
c.expectEQ(msg.Attachments[2].Data, crash.ReproC)
c.expectEQ(msg.Attachments[3].Name, "config.txt")
c.expectEQ(msg.Attachments[3].Data, build2.KernelConfig)
body := fmt.Sprintf(`syzbot has found reproducer for the following crash on repo2/branch2 commit
kernel_commit2 (Sat Feb 3 04:05:06 0001 +0000)
kernel_commit_title2

View File

@ -116,12 +116,12 @@ func TestJob(t *testing.T) {
c.expectEQ(msg.To, []string{"default@sender.com", list})
c.expectEQ(msg.Subject, crash.Title)
c.expectEQ(len(msg.Attachments), 3)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "patch.diff")
c.expectEQ(msg.Attachments[1].Data, []byte(patch))
c.expectEQ(msg.Attachments[2].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[2].Data, jobDoneReq.CrashLog)
c.expectEQ(msg.Attachments[0].Name, "patch.diff")
c.expectEQ(msg.Attachments[0].Data, []byte(patch))
c.expectEQ(msg.Attachments[1].Name, "raw.log.txt")
c.expectEQ(msg.Attachments[1].Data, jobDoneReq.CrashLog)
c.expectEQ(msg.Attachments[2].Name, "config.txt")
c.expectEQ(msg.Attachments[2].Data, build.KernelConfig)
body := `Hello,
syzbot has tested the proposed patch but the reproducer still triggered crash:
@ -156,10 +156,10 @@ Raw console output is attached.
{
msg := <-c.emailSink
c.expectEQ(len(msg.Attachments), 2)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "patch.diff")
c.expectEQ(msg.Attachments[1].Data, []byte(patch))
c.expectEQ(msg.Attachments[0].Name, "patch.diff")
c.expectEQ(msg.Attachments[0].Data, []byte(patch))
c.expectEQ(msg.Attachments[1].Name, "config.txt")
c.expectEQ(msg.Attachments[1].Data, build.KernelConfig)
body := `Hello,
syzbot tried to test the proposed patch but build/boot failed:
@ -194,10 +194,10 @@ Kernel config is attached.
{
msg := <-c.emailSink
c.expectEQ(len(msg.Attachments), 2)
c.expectEQ(msg.Attachments[0].Name, "config.txt")
c.expectEQ(msg.Attachments[0].Data, build.KernelConfig)
c.expectEQ(msg.Attachments[1].Name, "patch.diff")
c.expectEQ(msg.Attachments[1].Data, []byte(patch))
c.expectEQ(msg.Attachments[0].Name, "patch.diff")
c.expectEQ(msg.Attachments[0].Data, []byte(patch))
c.expectEQ(msg.Attachments[1].Name, "config.txt")
c.expectEQ(msg.Attachments[1].Data, build.KernelConfig)
body := fmt.Sprintf(`Hello,
syzbot has tested the proposed patch and the reproducer did not trigger crash:

View File

@ -144,12 +144,7 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error
}
to = email.MergeEmailLists(to, rep.CC)
var attachments []aemail.Attachment
if len(rep.KernelConfig) != 0 {
attachments = append(attachments, aemail.Attachment{
Name: "config.txt",
Data: rep.KernelConfig,
})
}
// Note: order of attachments is important. Some email clients show them inline.
if len(rep.Patch) != 0 {
attachments = append(attachments, aemail.Attachment{
Name: "patch.diff",
@ -174,6 +169,12 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error
Data: rep.ReproC,
})
}
if len(rep.KernelConfig) != 0 {
attachments = append(attachments, aemail.Attachment{
Name: "config.txt",
Data: rep.KernelConfig,
})
}
// Build error output and failing VM boot log can be way too long to inline.
const maxInlineError = 16 << 10
errorText, errorTruncated := rep.Error, false