mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 12:11:12 +08:00
FEATURE: set CSP base-uri and object-src to none (#6863)
This commit is contained in:
@ -7,6 +7,8 @@ class ContentSecurityPolicy
|
||||
|
||||
def initialize
|
||||
@directives = {}.tap do |directives|
|
||||
directives[:base_uri] = [:none]
|
||||
directives[:object_src] = [:none]
|
||||
directives[:script_src] = script_src
|
||||
directives[:worker_src] = worker_src
|
||||
directives[:report_uri] = report_uri if SiteSetting.content_security_policy_collect_reports
|
||||
|
@ -16,6 +16,20 @@ describe ContentSecurityPolicy do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'base-uri' do
|
||||
it 'is set to none' do
|
||||
base_uri = parse(policy)['base-uri']
|
||||
expect(base_uri).to eq(["'none'"])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'object-src' do
|
||||
it 'is set to none' do
|
||||
object_srcs = parse(policy)['object-src']
|
||||
expect(object_srcs).to eq(["'none'"])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'worker-src' do
|
||||
it 'always has self and blob' do
|
||||
worker_srcs = parse(policy)['worker-src']
|
||||
|
Reference in New Issue
Block a user