summaryrefslogtreecommitdiffstats
path: root/extensions/AntiSpam
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-07-14 07:03:15 +0200
committerByron Jones <glob@mozilla.com>2015-07-14 07:03:15 +0200
commitda4255a89aed53e9e215c69978087e16a0c85753 (patch)
treef81c831fe8e9391eab55f69a56d5849b3f8d2f9d /extensions/AntiSpam
parent43740a1ba3a3ee680033fbea7c23daab221016d5 (diff)
downloadbugzilla-da4255a89aed53e9e215c69978087e16a0c85753.tar.gz
bugzilla-da4255a89aed53e9e215c69978087e16a0c85753.tar.xz
Bug 1182909 - Prevent new accounts from CCing large numbers of users
Diffstat (limited to 'extensions/AntiSpam')
-rw-r--r--extensions/AntiSpam/Extension.pm32
-rw-r--r--extensions/AntiSpam/lib/Config.pm12
-rw-r--r--extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl8
3 files changed, 52 insertions, 0 deletions
diff --git a/extensions/AntiSpam/Extension.pm b/extensions/AntiSpam/Extension.pm
index 5ddc4c833..d8981071c 100644
--- a/extensions/AntiSpam/Extension.pm
+++ b/extensions/AntiSpam/Extension.pm
@@ -126,6 +126,38 @@ sub _ip_blocking {
}
#
+# cc count restrictions
+#
+
+sub bug_before_create {
+ my ($self, $args) = @_;
+ $self->_cc_limit($args->{params}, 'cc');
+}
+
+sub bug_start_of_set_all {
+ my ($self, $args) = @_;
+ $self->_cc_limit($args->{params}, 'newcc');
+}
+
+sub _cc_limit {
+ my ($self, $params, $cc_field) = @_;
+ return unless exists $params->{$cc_field};
+
+ my $user = Bugzilla->user;
+ my $cc_count = ref($params->{$cc_field}) ? scalar(@{ $params->{$cc_field} }) : 1;
+ my $limit_count = Bugzilla->params->{antispam_cc_limit_count};
+ my $limit_age = Bugzilla->params->{antispam_cc_limit_age};
+
+ if ($cc_count > $limit_count && $user->creation_age < $limit_age) {
+ _syslog(sprintf("[audit] blocked <%s> from CC'ing %s users", $user->login, $cc_count));
+ delete $params->{$cc_field};
+ if (exists $params->{cc} && exists $params->{cc}->{add}) {
+ delete $params->{cc}->{add};
+ }
+ }
+}
+
+#
# spam user disabling
#
diff --git a/extensions/AntiSpam/lib/Config.pm b/extensions/AntiSpam/lib/Config.pm
index c8e1255c2..92ccca175 100644
--- a/extensions/AntiSpam/lib/Config.pm
+++ b/extensions/AntiSpam/lib/Config.pm
@@ -61,6 +61,18 @@ sub get_param_list {
"reactivated in order to interact within our etiquette " .
"guidelines."
},
+ {
+ name => 'antispam_cc_limit_age',
+ type => 't',
+ default => '2',
+ checker => \&check_numeric,
+ },
+ {
+ name => 'antispam_cc_limit_count',
+ type => 't',
+ default => '5',
+ checker => \&check_numeric,
+ },
);
return @param_list;
diff --git a/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl b/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
index 671ac40f4..a21f57e4d 100644
--- a/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
+++ b/extensions/AntiSpam/template/en/default/admin/params/antispam.html.tmpl
@@ -33,5 +33,13 @@
antispam_abusive_disable_text =>
"This message will be displayed to the user when they try to log " _
"in after their account is disabled due to abuse."
+
+ antispam_cc_limit_age =>
+ "Accounts created fewer than this many days are restricted to CCing " _
+ "'antispam_cc_limit_count' users at once."
+
+ antispam_cc_limit_count =>
+ "The maximum number of users new accounts can CC at once. Attempts to " _
+ "CC more than this many users will result in zero users being CCed."
}
%]