-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPP-3838: restore safer CSP #4854
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests run fine on /accounts/profile/
, but have errors on /faq/
.
A warning "@next/third-parties: GA dataLayer dataLayer does not exist" is raised at GoogleAnalyticsWorkaround.tsx:103:12
. This is then followed by an error
Content-Security-Policy: The page’s settings blocked an inline script (script-src-elem) from being executed because it violates the following directive: “script-src 'self' https://www.google-analytics.com/ https://*.googletagmanager.com https://js.stripe.com/”
It doesn't happen when the trailing slash is in the path patterns.
privaterelay/middleware.py
Outdated
from whitenoise.middleware import WhiteNoiseMiddleware | ||
|
||
metrics = markus.get_metrics("fx-private-relay") | ||
|
||
|
||
CSP_NONCE_COOKIE_URLS = ["/", "/premium", "/faq", "/accounts/profile/"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add "/phone/", "/premium/waitlist/", "/phone/waitlist/", "/vpn-relay/waitlist/", "/contains-tracker-warning/", "/account/settings/", "/accounts/account_inactive/", "/vpn-relay-welcome/", "/tracker-report/"
Add the trailing slash for /premium/
and /faq/
Use a new EagerNonceCSPMiddleware to add nonce to the CSP and update the React app to include it in dynamic scripts.
Use SpectacularSwaggerSplitView to load the script as a <script> tag instead of an inline script. This means 'unsafe-inline' is not needed for API docs.
991403b
to
78508ad
Compare
Updated to include all url paths returned by:
(except the |
Co-authored-by: John Whitlock <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @groovecoder!
Use a new EagerNonceCSPMiddleware to add nonce to the CSP and update the React app to include it in dynamic scripts.
This PR fixes MPP-3838.
How to test:
frontend/
,npm run watch
to build the new front-end filespython manage.py runserver
l10n changes have been submitted to the l10n repository, if any.I've added a unit test to test for potential regressions of this bug.I've added or updated relevant docs in the docs/ directory.All UI revisions follow the coding standards, and use Protocol tokens where applicable (see/frontend/src/styles/tokens.scss
).