secure_headers 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32ea96aca183a8341bec40b998486beed14d59e8
4
- data.tar.gz: 3081354f4bd486f5ea49d22f680d1ac2d36de4aa
3
+ metadata.gz: 1b901bf6e9f4127c81ec207e46599054feb18f32
4
+ data.tar.gz: 642585cfc04901c83ff5d90ea1600f5ef141fec4
5
5
  SHA512:
6
- metadata.gz: cc8c64abdabaab458be788ee09a18984bab17cb8a01ef6eb76c75099cfaa5b8fc5962f5094e39f7067ebece388794e7f53a2e44f2fecdbfe4146a59a981211df
7
- data.tar.gz: f8c369a5a2ac0e7547e231100c2a946a9204684d4db33206cc3baf0dd786b99c5a6d05cdaaaca5fcb439530a6d385d029c265dbc84f9b6ff665df52ad1191537
6
+ metadata.gz: 8e304a7d52e6dbf0a4fd2bb114201ba781e8565fd9ecbd4977e6169f922101f186c7024194c81ecd780376f2e4c18f7af3bd88f98cd2b86301b15de5e4148c44
7
+ data.tar.gz: 9d5e1e8f35954baea9e4fcec70af22e7f3c2d8b16deaa98d6c882c9373c9a76556a711696b081920d9279df96375dd6e2a473e265c9bfbf2e12a6f9a62da486f
@@ -1,3 +1,7 @@
1
+ ## 5.2.0
2
+
3
+ Fixes newline injection issue
4
+
1
5
  ## 5.1.0
2
6
 
3
7
  Fixes semicolon injection issue reported by @mvgijssel see https://github.com/twitter/secure_headers/issues/418
@@ -140,11 +140,11 @@ module SecureHeaders
140
140
  if source_list != OPT_OUT && source_list && source_list.any?
141
141
  minified_source_list = minify_source_list(directive, source_list).join(" ")
142
142
 
143
- if minified_source_list.include?(";")
144
- Kernel.warn("#{directive} contains a ; in '#{minified_source_list}' which will raise an error in future versions. It has been replaced with a blank space.")
143
+ if minified_source_list =~ /(\n|;)/
144
+ Kernel.warn("#{directive} contains a #{$1} in #{minified_source_list.inspect} which will raise an error in future versions. It has been replaced with a blank space.")
145
145
  end
146
146
 
147
- escaped_source_list = minified_source_list.gsub(";", " ")
147
+ escaped_source_list = minified_source_list.gsub(/[\n;]/, " ")
148
148
  [symbol_to_hyphen_case(directive), escaped_source_list].join(" ").strip
149
149
  end
150
150
  end
@@ -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.1.0"
5
+ gem.version = "5.2.0"
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."
@@ -29,10 +29,15 @@ module SecureHeaders
29
29
  end
30
30
 
31
31
  it "deprecates and escapes semicolons in directive source lists" do
32
- expect(Kernel).to receive(:warn).with("frame_ancestors contains a ; in 'google.com;script-src *;.;' which will raise an error in future versions. It has been replaced with a blank space.")
32
+ expect(Kernel).to receive(:warn).with(%(frame_ancestors contains a ; in "google.com;script-src *;.;" which will raise an error in future versions. It has been replaced with a blank space.))
33
33
  expect(ContentSecurityPolicy.new(frame_ancestors: %w(https://google.com;script-src https://*;.;)).value).to eq("frame-ancestors google.com script-src * .")
34
34
  end
35
35
 
36
+ it "deprecates and escapes semicolons in directive source lists" do
37
+ expect(Kernel).to receive(:warn).with(%(frame_ancestors contains a \n in "\\nfoo.com\\nhacked" which will raise an error in future versions. It has been replaced with a blank space.))
38
+ expect(ContentSecurityPolicy.new(frame_ancestors: ["\nfoo.com\nhacked"]).value).to eq("frame-ancestors foo.com hacked")
39
+ end
40
+
36
41
  it "discards 'none' values if any other source expressions are present" do
37
42
  csp = ContentSecurityPolicy.new(default_opts.merge(child_src: %w('self' 'none')))
38
43
  expect(csp.value).not_to include("'none'")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Matatall