Skip to content

Commit

Permalink
Fix CSP needlessly allowing blob URLs in script-src (mastodon#11620)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent d77a675 commit 2e5face
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def host_to_url(str)
webpacker_urls = %w(ws http).map { |protocol| "#{protocol}#{Webpacker.dev_server.https? ? 's' : ''}://#{Webpacker.dev_server.host_with_port}" }

p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url, *webpacker_urls
p.script_src :self, :blob, :unsafe_inline, :unsafe_eval, assets_host
p.script_src :self, :unsafe_inline, :unsafe_eval, assets_host
p.worker_src :self, :blob, assets_host
else
p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url
p.script_src :self, :blob, assets_host
p.script_src :self, assets_host
p.worker_src :self, :blob, assets_host
end
end

Expand Down

0 comments on commit 2e5face

Please sign in to comment.