From d435e0a5b0e07c145f929457313d8d7738f42b14 Mon Sep 17 00:00:00 2001
From: Dylan William Hardison
Date: Wed, 21 Feb 2018 13:59:53 -0500
Subject: [PATCH] Bug 1439797 - Enable reporting-only CSP by default
---
Bugzilla/CGI.pm | 16 +++++-----
Bugzilla/CGI/ContentSecurityPolicy.pm | 4 +--
chart.cgi | 1 +
.../en/default/account/create.html.tmpl | 2 +-
.../bug/create/create-automative.html.tmpl | 4 +--
.../bug/create/create-creative.html.tmpl | 2 +-
.../bug/create/create-fsa-budget.html.tmpl | 2 +-
.../bug/create/create-mozlist.html.tmpl | 2 +-
.../default/bug/create/create-mozpr.html.tmpl | 6 ++--
.../default/bug/create/create-swag.html.tmpl | 2 +-
.../create/create-user-engagement.html.tmpl | 2 +-
.../admin/products/edit-common-rows.html.tmpl | 2 +-
.../hook/attachment/edit-view.html.tmpl | 2 +-
.../hook/bug/comments-a_comment-end.html.tmpl | 2 +-
.../hook/bug/comments-aftercomments.html.tmpl | 2 +-
.../bug/comments-comment_banner.html.tmpl | 2 +-
.../hook/bug/edit-after_importance.html.tmpl | 2 +-
.../hook/bug/edit-custom_field.html.tmpl | 2 +-
.../pages/attachment_bounty_form.html.tmpl | 6 ++--
.../pages/release_tracking_report.html.tmpl | 2 +-
.../en/default/pages/triage_reports.html.tmpl | 2 +-
.../en/default/pages/user_activity.html.tmpl | 2 +-
.../account/prefs/bugmail_filter.html.tmpl | 2 +-
.../account/prefs/component_watch.html.tmpl | 4 +--
.../components/edit-common-rows.html.tmpl | 2 +-
.../en/default/pages/edit_table.html.tmpl | 2 +-
.../default/flag/default_requestees.html.tmpl | 2 +-
.../en/default/flag/type_comment.html.tmpl | 2 +-
.../en/default/guided/guided.html.tmpl | 4 +--
.../hook/bug/comments-aftercomments.html.tmpl | 2 +-
.../en/default/pages/mydashboard.html.tmpl | 2 +-
.../edit-after_comment_textarea.html.tmpl | 2 +-
.../en/default/pages/push_config.html.tmpl | 4 +--
.../bug/create/create-remo-budget.html.tmpl | 4 +--
.../bug/create/create-remo-it.html.tmpl | 2 +-
.../bug/create/create-remo-swag.html.tmpl | 2 +-
.../default/pages/remo-form-payment.html.tmpl | 2 +-
.../hook/attachment/create-end.html.tmpl | 2 +-
.../hook/attachment/edit-end.html.tmpl | 2 +-
.../hook/bug/create/create-end.html.tmpl | 2 +-
.../hook/bug/edit-after_people.html.tmpl | 2 +-
.../hook/flag/list-requestee.html.tmpl | 2 +-
.../en/default/pages/review_history.html.tmpl | 2 +-
.../hook/admin/users/userdata-end.html.tmpl | 2 +-
.../en/default/pages/splinter.html.tmpl | 4 +--
.../en/default/bug/tracking_flags.html.tmpl | 4 +--
.../hook/bug/create/create-form.html.tmpl | 2 +-
.../bug/edit-after_custom_fields.html.tmpl | 2 +-
.../default/hook/bug/field-editable.html.tmpl | 2 +-
.../pages/tracking_flags_admin_edit.html.tmpl | 2 +-
.../bug/comments-comment_banner.html.tmpl | 4 +--
.../create-after_custom_fields.html.tmpl | 2 +-
.../admin/products/edit-common-rows.html.tmpl | 2 +-
report.cgi | 2 ++
static/metricsgraphics/socorro-lens.html | 2 +-
.../en/default/account/prefs/email.html.tmpl | 2 +-
.../account/prefs/saved-searches.html.tmpl | 2 +-
.../default/account/prefs/settings.html.tmpl | 2 +-
.../admin/custom_fields/create.html.tmpl | 2 +-
.../en/default/admin/params/common.html.tmpl | 2 +-
.../default/admin/workflow/comment.html.tmpl | 2 +-
.../en/default/admin/workflow/edit.html.tmpl | 2 +-
.../en/default/attachment/create.html.tmpl | 2 +-
.../attachment/createformcontents.html.tmpl | 17 ++++++++---
.../en/default/attachment/diff-file.html.tmpl | 2 +-
template/en/default/attachment/edit.html.tmpl | 4 +--
template/en/default/attachment/list.html.tmpl | 2 +-
template/en/default/bug/comments.html.tmpl | 8 ++---
.../bug/create/create-guided.html.tmpl | 4 +--
.../en/default/bug/create/create.html.tmpl | 8 ++---
template/en/default/bug/edit.html.tmpl | 12 ++++----
template/en/default/bug/field.html.tmpl | 12 ++++----
template/en/default/bug/knob.html.tmpl | 2 +-
.../en/default/bug/summarize-time.html.tmpl | 2 +-
.../en/default/list/edit-multiple.html.tmpl | 6 ++--
template/en/default/list/quips.html.tmpl | 2 +-
template/en/default/mfa/duo/verify.html.tmpl | 2 +-
.../en/default/reports/create-chart.html.tmpl | 30 +++++++++++--------
.../en/default/reports/keywords.html.tmpl | 2 +-
.../en/default/reports/report-table.html.tmpl | 2 +-
.../default/reports/series-common.html.tmpl | 2 +-
template/en/default/reports/series.html.tmpl | 23 +++++++++-----
template/en/default/request/queue.html.tmpl | 2 +-
.../default/search/boolean-charts.html.tmpl | 4 +--
template/en/default/search/field.html.tmpl | 4 +--
template/en/default/search/form.html.tmpl | 4 +--
.../search/search-create-series.html.tmpl | 2 +-
.../default/search/search-instant.html.tmpl | 2 +-
.../search/search-report-graph.html.tmpl | 2 +-
89 files changed, 175 insertions(+), 152 deletions(-)
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm
index 35d6dd687f..513d8c3021 100644
--- a/Bugzilla/CGI.pm
+++ b/Bugzilla/CGI.pm
@@ -34,8 +34,9 @@ BEGIN {
sub DEFAULT_CSP {
my %policy = (
default_src => [ 'self' ],
- script_src => [ 'self', 'unsafe-inline', 'unsafe-eval', 'https://www.google-analytics.com' ],
- child_src => [ 'self', ],
+ script_src => [ 'self', 'nonce', 'unsafe-inline', 'https://www.google-analytics.com' ],
+ frame_src => [ 'none', ],
+ worker_src => [ 'none', ],
img_src => [ 'self', 'https://secure.gravatar.com', 'https://www.google-analytics.com' ],
style_src => [ 'self', 'unsafe-inline' ],
object_src => [ 'none' ],
@@ -45,7 +46,7 @@ sub DEFAULT_CSP {
'https://www.google.com/search'
],
frame_ancestors => [ 'none' ],
- disable => 1,
+ report_only => 1,
);
if (Bugzilla->params->{github_client_id} && !Bugzilla->user->id) {
push @{$policy{form_action}}, 'https://github.com/login/oauth/authorize', 'https://github.com/login';
@@ -68,11 +69,8 @@ sub SHOW_BUG_MODAL_CSP {
# This is from extensions/OrangeFactor/web/js/orange_factor.js
'https://brasstacks.mozilla.com/orangefactor/api/count',
],
- child_src => [
- 'self',
- # This is for the socorro lens addon and is to be removed by Bug 1332016
- 'https://ashughes1.github.io/bugzilla-socorro-lens/chart.htm'
- ],
+ frame_src => [ 'none', ],
+ worker_src => [ 'none', ],
);
if (use_attachbase() && $bug_id) {
my $attach_base = Bugzilla->localconfig->{'attachment_base'};
@@ -194,7 +192,7 @@ sub content_security_policy {
require Bugzilla::CGI::ContentSecurityPolicy;
if (%add_params || !$self->{Bugzilla_csp}) {
my %params = DEFAULT_CSP;
- delete $params{disable} if %add_params && !$add_params{disable};
+ delete $params{report_only} if %add_params && !$add_params{report_only};
foreach my $key (keys %add_params) {
if (defined $add_params{$key}) {
$params{$key} = $add_params{$key};
diff --git a/Bugzilla/CGI/ContentSecurityPolicy.pm b/Bugzilla/CGI/ContentSecurityPolicy.pm
index 88f2732bc3..50a399cdc1 100644
--- a/Bugzilla/CGI/ContentSecurityPolicy.pm
+++ b/Bugzilla/CGI/ContentSecurityPolicy.pm
@@ -34,10 +34,10 @@ my $REFERRER_KEYWORD = enum [qw(
my @ALL_BOOL = qw( sandbox upgrade_insecure_requests );
my @ALL_SRC = qw(
- default_src child_src connect_src
+ default_src worker_src connect_src
font_src img_src media_src
object_src script_src style_src
- frame_ancestors form_action
+ frame_src frame_ancestors form_action
);
has \@ALL_SRC => ( is => 'ro', isa => $SOURCE_LIST, predicate => 1 );
diff --git a/chart.cgi b/chart.cgi
index 26f21c389b..36357cb3c1 100755
--- a/chart.cgi
+++ b/chart.cgi
@@ -51,6 +51,7 @@ local our $cgi = Bugzilla->cgi;
local our $template = Bugzilla->template;
local our $vars = {};
my $dbh = Bugzilla->dbh;
+$cgi->content_security_policy(report_only => 0);
my $user = Bugzilla->login(LOGIN_REQUIRED);
diff --git a/extensions/BMO/template/en/default/account/create.html.tmpl b/extensions/BMO/template/en/default/account/create.html.tmpl
index d293031049..10d5fb5c17 100644
--- a/extensions/BMO/template/en/default/account/create.html.tmpl
+++ b/extensions/BMO/template/en/default/account/create.html.tmpl
@@ -38,7 +38,7 @@
style_urls = [ 'extensions/BMO/web/styles/create_account.css' ]
%]
-
@@ -200,7 +200,7 @@ function validateAndSubmit() {
Calendar
-
diff --git a/extensions/BMO/template/en/default/bug/create/create-creative.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-creative.html.tmpl
index 13620d1c4f..eac24e53ec 100644
--- a/extensions/BMO/template/en/default/bug/create/create-creative.html.tmpl
+++ b/extensions/BMO/template/en/default/bug/create/create-creative.html.tmpl
@@ -209,7 +209,7 @@ function toggleTypeOther(element) {
Calendar
-
diff --git a/extensions/BMO/template/en/default/bug/create/create-fsa-budget.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-fsa-budget.html.tmpl
index 942b37afac..d97d95b2a6 100644
--- a/extensions/BMO/template/en/default/bug/create/create-fsa-budget.html.tmpl
+++ b/extensions/BMO/template/en/default/bug/create/create-fsa-budget.html.tmpl
@@ -139,7 +139,7 @@ function validateAndSubmit() {
Calendar
-
diff --git a/extensions/BMO/template/en/default/bug/create/create-mozlist.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-mozlist.html.tmpl
index ab03523ae6..8414770997 100644
--- a/extensions/BMO/template/en/default/bug/create/create-mozlist.html.tmpl
+++ b/extensions/BMO/template/en/default/bug/create/create-mozlist.html.tmpl
@@ -16,7 +16,7 @@
style = ".mandatory{color:red;font-size:80%;}"
%]
-
@@ -341,7 +341,7 @@ function validate_form() {
Calendar
-
@@ -355,7 +355,7 @@ function validate_form() {
Calendar
-
diff --git a/extensions/BMO/template/en/default/bug/create/create-swag.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-swag.html.tmpl
index 859d77194c..28b8045f61 100644
--- a/extensions/BMO/template/en/default/bug/create/create-swag.html.tmpl
+++ b/extensions/BMO/template/en/default/bug/create/create-swag.html.tmpl
@@ -810,7 +810,7 @@ function showGear() {
We do this to help protect the personal identifying information in this [% terms.bugs %].
-
diff --git a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
index 5486684f1b..632ccb1e65 100644
--- a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
@@ -30,7 +30,7 @@
This security group needs to be set to SHOWN/SHOWN
-
diff --git a/extensions/BMO/template/en/default/hook/bug/edit-after_importance.html.tmpl b/extensions/BMO/template/en/default/hook/bug/edit-after_importance.html.tmpl
index 6e15e50d31..1dec71b8df 100644
--- a/extensions/BMO/template/en/default/hook/bug/edit-after_importance.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/bug/edit-after_importance.html.tmpl
@@ -7,7 +7,7 @@
#%]
[%# Display product and component descriptions after their respective fields %]
-
@@ -177,7 +177,7 @@ function validateAndSubmit() {
Calendar
-
@@ -192,7 +192,7 @@ function validateAndSubmit() {
Calendar
-
diff --git a/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl b/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
index 79587205c1..8ee3d0d593 100644
--- a/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
+++ b/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
@@ -18,7 +18,7 @@
JavaScript is required to use this report.
-
diff --git a/extensions/BMO/template/en/default/pages/user_activity.html.tmpl b/extensions/BMO/template/en/default/pages/user_activity.html.tmpl
index 33aa27e3d7..075c8edf91 100644
--- a/extensions/BMO/template/en/default/pages/user_activity.html.tmpl
+++ b/extensions/BMO/template/en/default/pages/user_activity.html.tmpl
@@ -83,7 +83,7 @@
[% END %]
-
diff --git a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
index 32cb55ea15..bb1381c46e 100644
--- a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
+++ b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
@@ -14,7 +14,7 @@
[% SET selectable_products = user.get_selectable_products %]
[% SET dont_show_button = 1 %]
-
-
@@ -50,7 +50,7 @@ YAHOO.util.Dom.removeClass('loading', 'hidden');
Switch to the advanced [% terms.bug %] entry form
-
-
diff --git a/extensions/REMO/template/en/default/bug/create/create-remo-budget.html.tmpl b/extensions/REMO/template/en/default/bug/create/create-remo-budget.html.tmpl
index 62f45d5683..5c19ac7581 100644
--- a/extensions/REMO/template/en/default/bug/create/create-remo-budget.html.tmpl
+++ b/extensions/REMO/template/en/default/bug/create/create-remo-budget.html.tmpl
@@ -23,7 +23,7 @@
any persons designated in the CC line, and authorized members of the Mozilla
Rep team.
-
diff --git a/extensions/REMO/template/en/default/bug/create/create-remo-it.html.tmpl b/extensions/REMO/template/en/default/bug/create/create-remo-it.html.tmpl
index 10f65de398..af3db60bcc 100644
--- a/extensions/REMO/template/en/default/bug/create/create-remo-it.html.tmpl
+++ b/extensions/REMO/template/en/default/bug/create/create-remo-it.html.tmpl
@@ -17,7 +17,7 @@
[% USE Bugzilla %]
[% mandatory = '* ' %]
-
+
Mozilla Reps - Payment Form
diff --git a/extensions/Review/template/en/default/hook/attachment/create-end.html.tmpl b/extensions/Review/template/en/default/hook/attachment/create-end.html.tmpl
index 22d95d694c..ed5ae7b36e 100644
--- a/extensions/Review/template/en/default/hook/attachment/create-end.html.tmpl
+++ b/extensions/Review/template/en/default/hook/attachment/create-end.html.tmpl
@@ -10,7 +10,7 @@
[% bug = attachment.bug %]
[% END %]
-
diff --git a/extensions/Review/template/en/default/pages/review_history.html.tmpl b/extensions/Review/template/en/default/pages/review_history.html.tmpl
index d80ed5e0ad..c8263bc520 100644
--- a/extensions/Review/template/en/default/pages/review_history.html.tmpl
+++ b/extensions/Review/template/en/default/pages/review_history.html.tmpl
@@ -19,7 +19,7 @@
'js/field.js' ]
%]
-
[% IF !new_bug && user.id %]
@@ -47,7 +47,7 @@
[% END %]
-
diff --git a/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl b/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
index 4bb9e1eab5..005cc80625 100644
--- a/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
@@ -28,7 +28,7 @@
END;
%]
-
-
diff --git a/template/en/default/admin/params/common.html.tmpl b/template/en/default/admin/params/common.html.tmpl
index 4941afa38b..cd135e1d29 100644
--- a/template/en/default/admin/params/common.html.tmpl
+++ b/template/en/default/admin/params/common.html.tmpl
@@ -111,7 +111,7 @@
-
diff --git a/template/en/default/admin/workflow/comment.html.tmpl b/template/en/default/admin/workflow/comment.html.tmpl
index 9b447f777e..8f64c77a62 100644
--- a/template/en/default/admin/workflow/comment.html.tmpl
+++ b/template/en/default/admin/workflow/comment.html.tmpl
@@ -21,7 +21,7 @@
style_urls = ['skins/standard/admin.css']
%]
-
+
File :
Enter the path to the file on your computer (or
- paste text as attachment ).
+
+ paste text as attachment ).
@@ -58,7 +67,7 @@
patch
[%# Reset this whenever the page loads so that the JS state is up to date %]
-
diff --git a/template/en/default/attachment/edit.html.tmpl b/template/en/default/attachment/edit.html.tmpl
index 43bf4c83cd..d06d4ad563 100644
--- a/template/en/default/attachment/edit.html.tmpl
+++ b/template/en/default/attachment/edit.html.tmpl
@@ -219,7 +219,7 @@
View the attachment on a separate page .
[% END %]
-
-
[% ELSIF comment.collapsed %]
@@ -270,7 +270,7 @@
[% " bz_default_hidden" UNLESS comment.tags.size %]">