From 09e1bbfee2f997261d24acb37d95bdb638467c02 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Wed, 3 Jan 2018 14:22:04 -0500 Subject: Bug 1426409 - github_secret key has no rate limiting --- Bugzilla/Config/Admin.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Bugzilla/Config') diff --git a/Bugzilla/Config/Admin.pm b/Bugzilla/Config/Admin.pm index ad24f7112..ac1c4ca0e 100644 --- a/Bugzilla/Config/Admin.pm +++ b/Bugzilla/Config/Admin.pm @@ -12,7 +12,7 @@ use strict; use warnings; use Bugzilla::Config::Common; -use JSON::XS qw(decode_json); +use JSON::XS qw(decode_json encode_json); use List::MoreUtils qw(all); use Scalar::Util qw(looks_like_number); @@ -55,8 +55,9 @@ sub get_param_list { { name => 'rate_limit_rules', type => 'l', - default => '{"get_bug": [75, 60], "show_bug": [75, 60]}', + default => '{"get_bug": [75, 60], "show_bug": [75, 60], "github": [10, 60]}', checker => \&check_rate_limit_rules, + updater => \&update_rate_limit_rules, }, { @@ -78,11 +79,18 @@ sub check_rate_limit_rules { ref($_) eq 'ARRAY' && looks_like_number( $_->[0] ) && looks_like_number( $_->[1] ) } values %$val; - foreach my $required (qw( show_bug get_bug )) { + foreach my $required (qw( show_bug get_bug github )) { return "missing $required" unless exists $val->{$required}; } return ""; } +sub update_rate_limit_rules { + my ($rules) = @_; + my $val = decode_json($rules); + $val->{github} = [10, 60]; + return encode_json($val); +} + 1; -- cgit v1.2.3-24-g4f1b