Skip to content
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

CSP: Remove unsafe-eval & unsafe-inline from script-src #14831

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bedrock/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
CONTENT_SECURITY_POLICY_REPORT_ONLY["DIRECTIVES"]["style-src"].remove(csp.constants.UNSAFE_INLINE)
CONTENT_SECURITY_POLICY_REPORT_ONLY["DIRECTIVES"]["upgrade-insecure-requests"] = True
CONTENT_SECURITY_POLICY_REPORT_ONLY["DIRECTIVES"]["base-uri"] = [csp.constants.NONE]
CONTENT_SECURITY_POLICY_REPORT_ONLY["DIRECTIVES"]["script-src"].remove(csp.constants.UNSAFE_EVAL)
CONTENT_SECURITY_POLICY_REPORT_ONLY["DIRECTIVES"]["script-src"].remove(csp.constants.UNSAFE_INLINE)


# `CSP_PATH_OVERRIDES` and `CSP_PATH_OVERRIDES_REPORT_ONLY` are mainly for overriding CSP settings
Expand Down Expand Up @@ -163,7 +165,11 @@ def _override_csp(csp, append: dict[str, list[str]] = None, replace: dict[str, l

if csp_ro_report_uri:
# Path based overrides for report-only CSP.
CMS_ADMIN_CSP_RO = _override_csp(CONTENT_SECURITY_POLICY_REPORT_ONLY, replace={"frame-ancestors": [csp.constants.SELF]})
CMS_ADMIN_CSP_RO = _override_csp(
CONTENT_SECURITY_POLICY_REPORT_ONLY,
append={"script-src": [csp.constants.UNSAFE_INLINE]},
replace={"frame-ancestors": [csp.constants.SELF]},
)
CMS_ADMIN_IMAGES_CSP_RO = _override_csp(CONTENT_SECURITY_POLICY_REPORT_ONLY, append={"img-src": ["blob:"]})

CSP_PATH_OVERRIDES_REPORT_ONLY = {
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
path: path.resolve(__dirname, 'assets/'),
publicPath: '/media/'
},
devtool: 'source-map',
optimization: {
minimizer: [
new TerserPlugin({
Expand Down
Loading