]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1471304 - Block sending mail to hosts that end with .tld or .bugs
authorDylan William Hardison <dylan@hardison.net>
Tue, 26 Jun 2018 20:49:07 +0000 (16:49 -0400)
committerGitHub <noreply@github.com>
Tue, 26 Jun 2018 20:49:07 +0000 (16:49 -0400)
Bugzilla/BugMail.pm
Bugzilla/Mailer.pm
extensions/Review/Extension.pm

index 915405a0e09e132e6391c6dbc6131584e5184606..ebfc95d51b238f8b979fd497aa352180d2706718 100644 (file)
@@ -277,7 +277,7 @@ sub Send {
             # BMO: never send emails to bugs or .tld addresses.  this check needs to
             # happen after the bugmail_recipients hook.
             if ($user->email_enabled && $dep_ok &&
-                ($user->login !~ /bugs$/) && ($user->login !~ /\.tld$/))
+                ($user->login !~ /\.(?:bugs|tld)$/))
             {
                 # Don't show summaries for bugs the user can't access, and
                 # provide a hook for extensions such as SecureMail to filter
index 1b77e5063773969f1608acff5b6f3d7f458a7203..c9a458b475879a6a551a9e10c747b6839ff72f2c 100644 (file)
@@ -190,11 +190,16 @@ sub MessageToMTA {
         my @recipients = Email::Address->parse($to);
         die qq{Unable to parse "To:" address - $to\n} unless @recipients;
         die qq{Did not expect more than one "To:" address in $to\n} if @recipients > 1;
-        my $badhosts = Bugzilla::Bloomfilter->lookup("badhosts") or die "No badhosts bloomfilter\n";
-        if ($badhosts->test($recipients[0]->host)) {
+        my $recipient = $recipients[0];
+        my $badhosts  = Bugzilla::Bloomfilter->lookup("badhosts");
+        if ($badhosts && $badhosts->test($recipient->host)) {
             WARN("Attempted to send email to address in badhosts: $to");
             $email->header_set(to => '');
         }
+        elsif ($recipient->host =~ /\.(?:bugs|tld)$/) {
+            WARN("Attempted to send email to fake address: $to");
+            $email->header_set(to => '');
+        }
     } catch {
         ERROR($_);
     };
index f05f2ba8b6c33233384016baf81f1ce2105ad2fa..47edd69a69a2ef485d7fca3abe7eda85c41b399d 100644 (file)
@@ -94,7 +94,7 @@ sub _user_is_active {
     my ($self) = @_;
 
     # never consider .bugs or .tld addresses as inactive.
-    return 1 if $self->login =~ /bugs$/ || $self->login =~ /\.tld$/;
+    return 1 if $self->login =~ /\.(?:bugs|tld)$/;
     return 1 unless Bugzilla->params->{max_reviewer_last_seen};
     return 0 if !defined($self->last_seen_date);