{
name => 'rate_limit_rules',
type => 'l',
- default => '{"get_bug": [75, 60], "show_bug": [75, 60], "github": [10, 60]}',
+ default => default_rate_limit_rules(),
checker => \&check_rate_limit_rules,
updater => \&update_rate_limit_rules,
},
return @param_list;
}
+sub default_rate_limit_rules {
+ return encode_json({
+ get_bug => [75, 60],
+ show_bug => [75, 60],
+ github => [10, 60],
+ get_attachments => [75, 60],
+ get_comments => [75, 60],
+ });
+}
+
sub check_rate_limit_rules {
my $rules = shift;
}
values %$val;
- foreach my $required (qw( show_bug get_bug github )) {
+ my @required = qw(
+ show_bug github get_bug
+ get_attachments get_comments
+ );
+ foreach my $required (@required) {
return "missing $required" unless exists $val->{$required};
}
sub update_rate_limit_rules {
my ($rules) = @_;
my $val = decode_json($rules);
- $val->{github} = [10, 60];
+ $val->{github} = [10, 60];
+ $val->{get_attachments} = [75, 60];
+ $val->{get_comments} = [75, 60];
return encode_json($val);
}
my $dbh = Bugzilla->switch_to_shadow_db();
my $user = Bugzilla->user;
+ unless (Bugzilla->user->id) {
+ Bugzilla->check_rate_limit("get_comments", remote_ip());
+ }
+
my %bugs;
foreach my $bug_id (@$bug_ids) {
my $bug = Bugzilla::Bug->check($bug_id);
my $ids = $params->{ids} || [];
my $attach_ids = $params->{attachment_ids} || [];
+ unless (Bugzilla->user->id) {
+ Bugzilla->check_rate_limit("get_attachments", remote_ip());
+ }
+
my %bugs;
foreach my $bug_id (@$ids) {
my $bug = Bugzilla::Bug->check($bug_id);