summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla.pm1
-rw-r--r--Bugzilla/Memcached.pm2
-rw-r--r--Bugzilla/Quantum/Plugin/BasicAuth.pm10
-rw-r--r--Bugzilla/Quantum/Plugin/BlockIP.pm20
-rw-r--r--Bugzilla/Quantum/Plugin/Hostage.pm29
5 files changed, 33 insertions, 29 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 0dadfc549..596824b6d 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -854,6 +854,7 @@ sub markdown_parser {
# Per-process cleanup. Note that this is a plain subroutine, not a method,
# so we don't have $class available.
+*cleanup = \&_cleanup;
sub _cleanup {
return if $^C;
diff --git a/Bugzilla/Memcached.pm b/Bugzilla/Memcached.pm
index 40755aa29..6bbef080a 100644
--- a/Bugzilla/Memcached.pm
+++ b/Bugzilla/Memcached.pm
@@ -25,6 +25,8 @@ use Sys::Syslog qw(:DEFAULT);
use constant MAX_KEY_LENGTH => 250;
use constant RATE_LIMIT_PREFIX => "rate:";
+*new = \&_new;
+
sub _new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
diff --git a/Bugzilla/Quantum/Plugin/BasicAuth.pm b/Bugzilla/Quantum/Plugin/BasicAuth.pm
index bc79c89ef..e17273404 100644
--- a/Bugzilla/Quantum/Plugin/BasicAuth.pm
+++ b/Bugzilla/Quantum/Plugin/BasicAuth.pm
@@ -16,15 +16,15 @@ sub register {
$app->renderer->add_helper(
basic_auth => sub {
- my ($c, $realm, $auth_user, $auth_pass) = @_;
+ my ( $c, $realm, $auth_user, $auth_pass ) = @_;
my $req = $c->req;
- my ($user, $password) = $req->url->to_abs->userinfo =~ /^([^:]+):(.*)/;
+ my ( $user, $password ) = $req->url->to_abs->userinfo =~ /^([^:]+):(.*)/;
- unless ($realm && $auth_user && $auth_pass) {
+ unless ( $realm && $auth_user && $auth_pass ) {
croak 'basic_auth() called with missing parameters.';
}
- unless ($user eq $auth_user && $password eq $auth_pass) {
+ unless ( $user eq $auth_user && $password eq $auth_pass ) {
WARN('username and password do not match');
$c->res->headers->www_authenticate("Basic realm=\"$realm\"");
$c->res->code(401);
@@ -37,4 +37,4 @@ sub register {
);
}
-1;
+1; \ No newline at end of file
diff --git a/Bugzilla/Quantum/Plugin/BlockIP.pm b/Bugzilla/Quantum/Plugin/BlockIP.pm
index fbfffad66..ebeb2a4aa 100644
--- a/Bugzilla/Quantum/Plugin/BlockIP.pm
+++ b/Bugzilla/Quantum/Plugin/BlockIP.pm
@@ -4,34 +4,34 @@ use Mojo::Base 'Mojolicious::Plugin';
use Bugzilla::Memcached;
-use constant BLOCK_TIMEOUT => 60*60;
+use constant BLOCK_TIMEOUT => 60 * 60;
-my $MEMCACHED = Bugzilla::Memcached->_new()->{memcached};
+my $MEMCACHED = Bugzilla::Memcached->new()->{memcached};
sub register {
my ( $self, $app, $conf ) = @_;
- $app->hook(before_routes => \&_before_routes);
- $app->helper(block_ip => \&_block_ip);
- $app->helper(unblock_ip => \&_unblock_ip);
+ $app->hook( before_routes => \&_before_routes );
+ $app->helper( block_ip => \&_block_ip );
+ $app->helper( unblock_ip => \&_unblock_ip );
}
sub _block_ip {
- my ($class, $ip) = @_;
- $MEMCACHED->set("block_ip:$ip" => 1, BLOCK_TIMEOUT) if $MEMCACHED;
+ my ( $class, $ip ) = @_;
+ $MEMCACHED->set( "block_ip:$ip" => 1, BLOCK_TIMEOUT ) if $MEMCACHED;
}
sub _unblock_ip {
- my ($class, $ip) = @_;
+ my ( $class, $ip ) = @_;
$MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
}
sub _before_routes {
- my ( $c ) = @_;
+ my ($c) = @_;
return if $c->stash->{'mojo.static'};
my $ip = $c->tx->remote_address;
- if ($MEMCACHED && $MEMCACHED->get("block_ip:$ip")) {
+ if ( $MEMCACHED && $MEMCACHED->get("block_ip:$ip") ) {
$c->block_ip($ip);
$c->res->code(429);
$c->res->message("Too Many Requests");
diff --git a/Bugzilla/Quantum/Plugin/Hostage.pm b/Bugzilla/Quantum/Plugin/Hostage.pm
index 42a05a910..19c77995e 100644
--- a/Bugzilla/Quantum/Plugin/Hostage.pm
+++ b/Bugzilla/Quantum/Plugin/Hostage.pm
@@ -6,14 +6,14 @@ sub _attachment_root {
my ($base) = @_;
return undef unless $base;
return $base =~ m{^https?://(?:bug)?\%bugid\%\.([a-zA-Z\.-]+)}
- ? $1
- : undef;
+ ? $1
+ : undef;
}
sub _attachment_host_regex {
my ($base) = @_;
return undef unless $base;
- my $val = $base;
+ my $val = $base;
$val =~ s{^https?://}{}s;
$val =~ s{/$}{}s;
my $regex = quotemeta $val;
@@ -24,11 +24,11 @@ sub _attachment_host_regex {
sub register {
my ( $self, $app, $conf ) = @_;
- $app->hook(before_routes => \&_before_routes);
+ $app->hook( before_routes => \&_before_routes );
}
sub _before_routes {
- my ( $c ) = @_;
+ my ($c) = @_;
state $urlbase = Bugzilla->localconfig->{urlbase};
state $urlbase_uri = URI->new($urlbase);
state $urlbase_host = $urlbase_uri->host;
@@ -43,31 +43,32 @@ sub _before_routes {
return if $stash->{'mojo.static'};
- my $hostname = $url->host;
+ my $hostname = $url->host;
return if $hostname eq $urlbase_host;
my $path = $url->path;
return if $path eq '/__lbheartbeat__';
- if ($attachment_base && $hostname eq $attachment_root) {
+ if ( $attachment_base && $hostname eq $attachment_root ) {
$c->redirect_to($urlbase);
return;
}
- elsif ($attachment_base && $hostname =~ $attachment_host_regex) {
- if ($path =~ m{^/attachment\.cgi}s) {
+ elsif ( $attachment_base && $hostname =~ $attachment_host_regex ) {
+ if ( $path =~ m{^/attachment\.cgi}s ) {
return;
- } else {
+ }
+ else {
my $new_uri = $url->clone;
- $new_uri->scheme($urlbase_uri->scheme);
+ $new_uri->scheme( $urlbase_uri->scheme );
$new_uri->host($urlbase_host);
$c->redirect_to($new_uri);
return;
}
}
- elsif (my ($id) = $hostname =~ $urlbase_host_regex) {
+ elsif ( my ($id) = $hostname =~ $urlbase_host_regex ) {
my $new_uri = $urlbase_uri->clone;
$new_uri->path('/show_bug.cgi');
- $new_uri->query_form(id => $id);
+ $new_uri->query_form( id => $id );
$c->redirect_to($new_uri);
return;
}
@@ -77,4 +78,4 @@ sub _before_routes {
}
}
-1; \ No newline at end of file
+1;