secure_headers 5.0.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of secure_headers might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -4
- data/lib/secure_headers/headers/referrer_policy.rb +12 -5
- data/secure_headers.gemspec +1 -1
- data/spec/lib/secure_headers/headers/referrer_policy_spec.rb +19 -1
- metadata +2 -3
- data/docs/HPKP.md +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e421f2b5968b737c264d985109c40f477a84c44c
|
4
|
+
data.tar.gz: 7839fcc26e1db7ddda587f063a6f2f0db052ffa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd41e5df0da65b0f5304d58f73eec970315dd316598d7049fc59de87b16b97e281032c55df7b96490423e93bf24457e30b87196f2a000d127194a1c1878d4032
|
7
|
+
data.tar.gz: 4465312cd5cc22f2f74f77a4572c3585a9ecd1461ea2cfcbb3fd9dc1f506c06e22aff4efdd92b2eb8f90cd8c88b9eeacf34126c86444398f6d2ecfba04903e72
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,6 @@ The gem will automatically apply several headers that are related to security.
|
|
18
18
|
- X-Download-Options - [Prevent file downloads opening](https://msdn.microsoft.com/library/jj542450(v=vs.85).aspx)
|
19
19
|
- 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)
|
20
20
|
- Referrer-Policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/)
|
21
|
-
- 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)
|
22
21
|
- Expect-CT - Only use certificates that are present in the certificate transparency logs. [Expect-CT draft specification](https://datatracker.ietf.org/doc/draft-stark-expect-ct/).
|
23
22
|
- Clear-Site-Data - Clearing browser data for origin. [Clear-Site-Data specification](https://w3c.github.io/webappsec-clear-site-data/).
|
24
23
|
|
@@ -31,7 +30,6 @@ It can also mark all http cookies with the Secure, HttpOnly and SameSite attribu
|
|
31
30
|
- [Named overrides and appends](docs/named_overrides_and_appends.md)
|
32
31
|
- [Per action configuration](docs/per_action_configuration.md)
|
33
32
|
- [Cookies](docs/cookies.md)
|
34
|
-
- [HPKP](docs/HPKP.md)
|
35
33
|
- [Hashes](docs/hashes.md)
|
36
34
|
- [Sinatra Config](docs/sinatra.md)
|
37
35
|
|
@@ -67,13 +65,13 @@ SecureHeaders::Configuration.default do |config|
|
|
67
65
|
}
|
68
66
|
}
|
69
67
|
# Add "; preload" and submit the site to hstspreload.org for best protection.
|
70
|
-
config.hsts = "max-age=#{
|
68
|
+
config.hsts = "max-age=#{1.week.to_i}"
|
71
69
|
config.x_frame_options = "DENY"
|
72
70
|
config.x_content_type_options = "nosniff"
|
73
71
|
config.x_xss_protection = "1; mode=block"
|
74
72
|
config.x_download_options = "noopen"
|
75
73
|
config.x_permitted_cross_domain_policies = "none"
|
76
|
-
config.referrer_policy =
|
74
|
+
config.referrer_policy = %w(origin-when-cross-origin strict-origin-when-cross-origin)
|
77
75
|
config.csp = {
|
78
76
|
# "meta" values. these will shape the header, but the values are not included in the header.
|
79
77
|
preserve_schemes: true, # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
|
@@ -22,14 +22,21 @@ module SecureHeaders
|
|
22
22
|
# Returns a default header if no configuration is provided, or a
|
23
23
|
# header name and value based on the config.
|
24
24
|
def make_header(config = nil)
|
25
|
-
|
25
|
+
config ||= DEFAULT_VALUE
|
26
|
+
[HEADER_NAME, Array(config).join(", ")]
|
26
27
|
end
|
27
28
|
|
28
29
|
def validate_config!(config)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
case config
|
31
|
+
when nil, OPT_OUT
|
32
|
+
# valid
|
33
|
+
when String, Array
|
34
|
+
config = Array(config)
|
35
|
+
unless config.all? { |t| t.is_a?(String) && VALID_POLICIES.include?(t.downcase) }
|
36
|
+
raise ReferrerPolicyConfigError.new("Value can only be one or more of #{VALID_POLICIES.join(", ")}")
|
37
|
+
end
|
38
|
+
else
|
39
|
+
raise TypeError.new("Must be a string or array of strings. Found #{config.class}: #{config}")
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
data/secure_headers.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "secure_headers"
|
5
|
-
gem.version = "5.0.
|
5
|
+
gem.version = "5.0.2"
|
6
6
|
gem.authors = ["Neil Matatall"]
|
7
7
|
gem.email = ["neil.matatall@gmail.com"]
|
8
8
|
gem.description = "Manages application of security headers with many safe defaults."
|
@@ -5,6 +5,7 @@ module SecureHeaders
|
|
5
5
|
describe ReferrerPolicy do
|
6
6
|
specify { expect(ReferrerPolicy.make_header).to eq([ReferrerPolicy::HEADER_NAME, "origin-when-cross-origin"]) }
|
7
7
|
specify { expect(ReferrerPolicy.make_header("no-referrer")).to eq([ReferrerPolicy::HEADER_NAME, "no-referrer"]) }
|
8
|
+
specify { expect(ReferrerPolicy.make_header(%w(origin-when-cross-origin strict-origin-when-cross-origin))).to eq([ReferrerPolicy::HEADER_NAME, "origin-when-cross-origin, strict-origin-when-cross-origin"]) }
|
8
9
|
|
9
10
|
context "valid configuration values" do
|
10
11
|
it "accepts 'no-referrer'" do
|
@@ -60,14 +61,31 @@ module SecureHeaders
|
|
60
61
|
ReferrerPolicy.validate_config!(nil)
|
61
62
|
end.not_to raise_error
|
62
63
|
end
|
64
|
+
|
65
|
+
it "accepts array of policy values" do
|
66
|
+
expect do
|
67
|
+
ReferrerPolicy.validate_config!(
|
68
|
+
%w(
|
69
|
+
origin-when-cross-origin
|
70
|
+
strict-origin-when-cross-origin
|
71
|
+
)
|
72
|
+
)
|
73
|
+
end.not_to raise_error
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
|
-
context "
|
77
|
+
context "invalid configuration values" do
|
66
78
|
it "doesn't accept invalid values" do
|
67
79
|
expect do
|
68
80
|
ReferrerPolicy.validate_config!("open")
|
69
81
|
end.to raise_error(ReferrerPolicyConfigError)
|
70
82
|
end
|
83
|
+
|
84
|
+
it "doesn't accept invalid types" do
|
85
|
+
expect do
|
86
|
+
ReferrerPolicy.validate_config!({})
|
87
|
+
end.to raise_error(TypeError)
|
88
|
+
end
|
71
89
|
end
|
72
90
|
end
|
73
91
|
end
|
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: 5.0.
|
4
|
+
version: 5.0.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: 2017-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -61,7 +61,6 @@ files:
|
|
61
61
|
- LICENSE
|
62
62
|
- README.md
|
63
63
|
- Rakefile
|
64
|
-
- docs/HPKP.md
|
65
64
|
- docs/cookies.md
|
66
65
|
- docs/hashes.md
|
67
66
|
- docs/named_overrides_and_appends.md
|
data/docs/HPKP.md
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
## HTTP Public Key Pins
|
2
|
-
|
3
|
-
Be aware that pinning error reporting is governed by the same rules as everything else. If you have a pinning failure that tries to report back to the same origin, by definition this will not work.
|
4
|
-
|
5
|
-
```ruby
|
6
|
-
config.hpkp = {
|
7
|
-
max_age: 60.days.to_i, # max_age is a required parameter
|
8
|
-
include_subdomains: true, # whether or not to apply pins to subdomains
|
9
|
-
# Per the spec, SHA256 hashes are the only currently supported format.
|
10
|
-
pins: [
|
11
|
-
{sha256: 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'},
|
12
|
-
{sha256: '73a2c64f9545172c1195efb6616ca5f7afd1df6f245407cafb90de3998a1c97f'}
|
13
|
-
],
|
14
|
-
report_only: true, # defaults to false (report-only mode)
|
15
|
-
report_uri: 'https://report-uri.io/example-hpkp'
|
16
|
-
}
|
17
|
-
```
|