secure_headers 3.8.0 → 3.9.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
  SHA256:
3
- metadata.gz: d605beb08177e1325edd0726b0cb551d3ac71b6dc6da7c1261d6f30b60db7695
4
- data.tar.gz: f166e3735db90264366d654520269fb3cfb696ce9747c1ce92c11927d3322cb2
3
+ metadata.gz: 6e2f294d6c2130a1f629bf3dba2a88da71fa2b80a015cb7dc96bcbbcb88d1d59
4
+ data.tar.gz: 767021dbec7d023bbcb629b3315ad10ff989e2c6ae7ceff9ffc5614b05fa3ba5
5
5
  SHA512:
6
- metadata.gz: 784ea802225dbe362fa66d56022f13a1e8d58f71cac325959a7c28c4cb0f0acc25a478f794ef1286d3e951abb06f5c2fd25a3e448170643db6946c97027a3fe6
7
- data.tar.gz: 19abcb3f648b322ac8db0ca9352e53a758be5253d110e67224e8632366efde66a034f9777dc77946ef897dbc99e9dbf72edca743a1b184ca8b336c0a63296f7c
6
+ metadata.gz: 86d16e60409fca6b72e16321100a6afc3cc1fded1fb79c004778c8cdae2872ed4751205e90274f4b2c0517a70763c896692d9bd547f3b5b9144b8479b93268d5
7
+ data.tar.gz: a2462e058ad88292d40e5a7e4e23e0a5ba431a8a114616f1e1d77bd5218e99ed0b68f4e7b0cf9e3480e10ca2e34e97d60e3b7b1d77db8b71da71c031f4cdaa52
@@ -1,3 +1,7 @@
1
+ ## 3.9.0
2
+
3
+ Fixes newline injection issue
4
+
1
5
  ## 3.8.0
2
6
 
3
7
  Fixes semicolon injection issue reported by @mvgijssel see https://github.com/twitter/secure_headers/issues/418
@@ -144,10 +144,10 @@ module SecureHeaders
144
144
  return unless source_list && source_list.any?
145
145
  normalized_source_list = minify_source_list(directive, source_list).join(" ")
146
146
 
147
- if normalized_source_list.include?(";")
148
- Kernel.warn("#{directive} contains a ; in '#{normalized_source_list}' which will raise an error in future versions. It has been replaced with a blank space.")
147
+ if normalized_source_list =~ /(\n|;)/
148
+ Kernel.warn("#{directive} contains a #{$1} in #{normalized_source_list.inspect} which will raise an error in future versions. It has been replaced with a blank space.")
149
149
  end
150
- escaped_source_list = normalized_source_list.gsub(";", " ")
150
+ escaped_source_list = normalized_source_list.gsub(/[\n;]/, " ")
151
151
 
152
152
  [symbol_to_hyphen_case(directive), escaped_source_list].join(" ").strip
153
153
  end
@@ -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.8.0"
4
+ gem.version = "3.9.0"
5
5
  gem.authors = ["Neil Matatall"]
6
6
  gem.email = ["neil.matatall@gmail.com"]
7
7
  gem.description = 'Manages application of security headers with many safe defaults.'
@@ -28,10 +28,15 @@ module SecureHeaders
28
28
  end
29
29
 
30
30
  it "deprecates and escapes semicolons in directive source lists" do
31
- 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.")
31
+ 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
32
  expect(ContentSecurityPolicy.new(frame_ancestors: %w(https://google.com;script-src https://*;.;)).value).to eq("frame-ancestors google.com script-src * .")
33
33
  end
34
34
 
35
+ it "deprecates and escapes semicolons in directive source lists" do
36
+ 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.))
37
+ expect(ContentSecurityPolicy.new(frame_ancestors: ["\nfoo.com\nhacked"]).value).to eq("frame-ancestors foo.com hacked")
38
+ end
39
+
35
40
  it "discards 'none' values if any other source expressions are present" do
36
41
  csp = ContentSecurityPolicy.new(default_opts.merge(child_src: %w('self' 'none')))
37
42
  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: 3.8.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Matatall