Skip to content

Commit ff9797f

Browse files
authored
deprecate block-all-mixed-content (#509)
1 parent accd05c commit ff9797f

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ SecureHeaders::Configuration.default do |config|
6262
# directive values: these values will directly translate into source directives
6363
default_src: %w('none'),
6464
base_uri: %w('self'),
65-
block_all_mixed_content: true, # see https://www.w3.org/TR/mixed-content/
6665
child_src: %w('self'), # if child-src isn't supported, the value for frame-src will be set.
6766
connect_src: %w(wss:),
6867
font_src: %w('self' data:),
@@ -92,6 +91,9 @@ SecureHeaders::Configuration.default do |config|
9291
end
9392
```
9493

94+
### Deprecated Configuration Values
95+
* `block_all_mixed_content` - this value is deprecated in favor of `upgrade_insecure_requests`. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content for more information.
96+
9597
## Default values
9698

9799
All headers except for PublicKeyPins and ClearSiteData have a default value. The default set of headers is:

lib/secure_headers/headers/content_security_policy_config.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def self.included(base)
1616

1717
def initialize(hash)
1818
@base_uri = nil
19-
@block_all_mixed_content = nil
2019
@child_src = nil
2120
@connect_src = nil
2221
@default_src = nil

lib/secure_headers/headers/policy_management.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def self.included(base)
7171

7272
# All the directives currently under consideration for CSP level 3.
7373
# https://w3c.github.io/webappsec/specs/CSP2/
74-
BLOCK_ALL_MIXED_CONTENT = :block_all_mixed_content
7574
MANIFEST_SRC = :manifest_src
7675
NAVIGATE_TO = :navigate_to
7776
PREFETCH_SRC = :prefetch_src
@@ -85,7 +84,6 @@ def self.included(base)
8584

8685
DIRECTIVES_3_0 = [
8786
DIRECTIVES_2_0,
88-
BLOCK_ALL_MIXED_CONTENT,
8987
MANIFEST_SRC,
9088
NAVIGATE_TO,
9189
PREFETCH_SRC,
@@ -118,7 +116,6 @@ def self.included(base)
118116

119117
DIRECTIVE_VALUE_TYPES = {
120118
BASE_URI => :source_list,
121-
BLOCK_ALL_MIXED_CONTENT => :boolean,
122119
CHILD_SRC => :source_list,
123120
CONNECT_SRC => :source_list,
124121
DEFAULT_SRC => :source_list,
@@ -241,7 +238,7 @@ def validate_config!(config)
241238
#
242239
# raises an error if the original config is OPT_OUT
243240
#
244-
# 1. for non-source-list values (report_only, block_all_mixed_content, upgrade_insecure_requests),
241+
# 1. for non-source-list values (report_only, upgrade_insecure_requests),
245242
# additions will overwrite the original value.
246243
# 2. if a value in additions does not exist in the original config, the
247244
# default-src value is included to match original behavior.

spec/lib/secure_headers/headers/content_security_policy_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ module SecureHeaders
9292
end
9393

9494
it "does add a boolean directive if the value is true" do
95-
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], block_all_mixed_content: true, upgrade_insecure_requests: true)
96-
expect(csp.value).to eq("default-src example.org; block-all-mixed-content; upgrade-insecure-requests")
95+
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], upgrade_insecure_requests: true)
96+
expect(csp.value).to eq("default-src example.org; upgrade-insecure-requests")
9797
end
9898

9999
it "does not add a boolean directive if the value is false" do
100-
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], block_all_mixed_content: true, upgrade_insecure_requests: false)
101-
expect(csp.value).to eq("default-src example.org; block-all-mixed-content")
100+
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], upgrade_insecure_requests: false)
101+
expect(csp.value).to eq("default-src example.org")
102102
end
103103

104104
it "handles wildcard subdomain with wildcard port" do

spec/lib/secure_headers/headers/policy_management_spec.rb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ module SecureHeaders
3030
default_src: %w(https: 'self'),
3131

3232
base_uri: %w('self'),
33-
block_all_mixed_content: true, # see [http://www.w3.org/TR/mixed-content/](http://www.w3.org/TR/mixed-content/)
3433
connect_src: %w(wss:),
3534
child_src: %w('self' *.twimg.com itunes.apple.com),
3635
font_src: %w('self' data:),
@@ -92,12 +91,6 @@ module SecureHeaders
9291
end.to raise_error(ContentSecurityPolicyConfigError)
9392
end
9493

95-
it "requires :block_all_mixed_content to be a boolean value" do
96-
expect do
97-
ContentSecurityPolicy.validate_config!(ContentSecurityPolicyConfig.new(default_opts.merge(block_all_mixed_content: "steve")))
98-
end.to raise_error(ContentSecurityPolicyConfigError)
99-
end
100-
10194
it "requires :upgrade_insecure_requests to be a boolean value" do
10295
expect do
10396
ContentSecurityPolicy.validate_config!(ContentSecurityPolicyConfig.new(default_opts.merge(upgrade_insecure_requests: "steve")))
@@ -244,18 +237,18 @@ module SecureHeaders
244237
expect(csp.name).to eq(ContentSecurityPolicyReportOnlyConfig::HEADER_NAME)
245238
end
246239

247-
it "overrides the :block_all_mixed_content flag" do
240+
it "overrides the :upgrade_insecure_requests flag" do
248241
Configuration.default do |config|
249242
config.csp = {
250243
default_src: %w(https:),
251244
script_src: %w('self'),
252-
block_all_mixed_content: false
245+
upgrade_insecure_requests: false
253246
}
254247
end
255248
default_policy = Configuration.dup
256-
combined_config = ContentSecurityPolicy.combine_policies(default_policy.csp.to_h, block_all_mixed_content: true)
249+
combined_config = ContentSecurityPolicy.combine_policies(default_policy.csp.to_h, upgrade_insecure_requests: true)
257250
csp = ContentSecurityPolicy.new(combined_config)
258-
expect(csp.value).to eq("default-src https:; block-all-mixed-content; script-src 'self'")
251+
expect(csp.value).to eq("default-src https:; script-src 'self'; upgrade-insecure-requests")
259252
end
260253

261254
it "raises an error if appending to a OPT_OUT policy" do

0 commit comments

Comments
 (0)