summaryrefslogtreecommitdiff
path: root/app/views/layouts/errors.html.haml
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-05 23:14:32 -0700
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-07 12:37:31 +1000
commit5fbbd3dd6e965f76ecf1767373bddd236a78a4be (patch)
treeb3331f59d21a479deb970f4067b47c8352d8731e /app/views/layouts/errors.html.haml
parentfa216b0e86433192ba4e39a05f42217fb4685173 (diff)
downloadgitlab-ce-5fbbd3dd6e965f76ecf1767373bddd236a78a4be.tar.gz
Add support for Content-Security-Policy
A nonce-based Content-Security-Policy thwarts XSS attacks by allowing inline JavaScript to execute if the script nonce matches the header value. Rails 5.2 supports nonce-based Content-Security-Policy headers, so provide configuration to enable this and make it work. To support this, we need to change all `:javascript` HAML filters to the following form: ``` = javascript_tag nonce: true do :plain ... ``` We use `%script` throughout our HAML to store JSON and other text, but since this doesn't execute, browsers don't appear to block this content from being used and require the nonce value to be present.
Diffstat (limited to 'app/views/layouts/errors.html.haml')
-rw-r--r--app/views/layouts/errors.html.haml16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/views/layouts/errors.html.haml b/app/views/layouts/errors.html.haml
index 06069a72951..74484005b48 100644
--- a/app/views/layouts/errors.html.haml
+++ b/app/views/layouts/errors.html.haml
@@ -8,12 +8,12 @@
%body
.page-container
= yield
- -# haml-lint:disable InlineJavaScript
- :javascript
- (function(){
- var goBackElement = document.querySelector('.js-go-back');
+ = javascript_tag nonce: true do
+ :plain
+ (function(){
+ var goBackElement = document.querySelector('.js-go-back');
- if (goBackElement && history.length > 1) {
- goBackElement.style.display = 'block';
- }
- }());
+ if (goBackElement && history.length > 1) {
+ goBackElement.style.display = 'block';
+ }
+ }());