summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-08 07:04:18 +0200
committerDylan William Hardison <dylan@hardison.net>2018-07-08 07:04:18 +0200
commit597ac85a2a4219cb8cb6d916414e47a3abfa8c72 (patch)
tree1d01a86c4a32981a20016fa2204561588c96ea32 /scripts
parentbe1f92450788dc89280c9e04a4bf983b5d7fac54 (diff)
parentfbdbbe2d0dc333fdd6fb547254d2cab57ed3bc98 (diff)
downloadbugzilla-597ac85a2a4219cb8cb6d916414e47a3abfa8c72.tar.gz
bugzilla-597ac85a2a4219cb8cb6d916414e47a3abfa8c72.tar.xz
Merge remote-tracking branch 'dylanwh/mojo-poc'
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/block-ip.pl10
-rwxr-xr-xscripts/entrypoint.pl1
-rwxr-xr-xscripts/rewrite2mojo.pl70
-rwxr-xr-x[-rw-r--r--]scripts/undo.pl0
4 files changed, 77 insertions, 4 deletions
diff --git a/scripts/block-ip.pl b/scripts/block-ip.pl
index b767a1fd5..3fa66d336 100755
--- a/scripts/block-ip.pl
+++ b/scripts/block-ip.pl
@@ -12,8 +12,8 @@ use warnings;
use lib qw(. lib local/lib/perl5);
use Bugzilla;
+use Bugzilla::Quantum;
use Bugzilla::Constants;
-use Bugzilla::ModPerl::BlockIP;
use Getopt::Long;
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
@@ -23,10 +23,12 @@ GetOptions('unblock' => \$unblock);
pod2usage("No IPs given") unless @ARGV;
+my $app = Bugzilla::Quantum->new;
+
if ($unblock) {
- Bugzilla::ModPerl::BlockIP->unblock_ip($_) for @ARGV;
+ $app->unblock_ip($_) for @ARGV;
} else {
- Bugzilla::ModPerl::BlockIP->block_ip($_) for @ARGV;
+ $app->block_ip($_) for @ARGV;
}
=head1 NAME
@@ -52,4 +54,4 @@ If passed, the IPs will be unblocked instead of blocked. Use this to remove IPs
=head1 DESCRIPTION
-This is just a simple CLI inteface to L<Bugzilla::ModPerl::BlockIP>.
+This is just a simple CLI inteface to L<Bugzilla::Quantum::Plugin::BlockIP>.
diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl
index 1b0dcb7f1..c48582606 100755
--- a/scripts/entrypoint.pl
+++ b/scripts/entrypoint.pl
@@ -156,6 +156,7 @@ sub cmd_test_webservices {
sub cmd_test_selenium {
my $conf = require $ENV{BZ_QA_CONF_FILE};
+ $ENV{HTTP_BACKEND} = 'simple';
check_data_dir();
copy_qa_extension();
diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl
new file mode 100755
index 000000000..bae6d514b
--- /dev/null
+++ b/scripts/rewrite2mojo.pl
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use 5.10.1;
+use strict;
+use warnings;
+use Mojo::Parameters;
+use Data::Dumper;
+
+while (<>) {
+ my ($cmd, @args) = split /\s+/, $_;
+ next unless $cmd;
+ if (lc($cmd) eq "\LRewriteRule") {
+ my ($regex, $target, $flags) = @args;
+ $flags //= '';
+ next if $flags =~ /E=HTTP/;
+ next if $target eq '-';
+ my $action = 'rewrite_query';
+ if ($flags =~ /R/) {
+ next;
+ }
+ my ($script, $query) = $target =~ /^([^?]+)(?:\?(.+))?$/;
+ my $name = _file_to_method($script);
+ $regex =~ s/^\^//;
+ $regex =~ s/\$$//;
+ my $regex_name = _regex_to_name($regex);
+ my $param_hash = Mojo::Parameters->new($query)->to_hash;
+ my $param_str = Data::Dumper->new([$param_hash])->Terse(1)->Indent(0)->Dump;
+ say "\$r->any('/:$regex_name' => [$regex_name => qr{$regex}])->to(";
+ say " 'CGI#$name' => $param_str";
+ say ");";
+
+ }
+ # elsif (lc($cmd) eq "\LRedirect") {
+ # my ($type, $path, $url) = @args;
+ # if ($type eq 'permanent') {
+ # say "if (\$path =~ m{^\Q$path\E}s) {";
+ # say " redirect(\$c, q{$url});";
+ # say " return;";
+ # say "}";
+ # }
+ # else {
+ # warn "I don't understand Redirect $type\n";
+ # }
+ # }
+}
+
+sub _file_to_method {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ return $name;
+}
+
+sub _regex_to_name {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ $name =~ s/_+/_/g;
+ $name =~ s/^_//s;
+ $name =~ s/_$//s;
+ return $name;
+}
+
+
diff --git a/scripts/undo.pl b/scripts/undo.pl
index 24d6f594b..24d6f594b 100644..100755
--- a/scripts/undo.pl
+++ b/scripts/undo.pl