}
sub check_rate_limit {
- my ($class, $name, $ip) = @_;
+ my ($class, $name, $ip, $throw_error) = @_;
+ $throw_error //= sub { ThrowUserError("rate_limit") };
my $params = Bugzilla->params;
if ($params->{rate_limit_active}) {
my $rules = decode_json($params->{rate_limit_rules});
"[rate_limit] action=$action, ip=$ip, limit=$limit, name=$name");
if ($action eq 'block') {
$Bugzilla::App::CGI::C->block_ip($ip);
- ThrowUserError("rate_limit");
+ $throw_error->();
}
}
}
github => [10, 60],
get_attachments => [75, 60],
get_comments => [75, 60],
+ webpage_errors => [75, 60],
});
}
my @required = qw(
show_bug github get_bug
get_attachments get_comments
+ webpage_errors
);
foreach my $required (@required) {
return "missing $required" unless exists $val->{$required};
$val->{github} = [10, 60];
$val->{get_attachments} = [75, 60];
$val->{get_comments} = [75, 60];
+ $val->{webpage_errors} = [75, 60];
return encode_json($val);
}
}
if (Bugzilla->error_mode == ERROR_MODE_WEBPAGE) {
+ Bugzilla->check_rate_limit("webpage_errors", remote_ip(), sub { $vars->{rate_limit_error} = 1 });
my $cgi = Bugzilla->cgi;
$cgi->close_standby_message('text/html', 'inline', 'error', 'html');
$template->process($name, $vars) || ThrowTemplateError($template->error());
<p class="throw_error">
[% error_message FILTER none %]
+ [% IF rate_limit_error %] (rate limit exceeded) [% END %]
</p>
[% IF variables %]
<tr>
<td id="error_msg" class="throw_error">
[% error_message FILTER none %]
+ [% IF rate_limit_error %] (rate limit exceeded) [% END %]
</td>
</tr>
</table>