summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/issue-api-key.pl4
-rw-r--r--scripts/perl-fmt24
-rw-r--r--scripts/secbugsreport.pl84
-rwxr-xr-xscripts/syncflags.pl12
4 files changed, 120 insertions, 4 deletions
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 {
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 );
diff --git a/scripts/secbugsreport.pl b/scripts/secbugsreport.pl
new file mode 100644
index 000000000..81041b222
--- /dev/null
+++ b/scripts/secbugsreport.pl
@@ -0,0 +1,84 @@
+#!/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",
+ 'X-Bugzilla-Type' => 'admin'
+ ],
+ 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;
+}
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();