secure_headers 6.3.1 → 6.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -1
- data/docs/upgrading-to-6-0.md +3 -3
- data/lib/secure_headers/headers/content_security_policy_config.rb +4 -0
- data/lib/secure_headers/headers/policy_management.rb +13 -1
- data/lib/secure_headers/version.rb +1 -1
- data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +20 -0
- data/spec/lib/secure_headers/headers/policy_management_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e68ad14ceec22ceeeabe2f49b47ad9325f43585cbb688f9f6ffe9c9f3536abc
|
4
|
+
data.tar.gz: ffab69d446b3935d4cf01ad21c660d8035ab8ecd4343d682841510509bb8b714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a79d8c96fd8d64eba216bd8785ae2deee7dceb7ef388f65e100f1597ed1f3005ecbeb069e823beef5fcdf89a6998ea296d954e3d80de0ba61456a13445b6e3
|
7
|
+
data.tar.gz: 645a0f3aac96761574b57e4464b08c83cbf6839fc4a0503e54dedd768aebdb503a080ee368753add3ab0c2a3eeb31bd4f866f0e39ed7691c17587ad7125299eb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -75,7 +75,11 @@ SecureHeaders::Configuration.default do |config|
|
|
75
75
|
sandbox: true, # true and [] will set a maximally restrictive setting
|
76
76
|
plugin_types: %w(application/x-shockwave-flash),
|
77
77
|
script_src: %w('self'),
|
78
|
+
script_src_elem: %w('self'),
|
79
|
+
script_src_attr: %w('self'),
|
78
80
|
style_src: %w('unsafe-inline'),
|
81
|
+
style_src_elem: %w('unsafe-inline'),
|
82
|
+
style_src_attr: %w('unsafe-inline'),
|
79
83
|
worker_src: %w('self'),
|
80
84
|
upgrade_insecure_requests: true, # see https://www.w3.org/TR/upgrade-insecure-requests/
|
81
85
|
report_uri: %w(https://report-uri.io/example-csp)
|
@@ -165,7 +169,6 @@ If you've made a contribution and see your name missing from the list, make a PR
|
|
165
169
|
* Rack [rack-secure_headers](https://github.com/frodsan/rack-secure_headers)
|
166
170
|
* Node.js (express) [helmet](https://github.com/helmetjs/helmet) and [hood](https://github.com/seanmonstar/hood)
|
167
171
|
* Node.js (hapi) [blankie](https://github.com/nlf/blankie)
|
168
|
-
* J2EE Servlet >= 3.0 [headlines](https://github.com/sourceclear/headlines)
|
169
172
|
* ASP.NET - [NWebsec](https://github.com/NWebsec/NWebsec/wiki)
|
170
173
|
* Python - [django-csp](https://github.com/mozilla/django-csp) + [commonware](https://github.com/jsocol/commonware/); [django-security](https://github.com/sdelements/django-security)
|
171
174
|
* Go - [secureheader](https://github.com/kr/secureheader)
|
data/docs/upgrading-to-6-0.md
CHANGED
@@ -29,7 +29,7 @@ Prior to 6.0.0, the response would NOT include a `X-Frame-Options` header since
|
|
29
29
|
|
30
30
|
## `ContentSecurityPolicyConfig#merge` and `ContentSecurityPolicyReportOnlyConfig#merge` work more like `Hash#merge`
|
31
31
|
|
32
|
-
These classes are typically not directly instantiated by users of SecureHeaders. But, if you access `config.csp` you end up accessing one of these objects. Prior to 6.0.0, `#merge` worked more like `#append` in that it would combine policies (i.e. if both policies contained the same key the values would be combined rather than overwritten). This was not consistent with `#merge!`, which worked more like
|
32
|
+
These classes are typically not directly instantiated by users of SecureHeaders. But, if you access `config.csp` you end up accessing one of these objects. Prior to 6.0.0, `#merge` worked more like `#append` in that it would combine policies (i.e. if both policies contained the same key the values would be combined rather than overwritten). This was not consistent with `#merge!`, which worked more like Ruby's `Hash#merge!` (overwriting duplicate keys). As of 6.0.0, `#merge` works the same as `#merge!`, but returns a new object instead of mutating `self`.
|
33
33
|
|
34
34
|
## `Configuration#get` has been removed
|
35
35
|
|
@@ -39,7 +39,7 @@ This method is not typically directly called by users of SecureHeaders. Given th
|
|
39
39
|
|
40
40
|
Prior to 6.0.0 SecureHeaders pre-built and cached the headers that corresponded to the default configuration. The same was also done for named overrides. However, now that named overrides are applied dynamically, those can no longer be cached. As a result, caching has been removed in the name of simplicity. Some micro-benchmarks indicate this shouldn't be a performance problem and will help to eliminate a class of bugs entirely.
|
41
41
|
|
42
|
-
##
|
42
|
+
## Calling the default configuration more than once will result in an Exception
|
43
43
|
|
44
44
|
Prior to 6.0.0 you could conceivably, though unlikely, have `Configure#default` called more than once. Because configurations are dynamic, configuring more than once could result in unexpected behavior. So, as of 6.0.0 we raise `AlreadyConfiguredError` if the default configuration is setup more than once.
|
45
45
|
|
@@ -47,4 +47,4 @@ Prior to 6.0.0 you could conceivably, though unlikely, have `Configure#default`
|
|
47
47
|
|
48
48
|
The policy configured is the policy that is delivered in terms of which directives are sent. We still dedup, strip schemes, and look for other optimizations but we will not e.g. conditionally send `frame-src` / `child-src` or apply `nonce`s / `unsafe-inline`.
|
49
49
|
|
50
|
-
The primary reason for these per-browser customization was to reduce console warnings. This has lead to many bugs and results
|
50
|
+
The primary reason for these per-browser customization was to reduce console warnings. This has lead to many bugs and results in confusing behavior. Also, console logs are incredibly noisy today and increasingly warn you about perfectly valid things (like sending `X-Frame-Options` and `frame-ancestors` together).
|
@@ -38,8 +38,12 @@ module SecureHeaders
|
|
38
38
|
@sandbox = nil
|
39
39
|
@script_nonce = nil
|
40
40
|
@script_src = nil
|
41
|
+
@script_src_elem = nil
|
42
|
+
@script_src_attr = nil
|
41
43
|
@style_nonce = nil
|
42
44
|
@style_src = nil
|
45
|
+
@style_src_elem = nil
|
46
|
+
@style_src_attr = nil
|
43
47
|
@worker_src = nil
|
44
48
|
@upgrade_insecure_requests = nil
|
45
49
|
@disable_nonce_backwards_compatibility = nil
|
@@ -78,6 +78,10 @@ module SecureHeaders
|
|
78
78
|
REQUIRE_SRI_FOR = :require_sri_for
|
79
79
|
UPGRADE_INSECURE_REQUESTS = :upgrade_insecure_requests
|
80
80
|
WORKER_SRC = :worker_src
|
81
|
+
SCRIPT_SRC_ELEM = :script_src_elem
|
82
|
+
SCRIPT_SRC_ATTR = :script_src_attr
|
83
|
+
STYLE_SRC_ELEM = :style_src_elem
|
84
|
+
STYLE_SRC_ATTR = :style_src_attr
|
81
85
|
|
82
86
|
DIRECTIVES_3_0 = [
|
83
87
|
DIRECTIVES_2_0,
|
@@ -87,7 +91,11 @@ module SecureHeaders
|
|
87
91
|
PREFETCH_SRC,
|
88
92
|
REQUIRE_SRI_FOR,
|
89
93
|
WORKER_SRC,
|
90
|
-
UPGRADE_INSECURE_REQUESTS
|
94
|
+
UPGRADE_INSECURE_REQUESTS,
|
95
|
+
SCRIPT_SRC_ELEM,
|
96
|
+
SCRIPT_SRC_ATTR,
|
97
|
+
STYLE_SRC_ELEM,
|
98
|
+
STYLE_SRC_ATTR
|
91
99
|
].flatten.freeze
|
92
100
|
|
93
101
|
ALL_DIRECTIVES = (DIRECTIVES_1_0 + DIRECTIVES_2_0 + DIRECTIVES_3_0).uniq.sort
|
@@ -117,7 +125,11 @@ module SecureHeaders
|
|
117
125
|
PREFETCH_SRC => :source_list,
|
118
126
|
SANDBOX => :sandbox_list,
|
119
127
|
SCRIPT_SRC => :source_list,
|
128
|
+
SCRIPT_SRC_ELEM => :source_list,
|
129
|
+
SCRIPT_SRC_ATTR => :source_list,
|
120
130
|
STYLE_SRC => :source_list,
|
131
|
+
STYLE_SRC_ELEM => :source_list,
|
132
|
+
STYLE_SRC_ATTR => :source_list,
|
121
133
|
WORKER_SRC => :source_list,
|
122
134
|
UPGRADE_INSECURE_REQUESTS => :boolean,
|
123
135
|
}.freeze
|
@@ -160,6 +160,26 @@ module SecureHeaders
|
|
160
160
|
csp = ContentSecurityPolicy.new({default_src: %w('self'), script_src: [ContentSecurityPolicy::STRICT_DYNAMIC], script_nonce: 123456, disable_nonce_backwards_compatibility: true })
|
161
161
|
expect(csp.value).to eq("default-src 'self'; script-src 'strict-dynamic' 'nonce-123456'")
|
162
162
|
end
|
163
|
+
|
164
|
+
it "supports script-src-elem directive" do
|
165
|
+
csp = ContentSecurityPolicy.new({script_src: %w('self'), script_src_elem: %w('self')})
|
166
|
+
expect(csp.value).to eq("script-src 'self'; script-src-elem 'self'")
|
167
|
+
end
|
168
|
+
|
169
|
+
it "supports script-src-attr directive" do
|
170
|
+
csp = ContentSecurityPolicy.new({script_src: %w('self'), script_src_attr: %w('self')})
|
171
|
+
expect(csp.value).to eq("script-src 'self'; script-src-attr 'self'")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "supports style-src-elem directive" do
|
175
|
+
csp = ContentSecurityPolicy.new({style_src: %w('self'), style_src_elem: %w('self')})
|
176
|
+
expect(csp.value).to eq("style-src 'self'; style-src-elem 'self'")
|
177
|
+
end
|
178
|
+
|
179
|
+
it "supports style-src-attr directive" do
|
180
|
+
csp = ContentSecurityPolicy.new({style_src: %w('self'), style_src_attr: %w('self')})
|
181
|
+
expect(csp.value).to eq("style-src 'self'; style-src-attr 'self'")
|
182
|
+
end
|
163
183
|
end
|
164
184
|
end
|
165
185
|
end
|
@@ -49,6 +49,10 @@ module SecureHeaders
|
|
49
49
|
style_src: %w('unsafe-inline'),
|
50
50
|
upgrade_insecure_requests: true, # see https://www.w3.org/TR/upgrade-insecure-requests/
|
51
51
|
worker_src: %w(worker.com),
|
52
|
+
script_src_elem: %w(example.com),
|
53
|
+
script_src_attr: %w(example.com),
|
54
|
+
style_src_elem: %w(example.com),
|
55
|
+
style_src_attr: %w(example.com),
|
52
56
|
|
53
57
|
report_uri: %w(https://example.com/uri-directive),
|
54
58
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secure_headers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.3.
|
4
|
+
version: 6.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Matatall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|