secure_headers 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +3 -0
- data/lib/secure_headers/configuration.rb +9 -0
- data/lib/secure_headers/headers/policy_management.rb +1 -0
- data/secure_headers.gemspec +1 -1
- data/spec/lib/secure_headers/configuration_spec.rb +8 -0
- data/spec/lib/secure_headers_spec.rb +19 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ebe74bc751469bb4305dd36b59fe4881a87ec3d
|
|
4
|
+
data.tar.gz: 83fed6de7e4cab010cab6010caa0ba005ac43fc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd02880ba737a5a9489dd6e8209420259fec8d78330f5992e7b34f61ebe16677a93ff123dd3b417f6973bfcd85e03524b053bcd1487458492aa4c7b8a7a9bb40
|
|
7
|
+
data.tar.gz: 550c48cfd47e656e70dd3ab39ed6386b8d148231d55a553395da6076bc88bdaaa7fe1803695b093cf3e4fd49cb30bed0aff15a2455652efd00d7a27d9ce55636
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 3.1.2 Bug fix for regression
|
|
2
|
+
|
|
3
|
+
See https://github.com/twitter/secureheaders/pull/239
|
|
4
|
+
|
|
5
|
+
This meant that when header caches were regenerated upon calling `SecureHeaders.override(:name)` and using it with `use_secure_headers_override` would result in default values for anything other than CSP/HPKP.
|
|
6
|
+
|
|
7
|
+
## 3.1.1 Bug fix for regression
|
|
8
|
+
|
|
9
|
+
See https://github.com/twitter/secureheaders/pull/235
|
|
10
|
+
|
|
11
|
+
`idempotent_additions?` would return false when comparing `OPT_OUT` with `OPT_OUT`, causing `header_hash_for` to return a header cache with `{ nil => nil }` which cause the middleware to blow up when `{ nil => nil }` was merged into the rack header hash.
|
|
12
|
+
|
|
13
|
+
This is a regression in 3.1.0 only.
|
|
14
|
+
|
|
15
|
+
Now it returns true. I've added a test case to ensure that `header_hash_for` will never return such an element.
|
|
16
|
+
|
|
1
17
|
## 3.1.0 Adding secure cookie support
|
|
2
18
|
|
|
3
19
|
New feature: marking all cookies as secure. Added by @jmera in https://github.com/twitter/secureheaders/pull/231. In the future, we'll probably add the ability to whitelist individual cookies that should not be marked secure. PRs welcome.
|
data/README.md
CHANGED
|
@@ -15,6 +15,8 @@ The gem will automatically apply several headers that are related to security.
|
|
|
15
15
|
- X-Permitted-Cross-Domain-Policies - [Restrict Adobe Flash Player's access to data](https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html)
|
|
16
16
|
- Public Key Pinning - Pin certificate fingerprints in the browser to prevent man-in-the-middle attacks due to compromised Certificate Authorities. [Public Key Pinning Specification](https://tools.ietf.org/html/rfc7469)
|
|
17
17
|
|
|
18
|
+
It can also mark all http cookies with the secure attribute (when configured to do so).
|
|
19
|
+
|
|
18
20
|
`secure_headers` is a library with a global config, per request overrides, and rack middleware that enables you customize your application settings.
|
|
19
21
|
|
|
20
22
|
## Use
|
|
@@ -29,6 +31,7 @@ All `nil` values will fallback to their default values. `SecureHeaders::OPT_OUT`
|
|
|
29
31
|
|
|
30
32
|
```ruby
|
|
31
33
|
SecureHeaders::Configuration.default do |config|
|
|
34
|
+
config.secure_cookies = true # mark all cookies as "secure"
|
|
32
35
|
config.hsts = "max-age=#{20.years.to_i}; includeSubdomains; preload"
|
|
33
36
|
config.x_frame_options = "DENY"
|
|
34
37
|
config.x_content_type_options = "nosniff"
|
|
@@ -71,6 +71,7 @@ module SecureHeaders
|
|
|
71
71
|
ALL_HEADER_CLASSES.each do |klass|
|
|
72
72
|
config.send("#{klass::CONFIG_KEY}=", OPT_OUT)
|
|
73
73
|
end
|
|
74
|
+
config.dynamic_csp = OPT_OUT
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
add_configuration(NOOP_CONFIGURATION, noop_config)
|
|
@@ -120,6 +121,13 @@ module SecureHeaders
|
|
|
120
121
|
copy.csp = self.class.send(:deep_copy_if_hash, @csp)
|
|
121
122
|
copy.dynamic_csp = self.class.send(:deep_copy_if_hash, @dynamic_csp)
|
|
122
123
|
copy.cached_headers = self.class.send(:deep_copy_if_hash, @cached_headers)
|
|
124
|
+
copy.x_content_type_options = @x_content_type_options
|
|
125
|
+
copy.hsts = @hsts
|
|
126
|
+
copy.x_frame_options = @x_frame_options
|
|
127
|
+
copy.x_xss_protection = @x_xss_protection
|
|
128
|
+
copy.x_download_options = @x_download_options
|
|
129
|
+
copy.x_permitted_cross_domain_policies = @x_permitted_cross_domain_policies
|
|
130
|
+
copy.hpkp = @hpkp
|
|
123
131
|
copy
|
|
124
132
|
end
|
|
125
133
|
|
|
@@ -132,6 +140,7 @@ module SecureHeaders
|
|
|
132
140
|
end
|
|
133
141
|
|
|
134
142
|
def update_x_frame_options(value)
|
|
143
|
+
@x_frame_options = value
|
|
135
144
|
self.cached_headers[XFrameOptions::CONFIG_KEY] = XFrameOptions.make_header(value)
|
|
136
145
|
end
|
|
137
146
|
|
|
@@ -196,6 +196,7 @@ module SecureHeaders
|
|
|
196
196
|
# additions = { script_src: %w(google.com)} then idempotent_additions? would return
|
|
197
197
|
# because google.com is already in the config.
|
|
198
198
|
def idempotent_additions?(config, additions)
|
|
199
|
+
return true if config == OPT_OUT && additions == OPT_OUT
|
|
199
200
|
return false if config == OPT_OUT
|
|
200
201
|
config == combine_policies(config, additions)
|
|
201
202
|
end
|
data/secure_headers.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
Gem::Specification.new do |gem|
|
|
3
3
|
gem.name = "secure_headers"
|
|
4
|
-
gem.version = "3.1.
|
|
4
|
+
gem.version = "3.1.2"
|
|
5
5
|
gem.authors = ["Neil Matatall"]
|
|
6
6
|
gem.email = ["neil.matatall@gmail.com"]
|
|
7
7
|
gem.description = 'Security related headers all in one gem.'
|
|
@@ -41,6 +41,14 @@ module SecureHeaders
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
it "regenerates cached headers when building an override" do
|
|
45
|
+
Configuration.override(:test_override) do |config|
|
|
46
|
+
config.x_content_type_options = OPT_OUT
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
expect(Configuration.get.cached_headers).to_not eq(Configuration.get(:test_override).cached_headers)
|
|
50
|
+
end
|
|
51
|
+
|
|
44
52
|
it "stores an override of the global config" do
|
|
45
53
|
Configuration.override(:test_override) do |config|
|
|
46
54
|
config.x_frame_options = "DENY"
|
|
@@ -21,7 +21,7 @@ module SecureHeaders
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
describe "#header_hash_for" do
|
|
24
|
-
it "allows you to opt out of individual headers" do
|
|
24
|
+
it "allows you to opt out of individual headers via API" do
|
|
25
25
|
Configuration.default
|
|
26
26
|
SecureHeaders.opt_out_of_header(request, CSP::CONFIG_KEY)
|
|
27
27
|
SecureHeaders.opt_out_of_header(request, XContentTypeOptions::CONFIG_KEY)
|
|
@@ -31,6 +31,23 @@ module SecureHeaders
|
|
|
31
31
|
expect(hash['X-Content-Type-Options']).to be_nil
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
it "Carries options over when using overrides" do
|
|
35
|
+
Configuration.default do |config|
|
|
36
|
+
config.x_download_options = OPT_OUT
|
|
37
|
+
config.x_permitted_cross_domain_policies = OPT_OUT
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Configuration.override(:api) do |config|
|
|
41
|
+
config.x_frame_options = OPT_OUT
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
SecureHeaders.use_secure_headers_override(request, :api)
|
|
45
|
+
hash = SecureHeaders.header_hash_for(request)
|
|
46
|
+
expect(hash['X-Download-Options']).to be_nil
|
|
47
|
+
expect(hash['X-Permitted-Cross-Domain-Policies']).to be_nil
|
|
48
|
+
expect(hash['X-Frame-Options']).to be_nil
|
|
49
|
+
end
|
|
50
|
+
|
|
34
51
|
it "allows you to opt out entirely" do
|
|
35
52
|
Configuration.default
|
|
36
53
|
SecureHeaders.opt_out_of_all_protection(request)
|
|
@@ -38,6 +55,7 @@ module SecureHeaders
|
|
|
38
55
|
ALL_HEADER_CLASSES.each do |klass|
|
|
39
56
|
expect(hash[klass::CONFIG_KEY]).to be_nil
|
|
40
57
|
end
|
|
58
|
+
expect(hash.count).to eq(0)
|
|
41
59
|
end
|
|
42
60
|
|
|
43
61
|
it "allows you to override X-Frame-Options settings" do
|
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: 3.1.
|
|
4
|
+
version: 3.1.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: 2016-03-
|
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|