From 2e6e3e13587ee526ba94faabd5551e67508518f5 Mon Sep 17 00:00:00 2001 From: dklawren Date: Fri, 7 Sep 2018 06:04:50 -0400 Subject: Bug 1488292 - Remove MozReview extension from BMO code tree as MozReview is being decommissioned --- scripts/issue-api-key.pl | 4 ---- 1 file changed, 4 deletions(-) (limited to 'scripts') diff --git a/scripts/issue-api-key.pl b/scripts/issue-api-key.pl index 810b7e17e..e4cc1cdd0 100755 --- a/scripts/issue-api-key.pl +++ b/scripts/issue-api-key.pl @@ -33,10 +33,6 @@ my $params = { api_key => $given_api_key, }; -if ($description && $description eq 'mozreview') { - $params->{app_id} = Bugzilla->params->{mozreview_app_id} // ''; -} - if ($given_api_key) { $api_key = Bugzilla::User::APIKey->create_special($params); } else { -- cgit v1.2.3-24-g4f1b From a91453b19c462929b3ab77927b0d0a6807558b92 Mon Sep 17 00:00:00 2001 From: Israel Madueme Date: Mon, 10 Sep 2018 12:34:56 -0400 Subject: Bug 1479466 - Add Security Bugs Report Adds the security bugs report with open count and median age open of sec-critical and sec-high bugs. --- scripts/secbugsreport.pl | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 scripts/secbugsreport.pl (limited to 'scripts') diff --git a/scripts/secbugsreport.pl b/scripts/secbugsreport.pl new file mode 100644 index 000000000..ae0639e20 --- /dev/null +++ b/scripts/secbugsreport.pl @@ -0,0 +1,83 @@ +#!/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. +# +# Usage secbugsreport.pl YYYY MM DD, e.g. secbugsreport.pl $(date +'%Y %m %d') + +use 5.10.1; +use strict; +use warnings; + +use lib qw(. lib local/lib/perl5); + +use Bugzilla; +use Bugzilla::Component; +use Bugzilla::Constants; +use Bugzilla::Error; +use Bugzilla::Mailer; +use Bugzilla::Report::SecurityRisk; + +use DateTime; +use URI; +use JSON::MaybeXS; + +BEGIN { Bugzilla->extensions } +Bugzilla->usage_mode(USAGE_MODE_CMDLINE); + +exit 0 unless Bugzilla->params->{report_secbugs_active}; +exit 0 unless defined $ARGV[0] && defined $ARGV[1] && defined $ARGV[2]; + +my $html; +my $template = Bugzilla->template(); +my $end_date = DateTime->new( year => $ARGV[0], month => $ARGV[1], day => $ARGV[2] ); +my $start_date = $end_date->clone()->subtract( months => 6 ); +my $report_week = $end_date->ymd('-'); +my $products = decode_json( Bugzilla->params->{report_secbugs_products} ); +my $sec_keywords = [ 'sec-critical', 'sec-high' ]; +my $report = Bugzilla::Report::SecurityRisk->new( + start_date => $start_date, + end_date => $end_date, + products => $products, + sec_keywords => $sec_keywords +); +my $vars = { + urlbase => Bugzilla->localconfig->{urlbase}, + report_week => $report_week, + products => $products, + sec_keywords => $sec_keywords, + results => $report->results, + build_bugs_link => \&build_bugs_link, +}; + +$template->process( 'reports/email/security-risk.html.tmpl', $vars, \$html ) + or ThrowTemplateError( $template->error() ); + +# For now, only send HTML email. +my $email = Email::MIME->create( + header_str => [ + From => Bugzilla->params->{'mailfrom'}, + To => Bugzilla->params->{report_secbugs_emails}, + Subject => "Security Bugs Report for $report_week" + ], + attributes => { + content_type => 'text/html', + charset => 'UTF-8', + encoding => 'quoted-printable', + }, + body_str => $html, +); + +MessageToMTA($email); + +sub build_bugs_link { + my ( $arr, $product ) = @_; + my $uri = URI->new( Bugzilla->localconfig->{urlbase} . 'buglist.cgi' ); + $uri->query_param( bug_id => ( join ',', @$arr ) ); + $uri->query_param( product => $product ) if $product; + return $uri->as_string; +} -- cgit v1.2.3-24-g4f1b From c8b47ef3d5b39ab99065fe387c9ae93301b3aab0 Mon Sep 17 00:00:00 2001 From: Israel Madueme Date: Mon, 10 Sep 2018 13:30:05 -0400 Subject: no bug - add X-Bugzilla-Type to secbugsreport email --- scripts/secbugsreport.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/secbugsreport.pl b/scripts/secbugsreport.pl index ae0639e20..81041b222 100644 --- a/scripts/secbugsreport.pl +++ b/scripts/secbugsreport.pl @@ -62,7 +62,8 @@ my $email = Email::MIME->create( header_str => [ From => Bugzilla->params->{'mailfrom'}, To => Bugzilla->params->{report_secbugs_emails}, - Subject => "Security Bugs Report for $report_week" + Subject => "Security Bugs Report for $report_week", + 'X-Bugzilla-Type' => 'admin' ], attributes => { content_type => 'text/html', -- cgit v1.2.3-24-g4f1b From b8b2a943056adbb112474df7bdf766970a56b2dc Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 18 Sep 2018 18:19:03 -0400 Subject: Bug 1455495 - Replace apache with Mojolicious --- scripts/block-ip.pl | 10 ++++++---- scripts/entrypoint.pl | 14 +------------- scripts/undo.pl | 0 3 files changed, 7 insertions(+), 17 deletions(-) mode change 100644 => 100755 scripts/undo.pl (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. diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl index ce1cc795b..21d9aebb1 100755 --- a/scripts/entrypoint.pl +++ b/scripts/entrypoint.pl @@ -83,7 +83,6 @@ sub cmd_demo { sub cmd_httpd { check_data_dir(); wait_for_db(); - check_httpd_env(); my $httpd_exit_f = run_cereal_and_httpd(); assert_httpd()->get(); @@ -156,6 +155,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(); @@ -207,8 +207,6 @@ sub cmd_test_bmo { sub run_prove { my (%param) = @_; - check_httpd_env(); - my $prove_cmd = $param{prove_cmd}; my $prove_dir = $param{prove_dir}; assert_httpd()->then(sub { @@ -268,16 +266,6 @@ sub check_env { die 'Missing required environmental variables: ', join(', ', @missing_env), "\n"; } } -sub check_httpd_env { - check_env(qw( - HTTPD_StartServers - HTTPD_MinSpareServers - HTTPD_MaxSpareServers - HTTPD_ServerLimit - HTTPD_MaxClients - HTTPD_MaxRequestsPerChild - )) -} sub fix_path { $ENV{PATH} = "/app/local/bin:$ENV{PATH}"; diff --git a/scripts/undo.pl b/scripts/undo.pl old mode 100644 new mode 100755 -- cgit v1.2.3-24-g4f1b From 6a87c6d646f28edd54961b4a967d9de2e4b7b66a Mon Sep 17 00:00:00 2001 From: dklawren Date: Mon, 24 Sep 2018 10:53:23 -0400 Subject: Bug 1492346 - scripts/syncflags.pl should also add the target product to any tracking flags that the source product is a member --- scripts/syncflags.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'scripts') diff --git a/scripts/syncflags.pl b/scripts/syncflags.pl index e6b521e62..c99fd5160 100755 --- a/scripts/syncflags.pl +++ b/scripts/syncflags.pl @@ -75,6 +75,7 @@ if (!$tgtprodid) { exit(1); } +# Normal flags such as bug flags and attachment flags $dbh->do("INSERT INTO flaginclusions(component_id, type_id, product_id) SELECT fi1.component_id, fi1.type_id, ? FROM flaginclusions fi1 LEFT JOIN flaginclusions fi2 @@ -85,6 +86,17 @@ $dbh->do("INSERT INTO flaginclusions(component_id, type_id, product_id) undef, $tgtprodid, $tgtprodid, $srcprodid); +# Tracking type flags +$dbh->do("INSERT INTO tracking_flags_visibility (tracking_flag_id, product_id, component_id) + SELECT tf1.tracking_flag_id, ?, tf1.component_id FROM tracking_flags_visibility tf1 + LEFT JOIN tracking_flags_visibility tf2 + ON tf1.tracking_flag_id = tf2.tracking_flag_id + AND tf2.product_id = ? + WHERE tf1.product_id = ? + AND tf2.tracking_flag_id IS NULL", + undef, + $tgtprodid, $tgtprodid, $srcprodid); + # It's complex to determine which items now need to be flushed from memcached. # As this is expected to be a rare event, we just flush the entire cache. Bugzilla->memcached->clear_all(); -- cgit v1.2.3-24-g4f1b From abe9b579f25120898b714d4b73343918169d48ac Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 2 Oct 2018 00:24:25 -0400 Subject: no bug - adopt mojolicious code formatting guidelines (#784) @kyoshino likes 2-char indent for all the frontend. Mojolicious seems to use 2-space too. Let's just adopt their perltidyrc. Included in this is a script (in scripts/) that will modify files according to these rules. --- scripts/perl-fmt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/perl-fmt (limited to 'scripts') diff --git a/scripts/perl-fmt b/scripts/perl-fmt new file mode 100644 index 000000000..4b5ea3565 --- /dev/null +++ b/scripts/perl-fmt @@ -0,0 +1,24 @@ +#!/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 File::Basename qw(dirname); +use Cwd qw(realpath); +use File::Spec::Functions qw(catfile catdir); +use Env qw(@PATH @PERL5LIB); + +my $bugzilla_dir = realpath(catdir( dirname(__FILE__), '..' )); +unshift @PERL5LIB, catdir($bugzilla_dir, 'local', 'lib', 'perl5'); +unshift @PATH, catdir($bugzilla_dir, 'local', 'bin'); + +my $profile = catfile($bugzilla_dir, ".perltidyrc" ); +warn "formatting @ARGV\n"; +exec( perltidy => "--profile=$profile", '-nst', '-b', '-bext=/', '-conv', @ARGV ); -- cgit v1.2.3-24-g4f1b