Skip to content

Commit d41d3ba

Browse files
committed
more cleanup from stricter config settings
1 parent 07367a2 commit d41d3ba

File tree

5 files changed

+4
-6
lines changed

5 files changed

+4
-6
lines changed

lib/secure_headers/headers/content_security_policy.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module Constants
6868
).freeze
6969

7070
ALL_DIRECTIVES = [DIRECTIVES_1_0 + DIRECTIVES_2_0 + DIRECTIVES_3_0 + DIRECTIVES_DRAFT].flatten.sort.uniq
71+
ALL_CONFIGS = [:enforce, :app_name, :script_hash_middleware] + ALL_DIRECTIVES
7172
CONFIG_KEY = :csp
7273
end
7374

@@ -147,7 +148,7 @@ def initialize(config=nil, options={})
147148
# Config values can be string, array, or lamdba values
148149
@config = config.inject({}) do |hash, (key, value)|
149150
config_val = value.respond_to?(:call) ? value.call(@controller) : value
150-
if ([:enforce, :app_name] + ContentSecurityPolicy::ALL_DIRECTIVES).include?(key.to_sym) # directives need to be normalized to arrays of strings
151+
if ContentSecurityPolicy::ALL_CONFIGS.include?(key.to_sym) # directives need to be normalized to arrays of strings
151152
config_val = config_val.split if config_val.is_a? String
152153
if config_val.is_a?(Array)
153154
config_val = config_val.map do |val|

lib/secure_headers/view_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def hashed_javascript_tag(raise_error_on_unrecognized_hash = false, &block)
2727
if raise_error_on_unrecognized_hash
2828
raise UnexpectedHashedScriptException.new(message)
2929
else
30-
puts message
3130
request.env[HASHES_ENV_KEY] = (request.env[HASHES_ENV_KEY] || []) << hash_value
3231
end
3332
end

spec/lib/secure_headers/headers/content_security_policy/script_hash_middleware_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module SecureHeaders
1010

1111
let(:default_config) do
1212
{
13-
:disable_fill_missing => true,
1413
:default_src => 'https://*',
1514
:report_uri => '/csp_report',
1615
:script_src => "'unsafe-inline' 'unsafe-eval' https://* data:",

spec/lib/secure_headers/headers/content_security_policy_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def request_for user_agent, request_uri=nil, options={:ssl => false}
5959

6060
it "exports a policy to JSON" do
6161
policy = ContentSecurityPolicy.new(default_opts)
62-
puts default_opts
6362
expected = %({"default-src":["https:"],"img-src":["https:","data:"],"script-src":["'unsafe-inline'","'unsafe-eval'","https:","data:"],"style-src":["'unsafe-inline'","https:","about:"],"report-uri":["/csp_report"]})
6463
expect(policy.to_json).to eq(expected)
6564
end

spec/lib/secure_headers_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def expect_default_values(hash)
166166
end
167167

168168
it "produces a hash of headers given a hash as config" do
169-
hash = SecureHeaders::header_hash(:csp => {:default_src => "'none'", :img_src => "data:", :disable_fill_missing => true})
169+
hash = SecureHeaders::header_hash(:csp => {:default_src => "'none'", :img_src => "data:"})
170170
expect(hash['Content-Security-Policy-Report-Only']).to eq("default-src 'none'; img-src data:;")
171171
expect_default_values(hash)
172172
end
@@ -186,7 +186,7 @@ def expect_default_values(hash)
186186
}
187187
end
188188

189-
hash = SecureHeaders::header_hash(:csp => {:default_src => "'none'", :img_src => "data:", :disable_fill_missing => true})
189+
hash = SecureHeaders::header_hash(:csp => {:default_src => "'none'", :img_src => "data:"})
190190
::SecureHeaders::Configuration.configure do |config|
191191
config.hsts = nil
192192
config.hpkp = nil

0 commit comments

Comments
 (0)