chomp;
push @{ $c{ControlAllow} }, $_;
}
+ close(CA);
+ }
+
+ if ( $c{ControlBlacklistPath} ) {
+ open CB, "<" . $c{ControlBlacklistPath}
+ or die "unable to open " . $c{ControlBlacklistPath} . ": $!";
+ $c{ControBlacklist} = [];
+ while (<CB>) {
+ chomp;
+ push @{ $c{ControlBlacklist} }, $_;
+ }
+ close(CB);
}
}
- bug-dist list is sufficient perhaps?
- Enable Perl taint mode?
- Strip common prefixes from title, e.g. [xen-devel], [PATCH] etc?
- - black-listing (e.g. from MAILER-DAEMON\@.* to avoid silly bounces or
- specific addresses to avoid trolls).
bugs:
- components
# Otherwise ControlAllow should be an array of email addresses
#@{ $c{ControlAllow} } = qw/admin@example.com/;
+# ControlBlacklistPath should contain the path to a file with one email address
+# per line.
+$c{ControlBlacklistPath} = "/etc/emesinae/control.blacklist";
# Severity levels, in decending order of criticality
@{ $c{SeverityLevels} } = qw/blocker critical normal wishlist/;
--- /dev/null
+i.am.a.spammer@example.com
+
$c{ControlAllowPath} = "/srv/test/etc/control.users";
# Otherwise ControlAllow should be an array of email addresses
#@{ $c{ControlAllow} } = qw/admin@example.com/;
+# ControlBlacklistPath should contain the path to a file with one email address
+# per line.
+$c{ControlBlacklistPath} = "/srv/test/etc/control.blacklist";
# Severity levels, in decending order of criticality
@{ $c{SeverityLevels} } = qw/blocker critical normal wishlist/;
$c{ControlAllowPath} = "/srv/xen-devel-bugs/etc/control.users";
# Otherwise ControlAllow should be an array of email addresses
#@{ $c{ControlAllow} } = qw/admin@example.com/;
+# ControlBlacklistPath should contain the path to a file with one email address
+# per line.
+$c{ControlBlacklistPath} = "/srv/xen-devel-bugs/etc/control.blacklist";
# Severity levels, in decending order of criticality
@{ $c{SeverityLevels} } = qw/blocker critical normal wishlist/;
$head->get($it) or push @{$err}, "Control message missing `$it' header";
}
+sub check_from_blacklist($) {
+ my ($err) = @_;
+
+ return unless $head->get('from'); # validate_one_header already handled this.
+ return if not @{ $c{ControlBlacklist} };
+
+ my $addrhead = Mail::Field::AddrList->extract( 'from', $head );
+ my @addresses = map { lc } $addrhead->addresses;
+ my @blacklist = map { lc } @{ $c{ControlBlacklist} };
+
+ for my $addr (@addresses) {
+ if ( $addr ~~ @blacklist ) {
+ push @{$err}, "Blacklisted From address: $addr";
+ last;
+ }
+ }
+}
+
sub validate_headers () {
my @errors;
# with such broken mail clients.
validate_one_header( \@errors, 'From' );
validate_one_header( \@errors, 'Message-ID' );
+ check_from_blacklist( \@errors );
return @errors;
}