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%;}" %] - + : Enter the path to the file on your computer (or - paste text as attachment).
+ + paste text as attachment).
@@ -58,7 +67,7 @@

[%# 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 %] -