diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-07-10 10:37:56 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-07-10 08:52:48 +0000 |
| commit | d7384b6d0bff77c60aad349866f126ab16ce5296 (patch) | |
| tree | 2edd653a5fb8c0aba986e975e86cfbd40f95d116 /dashboard | |
| parent | e2c7870cb29ae33156ef5f5e058d350e0d485f04 (diff) | |
dashboard: never react to forwarded emails
Adjust the tests to emulate user reply to the forwarded email.
To prevent syzbot from reacting to the email, look for the inbox pattern
in the raw from/cc/to email lists.
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/app/email_test.go | 6 | ||||
| -rw-r--r-- | dashboard/app/reporting_email.go | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go index b35fcd8dc..b9cdfb88c 100644 --- a/dashboard/app/email_test.go +++ b/dashboard/app/email_test.go @@ -1447,9 +1447,9 @@ Author: someone@mail.com `, msg.Body) t.Run("no-loop", func(t *testing.T) { - // Ensure that we don't react to our own reply. - c.incomingEmail(from, msg.Body, - EmailOptFrom(msg.Sender), + // Ensure that we don't react to replies. + c.incomingEmail("syzbot@testapp.appspotmail.com", msg.Body, + EmailOptFrom("syzbot@testapp.appspotmail.com"), EmailOptCC(append(append([]string{}, msg.Cc...), msg.To...))) c.expectNoEmail() }) diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index 56c956c0e..b241ef3a6 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -600,7 +600,7 @@ func handleIncomingMail(w http.ResponseWriter, r *http.Request) { return } source := matchDiscussionEmail(c, myEmail) - inbox := matchInbox(c, myEmail) + inbox := matchInbox(c, msg) log.Infof(c, "received email at %q, source %q, matched ignored inbox=%v", myEmail, source, inbox != nil) if inbox != nil { @@ -631,10 +631,16 @@ func matchDiscussionEmail(c context.Context, myEmail string) dashapi.DiscussionS return dashapi.NoDiscussion } -func matchInbox(c context.Context, myEmail string) *PerInboxConfig { +func matchInbox(c context.Context, msg *email.Email) *PerInboxConfig { + // We look at all raw addresses in To or Cc because, after forwarding, someone's reply + // will arrive to us both via the email through which we have forwarded and through the + // address that matched InboxRe. for _, item := range getConfig(c).MonitoredInboxes { - if ok, _ := regexp.MatchString(item.InboxRe, myEmail); ok { - return item + rg := regexp.MustCompile(item.InboxRe) + for _, cc := range msg.RawCc { + if rg.MatchString(cc) { + return item + } } } return nil |
