From 541e2b41af8cc44ad3eb0638618bc457c666d612 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 7 Apr 2018 19:20:00 -0400 Subject: a bit of a quantum leap It's now possible to load the CGIs into a mojolicious controller. Compatibility isn't 100% yet, but it should give a migration path for any random CGI to become a proper controller. --- scripts/bugzilla_quantum | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 scripts/bugzilla_quantum (limited to 'scripts') diff --git a/scripts/bugzilla_quantum b/scripts/bugzilla_quantum new file mode 100755 index 000000000..1112faabd --- /dev/null +++ b/scripts/bugzilla_quantum @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +use 5.10.1; +use strict; +use warnings; + +use File::Basename qw(basename dirname); +use File::Spec::Functions qw(catdir rel2abs); + +BEGIN { + require lib; + my $dir = rel2abs( catdir(dirname(__FILE__), '..') ); + lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) ); +} +use Mojolicious::Commands; + +# Start command line interface for application +Mojolicious::Commands->start_app('Bugzilla::Quantum'); \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f5a81daeeb16c6f64475f3a48b8ea5eb0ec84c9b Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 19 May 2018 18:45:58 -0400 Subject: run mojolicious daemon instead of httpd --- scripts/bugzilla_quantum | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/bugzilla_quantum b/scripts/bugzilla_quantum index 1112faabd..9069a2f05 100755 --- a/scripts/bugzilla_quantum +++ b/scripts/bugzilla_quantum @@ -4,14 +4,15 @@ use strict; use warnings; use File::Basename qw(basename dirname); -use File::Spec::Functions qw(catdir rel2abs); +use File::Spec::Functions qw(catdir); +use Cwd qw(realpath); BEGIN { require lib; - my $dir = rel2abs( catdir(dirname(__FILE__), '..') ); + my $dir = realpath( catdir(dirname(__FILE__), '..') ); lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) ); } use Mojolicious::Commands; # Start command line interface for application -Mojolicious::Commands->start_app('Bugzilla::Quantum'); \ No newline at end of file +Mojolicious::Commands->start_app('Bugzilla::Quantum'); -- cgit v1.2.3-24-g4f1b From 258d3e1c7d5d99ab202ffe5ce777c435fc34d44a Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Wed, 13 Jun 2018 12:26:14 -0400 Subject: add script --- scripts/rewrite2mojo.pl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/rewrite2mojo.pl (limited to 'scripts') diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl new file mode 100755 index 000000000..42188d739 --- /dev/null +++ b/scripts/rewrite2mojo.pl @@ -0,0 +1,39 @@ +#!/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; + +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/; + my $action = 'rewrite_query'; + if ($flags =~ /R/) { + $action = 'redirect'; + } + say qq{# from line $. of $ARGV}; + say "if (my \@match = \$path =~ m{$regex}s) {"; + say " $action(\$c, q{$target}, \@match);"; + say " return;" if $flags =~ /L/; + say "}"; + } + elsif (lc($cmd) eq "\LRedirect") { + say qq{# from line $. of $ARGV}; + say "if (my \@match = \$path =~ m{$regex}s) {"; + say " $action(\$c, q{$target}, \@match);"; + say " return;" if $flags =~ /L/; + say "}"; + } +} + + -- cgit v1.2.3-24-g4f1b From b3a6e0da65144921a99a369398dd390f5c65bef3 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 14 Jun 2018 14:32:43 -0400 Subject: work in progress --- scripts/rewrite2mojo.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl index 42188d739..66fc0d832 100755 --- a/scripts/rewrite2mojo.pl +++ b/scripts/rewrite2mojo.pl @@ -17,22 +17,29 @@ while (<>) { my ($regex, $target, $flags) = @args; $flags //= ''; next if $flags =~ /E=HTTP/; + next if $target eq '-'; + next if $target =~ /BzAPI/; + next if $target =~ /rest\.cgi/; my $action = 'rewrite_query'; if ($flags =~ /R/) { $action = 'redirect'; } - say qq{# from line $. of $ARGV}; say "if (my \@match = \$path =~ m{$regex}s) {"; say " $action(\$c, q{$target}, \@match);"; say " return;" if $flags =~ /L/; say "}"; } elsif (lc($cmd) eq "\LRedirect") { - say qq{# from line $. of $ARGV}; - say "if (my \@match = \$path =~ m{$regex}s) {"; - say " $action(\$c, q{$target}, \@match);"; - say " return;" if $flags =~ /L/; - say "}"; + 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"; + } } } -- cgit v1.2.3-24-g4f1b From d384888e734489a1524ca3ab1ad271343258bdea Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Fri, 15 Jun 2018 18:30:47 -0400 Subject: fix more tests, hopefully --- scripts/rewrite2mojo.pl | 62 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'scripts') diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl index 66fc0d832..bae6d514b 100755 --- a/scripts/rewrite2mojo.pl +++ b/scripts/rewrite2mojo.pl @@ -9,6 +9,8 @@ use 5.10.1; use strict; use warnings; +use Mojo::Parameters; +use Data::Dumper; while (<>) { my ($cmd, @args) = split /\s+/, $_; @@ -18,29 +20,51 @@ while (<>) { $flags //= ''; next if $flags =~ /E=HTTP/; next if $target eq '-'; - next if $target =~ /BzAPI/; - next if $target =~ /rest\.cgi/; my $action = 'rewrite_query'; if ($flags =~ /R/) { - $action = 'redirect'; - } - say "if (my \@match = \$path =~ m{$regex}s) {"; - say " $action(\$c, q{$target}, \@match);"; - say " return;" if $flags =~ /L/; - 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"; + 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; } -- cgit v1.2.3-24-g4f1b From e1b48df3b5cdd81920782a8585864af3b294e919 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 19 Jun 2018 21:28:50 -0400 Subject: lots of hacking --- scripts/bugzilla_quantum | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100755 scripts/bugzilla_quantum (limited to 'scripts') diff --git a/scripts/bugzilla_quantum b/scripts/bugzilla_quantum deleted file mode 100755 index 9069a2f05..000000000 --- a/scripts/bugzilla_quantum +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env perl -use 5.10.1; -use strict; -use warnings; - -use File::Basename qw(basename dirname); -use File::Spec::Functions qw(catdir); -use Cwd qw(realpath); - -BEGIN { - require lib; - my $dir = realpath( catdir(dirname(__FILE__), '..') ); - lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) ); -} -use Mojolicious::Commands; - -# Start command line interface for application -Mojolicious::Commands->start_app('Bugzilla::Quantum'); -- cgit v1.2.3-24-g4f1b From b167dfd575095cd574560a054673b0d3e78d9966 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 21 Jun 2018 15:35:34 -0400 Subject: port BlockIP to mojolicious --- scripts/block-ip.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'scripts') 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. +This is just a simple CLI inteface to L. -- cgit v1.2.3-24-g4f1b From 7cf010d2aaae017c5d1d416894f8d98bbf2ee082 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 28 Jun 2018 12:29:00 -0400 Subject: remove MOD_PERL bits --- scripts/undo.pl | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/undo.pl (limited to 'scripts') diff --git a/scripts/undo.pl b/scripts/undo.pl old mode 100644 new mode 100755 -- cgit v1.2.3-24-g4f1b From fbdbbe2d0dc333fdd6fb547254d2cab57ed3bc98 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 28 Jun 2018 13:02:20 -0400 Subject: run selenium tests in single httpd mode --- scripts/entrypoint.pl | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl index ce1cc795b..e5ecc4324 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(); -- cgit v1.2.3-24-g4f1b