A platform for community discussion. Free, open, simple.
include '/plugins/' directory for script-src and blob for worker-src
Kyle Zhao962fbd1ec7a7
diff --git a/lib/content_security_policy.rb b/lib/content_security_policy.rbindex b30beec8690..85000825b39 100644--- a/lib/content_security_policy.rb+++ b/lib/content_security_policy.rb@@ -37,7 +37,7 @@ class ContentSecurityPolicy@request = request@directives = {script_src: script_src,- worker_src: [:self],+ worker_src: [:self, :blob],}@directives[:report_uri] = path('/csp_reports') if SiteSetting.content_security_policy_collect_reports@@ -68,6 +68,7 @@ class ContentSecurityPolicy['/extra-locales/', false, false],['/highlight-js/', false, true],['/javascripts/', false, true],+ ['/plugins/', false, true],['/theme-javascripts/', false, true],]diff --git a/spec/lib/content_security_policy_spec.rb b/spec/lib/content_security_policy_spec.rbindex a73082ac7df..af4311fa2dc 100644--- a/spec/lib/content_security_policy_spec.rb+++ b/spec/lib/content_security_policy_spec.rb@@ -13,8 +13,18 @@ describe ContentSecurityPolicy doendend- describe 'script-src defaults' do- it 'always have self, logster, sidekiq, and assets' do+ describe 'worker-src' do+ it 'always has self and blob' do+ worker_srcs = parse(ContentSecurityPolicy.new.build)['worker-src']+ expect(worker_srcs).to eq(%w[+ 'self'+ blob:+ ])+ end+ end++ describe 'script-src' do+ it 'always has self, logster, sidekiq, and assets' doscript_srcs = parse(ContentSecurityPolicy.new.build)['script-src']expect(script_srcs).to eq(%w['unsafe-eval'@@ -26,6 +36,7 @@ describe ContentSecurityPolicy dohttp://test.localhost/extra-locales/http://test.localhost/highlight-js/http://test.localhost/javascripts/+ http://test.localhost/plugins/http://test.localhost/theme-javascripts/])end@@ -48,6 +59,7 @@ describe ContentSecurityPolicy dohttps://cdn.com/brotli_asset/https://cdn.com/highlight-js/https://cdn.com/javascripts/+ https://cdn.com/plugins/https://cdn.com/theme-javascripts/http://test.localhost/extra-locales/])@@ -60,6 +72,7 @@ describe ContentSecurityPolicy dohttps://s3-cdn.com/brotli_asset/https://cdn.com/highlight-js/https://cdn.com/javascripts/+ https://cdn.com/plugins/https://cdn.com/theme-javascripts/http://test.localhost/extra-locales/])