diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-11 12:48:53 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-11 13:04:03 +0100 |
commit | aa34ed466abc6ccb4aa577caf81a828d753233a0 (patch) | |
tree | ed882216e3f4268abfa3d4003bd852bb33d58339 /common | |
parent | 26459fb4ca619b675729b4bea7714914631dbb86 (diff) | |
download | browser-extension-aa34ed466abc6ccb4aa577caf81a828d753233a0.tar.gz browser-extension-aa34ed466abc6ccb4aa577caf81a828d753233a0.zip |
make the order of rules in generated CSP deterministic
This is purely to help with automated testing.
Diffstat (limited to 'common')
-rw-r--r-- | common/policy.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/common/policy.js b/common/policy.js index 47b2d1d..e14d8cd 100644 --- a/common/policy.js +++ b/common/policy.js @@ -52,9 +52,13 @@ function make_csp(nonce) { const rule = nonce ? `nonce-${nonce}` : "none"; - const csp_dict = {"prefetch-src": "none", "script-src-attr": "none"}; - Object.assign(csp_dict, {"script-src": rule, "script-src-elem": rule}); - return Object.entries(csp_dict).map(([a, b]) => `${a} '${b}';`).join(" "); + const csp_list = [ + ["prefetch-src", "none"], + ["script-src-attr", "none"], + ["script-src", rule], + ["script-src-elem", rule] + ]; + return csp_list.map(([a, b]) => `${a} '${b}';`).join(" "); } function decide_policy(patterns_tree, url, default_allow, secret) |