secure_headers 1.3.2 → 2.0.0

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.
Files changed (116) hide show
  1. data/.gitignore +4 -8
  2. data/.travis.yml +7 -4
  3. data/Gemfile +6 -7
  4. data/README.md +117 -81
  5. data/Rakefile +11 -116
  6. data/fixtures/rails_3_2_12/Gemfile +0 -6
  7. data/fixtures/rails_3_2_12/app/controllers/things_controller.rb +0 -1
  8. data/fixtures/rails_3_2_12/app/views/layouts/application.html.erb +1 -4
  9. data/fixtures/rails_3_2_12/app/views/other_things/index.html.erb +2 -1
  10. data/fixtures/rails_3_2_12/app/views/things/index.html.erb +1 -21
  11. data/fixtures/rails_3_2_12/config/application.rb +0 -54
  12. data/fixtures/rails_3_2_12/config/environments/test.rb +2 -2
  13. data/fixtures/rails_3_2_12/config/initializers/secure_headers.rb +2 -1
  14. data/fixtures/rails_3_2_12/config/routes.rb +0 -57
  15. data/fixtures/rails_3_2_12/config/script_hashes.yml +5 -0
  16. data/fixtures/rails_3_2_12/config.ru +3 -0
  17. data/fixtures/rails_3_2_12/spec/controllers/other_things_controller_spec.rb +58 -16
  18. data/fixtures/rails_3_2_12/spec/controllers/things_controller_spec.rb +11 -1
  19. data/fixtures/rails_3_2_12_no_init/Gemfile +0 -7
  20. data/fixtures/rails_3_2_12_no_init/app/controllers/other_things_controller.rb +1 -2
  21. data/fixtures/rails_3_2_12_no_init/app/controllers/things_controller.rb +1 -1
  22. data/fixtures/rails_3_2_12_no_init/app/views/layouts/application.html.erb +0 -2
  23. data/fixtures/rails_3_2_12_no_init/app/views/things/index.html.erb +0 -21
  24. data/fixtures/rails_3_2_12_no_init/config/application.rb +0 -51
  25. data/fixtures/rails_3_2_12_no_init/config/environments/test.rb +2 -2
  26. data/fixtures/rails_3_2_12_no_init/config/routes.rb +0 -57
  27. data/fixtures/rails_3_2_12_no_init/spec/controllers/other_things_controller_spec.rb +10 -0
  28. data/fixtures/rails_3_2_12_no_init/spec/controllers/things_controller_spec.rb +10 -0
  29. data/fixtures/rails_4_1_8/Gemfile +5 -0
  30. data/fixtures/rails_4_1_8/README.rdoc +28 -0
  31. data/fixtures/rails_4_1_8/Rakefile +6 -0
  32. data/fixtures/rails_4_1_8/app/controllers/application_controller.rb +4 -0
  33. data/fixtures/rails_4_1_8/app/controllers/concerns/.keep +0 -0
  34. data/fixtures/rails_4_1_8/app/controllers/other_things_controller.rb +5 -0
  35. data/fixtures/rails_4_1_8/app/controllers/things_controller.rb +5 -0
  36. data/fixtures/rails_4_1_8/app/models/.keep +0 -0
  37. data/fixtures/rails_4_1_8/app/models/concerns/.keep +0 -0
  38. data/fixtures/rails_4_1_8/app/views/layouts/application.html.erb +11 -0
  39. data/fixtures/rails_4_1_8/app/views/other_things/index.html.erb +2 -0
  40. data/fixtures/rails_4_1_8/app/views/things/index.html.erb +1 -0
  41. data/fixtures/rails_4_1_8/config/application.rb +15 -0
  42. data/fixtures/rails_4_1_8/config/boot.rb +4 -0
  43. data/fixtures/rails_4_1_8/config/environment.rb +5 -0
  44. data/fixtures/rails_4_1_8/config/environments/test.rb +10 -0
  45. data/fixtures/rails_4_1_8/config/initializers/secure_headers.rb +17 -0
  46. data/fixtures/rails_4_1_8/config/routes.rb +4 -0
  47. data/fixtures/rails_4_1_8/config/script_hashes.yml +5 -0
  48. data/fixtures/rails_4_1_8/config/secrets.yml +22 -0
  49. data/fixtures/rails_4_1_8/config.ru +4 -0
  50. data/fixtures/rails_4_1_8/lib/assets/.keep +0 -0
  51. data/fixtures/rails_4_1_8/lib/tasks/.keep +0 -0
  52. data/fixtures/rails_4_1_8/log/.keep +0 -0
  53. data/fixtures/rails_4_1_8/spec/controllers/other_things_controller_spec.rb +83 -0
  54. data/fixtures/rails_4_1_8/spec/controllers/things_controller_spec.rb +59 -0
  55. data/fixtures/rails_4_1_8/spec/spec_helper.rb +15 -0
  56. data/fixtures/rails_4_1_8/vendor/assets/javascripts/.keep +0 -0
  57. data/fixtures/rails_4_1_8/vendor/assets/stylesheets/.keep +0 -0
  58. data/lib/secure_headers/hash_helper.rb +7 -0
  59. data/lib/secure_headers/headers/content_security_policy/script_hash_middleware.rb +22 -0
  60. data/lib/secure_headers/headers/content_security_policy.rb +141 -133
  61. data/lib/secure_headers/headers/strict_transport_security.rb +2 -1
  62. data/lib/secure_headers/headers/x_download_options.rb +39 -0
  63. data/lib/secure_headers/headers/x_permitted_cross_domain_policies.rb +40 -0
  64. data/lib/secure_headers/headers/x_xss_protection.rb +2 -1
  65. data/lib/secure_headers/railtie.rb +19 -24
  66. data/lib/secure_headers/version.rb +1 -1
  67. data/lib/secure_headers/view_helper.rb +68 -0
  68. data/lib/secure_headers.rb +65 -16
  69. data/lib/tasks/tasks.rake +48 -0
  70. data/secure_headers.gemspec +4 -4
  71. data/spec/lib/secure_headers/headers/content_security_policy/script_hash_middleware_spec.rb +47 -0
  72. data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +83 -208
  73. data/spec/lib/secure_headers/headers/strict_transport_security_spec.rb +1 -0
  74. data/spec/lib/secure_headers/headers/x_download_options_spec.rb +32 -0
  75. data/spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb +64 -0
  76. data/spec/lib/secure_headers/headers/x_xss_protection_spec.rb +2 -1
  77. data/spec/lib/secure_headers_spec.rb +62 -61
  78. data/spec/spec_helper.rb +27 -1
  79. metadata +54 -45
  80. checksums.yaml +0 -15
  81. data/Guardfile +0 -6
  82. data/HISTORY.md +0 -148
  83. data/app/controllers/content_security_policy_controller.rb +0 -75
  84. data/config/curl-ca-bundle.crt +0 -5420
  85. data/config/routes.rb +0 -3
  86. data/fixtures/rails_3_2_12/app/models/thing.rb +0 -3
  87. data/fixtures/rails_3_2_12/config/database.yml +0 -25
  88. data/fixtures/rails_3_2_12/config/environments/development.rb +0 -37
  89. data/fixtures/rails_3_2_12/config/environments/production.rb +0 -67
  90. data/fixtures/rails_3_2_12/config/initializers/backtrace_silencers.rb +0 -7
  91. data/fixtures/rails_3_2_12/config/initializers/inflections.rb +0 -15
  92. data/fixtures/rails_3_2_12/config/initializers/mime_types.rb +0 -5
  93. data/fixtures/rails_3_2_12/config/initializers/secret_token.rb +0 -7
  94. data/fixtures/rails_3_2_12/config/initializers/session_store.rb +0 -8
  95. data/fixtures/rails_3_2_12/config/initializers/wrap_parameters.rb +0 -14
  96. data/fixtures/rails_3_2_12/config/locales/en.yml +0 -5
  97. data/fixtures/rails_3_2_12/db/schema.rb +0 -16
  98. data/fixtures/rails_3_2_12/db/seeds.rb +0 -7
  99. data/fixtures/rails_3_2_12_no_init/app/models/thing.rb +0 -3
  100. data/fixtures/rails_3_2_12_no_init/app/views/things/_form.html.erb +0 -17
  101. data/fixtures/rails_3_2_12_no_init/app/views/things/edit.html.erb +0 -6
  102. data/fixtures/rails_3_2_12_no_init/app/views/things/new.html.erb +0 -5
  103. data/fixtures/rails_3_2_12_no_init/app/views/things/show.html.erb +0 -5
  104. data/fixtures/rails_3_2_12_no_init/config/database.yml +0 -25
  105. data/fixtures/rails_3_2_12_no_init/config/environments/development.rb +0 -37
  106. data/fixtures/rails_3_2_12_no_init/config/environments/production.rb +0 -67
  107. data/fixtures/rails_3_2_12_no_init/config/initializers/backtrace_silencers.rb +0 -7
  108. data/fixtures/rails_3_2_12_no_init/config/initializers/inflections.rb +0 -15
  109. data/fixtures/rails_3_2_12_no_init/config/initializers/mime_types.rb +0 -5
  110. data/fixtures/rails_3_2_12_no_init/config/initializers/secret_token.rb +0 -7
  111. data/fixtures/rails_3_2_12_no_init/config/initializers/session_store.rb +0 -8
  112. data/fixtures/rails_3_2_12_no_init/config/initializers/wrap_parameters.rb +0 -14
  113. data/fixtures/rails_3_2_12_no_init/config/locales/en.yml +0 -5
  114. data/fixtures/rails_3_2_12_no_init/db/schema.rb +0 -16
  115. data/fixtures/rails_3_2_12_no_init/db/seeds.rb +0 -7
  116. data/spec/controllers/content_security_policy_controller_spec.rb +0 -90
@@ -18,26 +18,7 @@ describe SecureHeaders do
18
18
  allow(subject).to receive(:request).and_return(request)
19
19
  end
20
20
 
21
- ALL_HEADERS = Hash[[:hsts, :csp, :x_frame_options, :x_content_type_options, :x_xss_protection].map{|header| [header, false]}]
22
- USER_AGENTS = {
23
- :firefox => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1',
24
- :chrome => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5',
25
- :ie => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)',
26
- :opera => 'Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00',
27
- :ios5 => "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3",
28
- :ios6 => "Mozilla/5.0 (iPhone; CPU iPhone OS 614 like Mac OS X) AppleWebKit/536.26 (KHTML like Gecko) Version/6.0 Mobile/10B350 Safari/8536.25",
29
- :safari5 => "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3",
30
- :safari5_1 => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
31
- :safari6 => "Mozilla/5.0 (Macintosh; Intel Mac OS X 1084) AppleWebKit/536.30.1 (KHTML like Gecko) Version/6.0.5 Safari/536.30.1"
32
- }
33
-
34
- def should_assign_header name, value
35
- expect(response.headers).to receive(:[]=).with(name, value)
36
- end
37
-
38
- def should_not_assign_header name
39
- expect(response.headers).not_to receive(:[]=).with(name, anything)
40
- end
21
+ ALL_HEADERS = Hash[[:hsts, :csp, :x_frame_options, :x_content_type_options, :x_xss_protection, :x_permitted_cross_domain_policies].map{|header| [header, false]}]
41
22
 
42
23
  def stub_user_agent val
43
24
  allow(request).to receive_message_chain(:env, :[]).and_return(val)
@@ -54,6 +35,8 @@ describe SecureHeaders do
54
35
  config.x_content_type_options = nil
55
36
  config.x_xss_protection = nil
56
37
  config.csp = nil
38
+ config.x_download_options = nil
39
+ config.x_permitted_cross_domain_policies = nil
57
40
  end
58
41
  end
59
42
 
@@ -63,14 +46,8 @@ describe SecureHeaders do
63
46
  subject.set_x_frame_options_header
64
47
  subject.set_x_content_type_options_header
65
48
  subject.set_x_xss_protection_header
66
- end
67
-
68
- describe "#ensure_security_headers" do
69
- it "sets a before filter" do
70
- options = {}
71
- expect(DummyClass).to receive(:before_filter).exactly(5).times
72
- DummyClass.ensure_security_headers(options)
73
- end
49
+ subject.set_x_download_options_header
50
+ subject.set_x_permitted_cross_domain_policies_header
74
51
  end
75
52
 
76
53
  describe "#set_header" do
@@ -86,19 +63,18 @@ describe SecureHeaders do
86
63
  end
87
64
 
88
65
  describe "#set_security_headers" do
89
- before(:each) do
90
- allow(SecureHeaders::ContentSecurityPolicy).to receive(:new).and_return(double.as_null_object)
91
- end
92
66
  USER_AGENTS.each do |name, useragent|
93
67
  it "sets all default headers for #{name} (smoke test)" do
94
68
  stub_user_agent(useragent)
95
- number_of_headers = 5
69
+ number_of_headers = 7
96
70
  expect(subject).to receive(:set_header).exactly(number_of_headers).times # a request for a given header
97
71
  subject.set_csp_header
98
72
  subject.set_x_frame_options_header
99
73
  subject.set_hsts_header
100
74
  subject.set_x_xss_protection_header
101
75
  subject.set_x_content_type_options_header
76
+ subject.set_x_download_options_header
77
+ subject.set_x_permitted_cross_domain_policies_header
102
78
  end
103
79
  end
104
80
 
@@ -113,11 +89,21 @@ describe SecureHeaders do
113
89
  subject.set_x_xss_protection_header(false)
114
90
  end
115
91
 
92
+ it "does not set the X-Download-Options header if disabled" do
93
+ should_not_assign_header(XDO_HEADER_NAME)
94
+ subject.set_x_download_options_header(false)
95
+ end
96
+
116
97
  it "does not set the X-Frame-Options header if disabled" do
117
98
  should_not_assign_header(XFO_HEADER_NAME)
118
99
  subject.set_x_frame_options_header(false)
119
100
  end
120
101
 
102
+ it "does not set the X-Permitted-Cross-Domain-Policies header if disabled" do
103
+ should_not_assign_header(XPCDP_HEADER_NAME)
104
+ subject.set_x_permitted_cross_domain_policies_header(false)
105
+ end
106
+
121
107
  it "does not set the HSTS header if disabled" do
122
108
  should_not_assign_header(HSTS_HEADER_NAME)
123
109
  subject.set_hsts_header(false)
@@ -131,8 +117,19 @@ describe SecureHeaders do
131
117
 
132
118
  it "does not set the CSP header if disabled" do
133
119
  stub_user_agent(USER_AGENTS[:chrome])
134
- should_not_assign_header(STANDARD_HEADER_NAME)
135
- subject.set_csp_header(options_for(:csp).merge(:csp => false))
120
+ should_not_assign_header(HEADER_NAME)
121
+ subject.set_csp_header(false)
122
+ end
123
+
124
+ it "saves the options to the env when using script hashes" do
125
+ opts = {
126
+ :default_src => 'self',
127
+ :script_hash_middleware => true
128
+ }
129
+ stub_user_agent(USER_AGENTS[:chrome])
130
+
131
+ expect(SecureHeaders::ContentSecurityPolicy).to receive(:add_to_env)
132
+ subject.set_csp_header(opts)
136
133
  end
137
134
 
138
135
  context "when disabled by configuration settings" do
@@ -143,6 +140,8 @@ describe SecureHeaders do
143
140
  config.x_content_type_options = false
144
141
  config.x_xss_protection = false
145
142
  config.csp = false
143
+ config.x_download_options = false
144
+ config.x_permitted_cross_domain_policies = false
146
145
  end
147
146
  expect(subject).not_to receive(:set_header)
148
147
  set_security_headers(subject)
@@ -163,6 +162,18 @@ describe SecureHeaders do
163
162
  end
164
163
  end
165
164
 
165
+ describe "#set_x_download_options_header" do
166
+ it "sets the X-Download-Options header" do
167
+ should_assign_header(XDO_HEADER_NAME, SecureHeaders::XDownloadOptions::Constants::DEFAULT_VALUE)
168
+ subject.set_x_download_options_header
169
+ end
170
+
171
+ it "allows a custom X-Download-Options header" do
172
+ should_assign_header(XDO_HEADER_NAME, "noopen")
173
+ subject.set_x_download_options_header(:value => 'noopen')
174
+ end
175
+ end
176
+
166
177
  describe "#set_strict_transport_security" do
167
178
  it "sets the Strict-Transport-Security header" do
168
179
  should_assign_header(HSTS_HEADER_NAME, SecureHeaders::StrictTransportSecurity::Constants::DEFAULT_VALUE)
@@ -178,6 +189,11 @@ describe SecureHeaders do
178
189
  should_assign_header(HSTS_HEADER_NAME, "max-age=#{HSTS_MAX_AGE}; includeSubdomains")
179
190
  subject.set_hsts_header(:max_age => HSTS_MAX_AGE, :include_subdomains => true)
180
191
  end
192
+
193
+ it "allows you to specify preload" do
194
+ should_assign_header(HSTS_HEADER_NAME, "max-age=#{HSTS_MAX_AGE}; includeSubdomains; preload")
195
+ subject.set_hsts_header(:max_age => HSTS_MAX_AGE, :include_subdomains => true, :preload => true)
196
+ end
181
197
  end
182
198
 
183
199
  describe "#set_x_xss_protection" do
@@ -221,7 +237,7 @@ describe SecureHeaders do
221
237
  context "when using Firefox" do
222
238
  it "sets CSP headers" do
223
239
  stub_user_agent(USER_AGENTS[:firefox])
224
- should_assign_header(STANDARD_HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
240
+ should_assign_header(HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
225
241
  subject.set_csp_header
226
242
  end
227
243
  end
@@ -229,7 +245,7 @@ describe SecureHeaders do
229
245
  context "when using Chrome" do
230
246
  it "sets default CSP header" do
231
247
  stub_user_agent(USER_AGENTS[:chrome])
232
- should_assign_header(STANDARD_HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
248
+ should_assign_header(HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
233
249
  subject.set_csp_header
234
250
  end
235
251
  end
@@ -237,36 +253,21 @@ describe SecureHeaders do
237
253
  context "when using a browser besides chrome/firefox" do
238
254
  it "sets the CSP header" do
239
255
  stub_user_agent(USER_AGENTS[:opera])
240
- should_assign_header(STANDARD_HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
256
+ should_assign_header(HEADER_NAME + "-Report-Only", DEFAULT_CSP_HEADER)
241
257
  subject.set_csp_header
242
258
  end
243
259
  end
260
+ end
244
261
 
245
- context "when using the experimental key" do
246
- before(:each) do
247
- stub_user_agent(USER_AGENTS[:chrome])
248
- @opts = {
249
- :enforce => true,
250
- :default_src => 'self',
251
- :script_src => 'https://mycdn.example.com',
252
- :experimental => {
253
- :script_src => 'self',
254
- }
255
- }
256
- end
257
-
258
- it "does not set the header in enforce mode if experimental is supplied, but enforce is disabled" do
259
- opts = @opts.merge(:enforce => false)
260
- should_assign_header(STANDARD_HEADER_NAME + "-Report-Only", anything)
261
- should_not_assign_header(STANDARD_HEADER_NAME)
262
- subject.set_csp_header(opts)
263
- end
262
+ describe "#set_x_permitted_cross_domain_policies_header" do
263
+ it "sets the X-Permitted-Cross-Domain-Policies header" do
264
+ should_assign_header(XPCDP_HEADER_NAME, SecureHeaders::XPermittedCrossDomainPolicies::Constants::DEFAULT_VALUE)
265
+ subject.set_x_permitted_cross_domain_policies_header
266
+ end
264
267
 
265
- it "sets a header in enforce mode as well as report-only mode" do
266
- should_assign_header(STANDARD_HEADER_NAME, anything)
267
- should_assign_header(STANDARD_HEADER_NAME + "-Report-Only", anything)
268
- subject.set_csp_header(@opts)
269
- end
268
+ it "allows a custom X-Permitted-Cross-Domain-Policies header" do
269
+ should_assign_header(XPCDP_HEADER_NAME, "master-only")
270
+ subject.set_x_permitted_cross_domain_policies_header(:value => 'master-only')
270
271
  end
271
272
  end
272
273
  end
data/spec/spec_helper.rb CHANGED
@@ -2,9 +2,35 @@ require 'rubygems'
2
2
  require 'rspec'
3
3
 
4
4
  require File.join(File.dirname(__FILE__), '..', 'lib', 'secure_headers')
5
- require File.join(File.dirname(__FILE__), '..', 'app', 'controllers', 'content_security_policy_controller')
5
+
6
+ if defined?(Coveralls)
7
+ Coveralls.wear!
8
+ end
9
+
6
10
  include ::SecureHeaders::StrictTransportSecurity::Constants
7
11
  include ::SecureHeaders::ContentSecurityPolicy::Constants
8
12
  include ::SecureHeaders::XFrameOptions::Constants
9
13
  include ::SecureHeaders::XXssProtection::Constants
10
14
  include ::SecureHeaders::XContentTypeOptions::Constants
15
+ include ::SecureHeaders::XDownloadOptions::Constants
16
+ include ::SecureHeaders::XPermittedCrossDomainPolicies::Constants
17
+
18
+ USER_AGENTS = {
19
+ :firefox => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1',
20
+ :chrome => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5',
21
+ :ie => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)',
22
+ :opera => 'Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00',
23
+ :ios5 => "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3",
24
+ :ios6 => "Mozilla/5.0 (iPhone; CPU iPhone OS 614 like Mac OS X) AppleWebKit/536.26 (KHTML like Gecko) Version/6.0 Mobile/10B350 Safari/8536.25",
25
+ :safari5 => "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3",
26
+ :safari5_1 => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
27
+ :safari6 => "Mozilla/5.0 (Macintosh; Intel Mac OS X 1084) AppleWebKit/536.30.1 (KHTML like Gecko) Version/6.0.5 Safari/536.30.1"
28
+ }
29
+
30
+ def should_assign_header name, value
31
+ expect(response.headers).to receive(:[]=).with(name, value)
32
+ end
33
+
34
+ def should_not_assign_header name
35
+ expect(response.headers).not_to receive(:[]=).with(name, anything)
36
+ end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 2.0.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Neil Matatall
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
12
+ date: 2015-01-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,11 +22,12 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
- description: Add easily configured browser headers to responses.
30
+ description: Security related headers all in one gem.
28
31
  email:
29
32
  - neil.matatall@gmail.com
30
33
  executables: []
@@ -36,14 +39,9 @@ files:
36
39
  - .ruby-version
37
40
  - .travis.yml
38
41
  - Gemfile
39
- - Guardfile
40
- - HISTORY.md
41
42
  - LICENSE
42
43
  - README.md
43
44
  - Rakefile
44
- - app/controllers/content_security_policy_controller.rb
45
- - config/curl-ca-bundle.crt
46
- - config/routes.rb
47
45
  - fixtures/rails_3_2_12/.rspec
48
46
  - fixtures/rails_3_2_12/Gemfile
49
47
  - fixtures/rails_3_2_12/README.rdoc
@@ -52,29 +50,17 @@ files:
52
50
  - fixtures/rails_3_2_12/app/controllers/other_things_controller.rb
53
51
  - fixtures/rails_3_2_12/app/controllers/things_controller.rb
54
52
  - fixtures/rails_3_2_12/app/models/.gitkeep
55
- - fixtures/rails_3_2_12/app/models/thing.rb
56
53
  - fixtures/rails_3_2_12/app/views/layouts/application.html.erb
57
54
  - fixtures/rails_3_2_12/app/views/other_things/index.html.erb
58
55
  - fixtures/rails_3_2_12/app/views/things/index.html.erb
59
56
  - fixtures/rails_3_2_12/config.ru
60
57
  - fixtures/rails_3_2_12/config/application.rb
61
58
  - fixtures/rails_3_2_12/config/boot.rb
62
- - fixtures/rails_3_2_12/config/database.yml
63
59
  - fixtures/rails_3_2_12/config/environment.rb
64
- - fixtures/rails_3_2_12/config/environments/development.rb
65
- - fixtures/rails_3_2_12/config/environments/production.rb
66
60
  - fixtures/rails_3_2_12/config/environments/test.rb
67
- - fixtures/rails_3_2_12/config/initializers/backtrace_silencers.rb
68
- - fixtures/rails_3_2_12/config/initializers/inflections.rb
69
- - fixtures/rails_3_2_12/config/initializers/mime_types.rb
70
- - fixtures/rails_3_2_12/config/initializers/secret_token.rb
71
61
  - fixtures/rails_3_2_12/config/initializers/secure_headers.rb
72
- - fixtures/rails_3_2_12/config/initializers/session_store.rb
73
- - fixtures/rails_3_2_12/config/initializers/wrap_parameters.rb
74
- - fixtures/rails_3_2_12/config/locales/en.yml
75
62
  - fixtures/rails_3_2_12/config/routes.rb
76
- - fixtures/rails_3_2_12/db/schema.rb
77
- - fixtures/rails_3_2_12/db/seeds.rb
63
+ - fixtures/rails_3_2_12/config/script_hashes.yml
78
64
  - fixtures/rails_3_2_12/lib/assets/.gitkeep
79
65
  - fixtures/rails_3_2_12/lib/tasks/.gitkeep
80
66
  - fixtures/rails_3_2_12/log/.gitkeep
@@ -92,32 +78,15 @@ files:
92
78
  - fixtures/rails_3_2_12_no_init/app/controllers/other_things_controller.rb
93
79
  - fixtures/rails_3_2_12_no_init/app/controllers/things_controller.rb
94
80
  - fixtures/rails_3_2_12_no_init/app/models/.gitkeep
95
- - fixtures/rails_3_2_12_no_init/app/models/thing.rb
96
81
  - fixtures/rails_3_2_12_no_init/app/views/layouts/application.html.erb
97
82
  - fixtures/rails_3_2_12_no_init/app/views/other_things/index.html.erb
98
- - fixtures/rails_3_2_12_no_init/app/views/things/_form.html.erb
99
- - fixtures/rails_3_2_12_no_init/app/views/things/edit.html.erb
100
83
  - fixtures/rails_3_2_12_no_init/app/views/things/index.html.erb
101
- - fixtures/rails_3_2_12_no_init/app/views/things/new.html.erb
102
- - fixtures/rails_3_2_12_no_init/app/views/things/show.html.erb
103
84
  - fixtures/rails_3_2_12_no_init/config.ru
104
85
  - fixtures/rails_3_2_12_no_init/config/application.rb
105
86
  - fixtures/rails_3_2_12_no_init/config/boot.rb
106
- - fixtures/rails_3_2_12_no_init/config/database.yml
107
87
  - fixtures/rails_3_2_12_no_init/config/environment.rb
108
- - fixtures/rails_3_2_12_no_init/config/environments/development.rb
109
- - fixtures/rails_3_2_12_no_init/config/environments/production.rb
110
88
  - fixtures/rails_3_2_12_no_init/config/environments/test.rb
111
- - fixtures/rails_3_2_12_no_init/config/initializers/backtrace_silencers.rb
112
- - fixtures/rails_3_2_12_no_init/config/initializers/inflections.rb
113
- - fixtures/rails_3_2_12_no_init/config/initializers/mime_types.rb
114
- - fixtures/rails_3_2_12_no_init/config/initializers/secret_token.rb
115
- - fixtures/rails_3_2_12_no_init/config/initializers/session_store.rb
116
- - fixtures/rails_3_2_12_no_init/config/initializers/wrap_parameters.rb
117
- - fixtures/rails_3_2_12_no_init/config/locales/en.yml
118
89
  - fixtures/rails_3_2_12_no_init/config/routes.rb
119
- - fixtures/rails_3_2_12_no_init/db/schema.rb
120
- - fixtures/rails_3_2_12_no_init/db/seeds.rb
121
90
  - fixtures/rails_3_2_12_no_init/lib/assets/.gitkeep
122
91
  - fixtures/rails_3_2_12_no_init/lib/tasks/.gitkeep
123
92
  - fixtures/rails_3_2_12_no_init/log/.gitkeep
@@ -127,22 +96,59 @@ files:
127
96
  - fixtures/rails_3_2_12_no_init/vendor/assets/javascripts/.gitkeep
128
97
  - fixtures/rails_3_2_12_no_init/vendor/assets/stylesheets/.gitkeep
129
98
  - fixtures/rails_3_2_12_no_init/vendor/plugins/.gitkeep
99
+ - fixtures/rails_4_1_8/Gemfile
100
+ - fixtures/rails_4_1_8/README.rdoc
101
+ - fixtures/rails_4_1_8/Rakefile
102
+ - fixtures/rails_4_1_8/app/controllers/application_controller.rb
103
+ - fixtures/rails_4_1_8/app/controllers/concerns/.keep
104
+ - fixtures/rails_4_1_8/app/controllers/other_things_controller.rb
105
+ - fixtures/rails_4_1_8/app/controllers/things_controller.rb
106
+ - fixtures/rails_4_1_8/app/models/.keep
107
+ - fixtures/rails_4_1_8/app/models/concerns/.keep
108
+ - fixtures/rails_4_1_8/app/views/layouts/application.html.erb
109
+ - fixtures/rails_4_1_8/app/views/other_things/index.html.erb
110
+ - fixtures/rails_4_1_8/app/views/things/index.html.erb
111
+ - fixtures/rails_4_1_8/config.ru
112
+ - fixtures/rails_4_1_8/config/application.rb
113
+ - fixtures/rails_4_1_8/config/boot.rb
114
+ - fixtures/rails_4_1_8/config/environment.rb
115
+ - fixtures/rails_4_1_8/config/environments/test.rb
116
+ - fixtures/rails_4_1_8/config/initializers/secure_headers.rb
117
+ - fixtures/rails_4_1_8/config/routes.rb
118
+ - fixtures/rails_4_1_8/config/script_hashes.yml
119
+ - fixtures/rails_4_1_8/config/secrets.yml
120
+ - fixtures/rails_4_1_8/lib/assets/.keep
121
+ - fixtures/rails_4_1_8/lib/tasks/.keep
122
+ - fixtures/rails_4_1_8/log/.keep
123
+ - fixtures/rails_4_1_8/spec/controllers/other_things_controller_spec.rb
124
+ - fixtures/rails_4_1_8/spec/controllers/things_controller_spec.rb
125
+ - fixtures/rails_4_1_8/spec/spec_helper.rb
126
+ - fixtures/rails_4_1_8/vendor/assets/javascripts/.keep
127
+ - fixtures/rails_4_1_8/vendor/assets/stylesheets/.keep
130
128
  - lib/secure_headers.rb
129
+ - lib/secure_headers/hash_helper.rb
131
130
  - lib/secure_headers/header.rb
132
131
  - lib/secure_headers/headers/content_security_policy.rb
132
+ - lib/secure_headers/headers/content_security_policy/script_hash_middleware.rb
133
133
  - lib/secure_headers/headers/strict_transport_security.rb
134
134
  - lib/secure_headers/headers/x_content_type_options.rb
135
+ - lib/secure_headers/headers/x_download_options.rb
135
136
  - lib/secure_headers/headers/x_frame_options.rb
137
+ - lib/secure_headers/headers/x_permitted_cross_domain_policies.rb
136
138
  - lib/secure_headers/headers/x_xss_protection.rb
137
139
  - lib/secure_headers/padrino.rb
138
140
  - lib/secure_headers/railtie.rb
139
141
  - lib/secure_headers/version.rb
142
+ - lib/secure_headers/view_helper.rb
143
+ - lib/tasks/tasks.rake
140
144
  - secure_headers.gemspec
141
- - spec/controllers/content_security_policy_controller_spec.rb
145
+ - spec/lib/secure_headers/headers/content_security_policy/script_hash_middleware_spec.rb
142
146
  - spec/lib/secure_headers/headers/content_security_policy_spec.rb
143
147
  - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
144
148
  - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
149
+ - spec/lib/secure_headers/headers/x_download_options_spec.rb
145
150
  - spec/lib/secure_headers/headers/x_frame_options_spec.rb
151
+ - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
146
152
  - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
147
153
  - spec/lib/secure_headers_spec.rb
148
154
  - spec/spec_helper.rb
@@ -150,34 +156,37 @@ files:
150
156
  homepage: https://github.com/twitter/secureheaders
151
157
  licenses:
152
158
  - Apache Public License 2.0
153
- metadata: {}
154
159
  post_install_message:
155
160
  rdoc_options: []
156
161
  require_paths:
157
162
  - lib
158
163
  required_ruby_version: !ruby/object:Gem::Requirement
164
+ none: false
159
165
  requirements:
160
166
  - - ! '>='
161
167
  - !ruby/object:Gem::Version
162
168
  version: '0'
163
169
  required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
164
171
  requirements:
165
172
  - - ! '>='
166
173
  - !ruby/object:Gem::Version
167
174
  version: '0'
168
175
  requirements: []
169
176
  rubyforge_project:
170
- rubygems_version: 2.1.1
177
+ rubygems_version: 1.8.23
171
178
  signing_key:
172
- specification_version: 4
173
- summary: Add easily configured browser headers to responses including content security
174
- policy, x-frame-options, strict-transport-security and more.
179
+ specification_version: 3
180
+ summary: Add easily configured security headers to responses including content-security-policy,
181
+ x-frame-options, strict-transport-security, etc.
175
182
  test_files:
176
- - spec/controllers/content_security_policy_controller_spec.rb
183
+ - spec/lib/secure_headers/headers/content_security_policy/script_hash_middleware_spec.rb
177
184
  - spec/lib/secure_headers/headers/content_security_policy_spec.rb
178
185
  - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
179
186
  - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
187
+ - spec/lib/secure_headers/headers/x_download_options_spec.rb
180
188
  - spec/lib/secure_headers/headers/x_frame_options_spec.rb
189
+ - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
181
190
  - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
182
191
  - spec/lib/secure_headers_spec.rb
183
192
  - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGRkYjRlNDU4ZTZjMWViMTM0NTlkZDc1ZDNmNjJkMjNlMGIzMDY5OA==
5
- data.tar.gz: !binary |-
6
- Y2Y0OGEwODAwNDZmMzNkNWYzYzJiNDAzZTdlZDE2YmYzNzQ5MDNhMA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- NGZmODE5M2ViNWJkZTRhMjRjYzEwNTRkZDkzMzdmOWQzMzdiYWU0OGM3ZGZl
10
- Yjc0YjJmOTI4MWFiMTE2NGJlMDA4ZjA2YjY3YzAyMWU5ZDExMmEwZWM1ODVl
11
- ZDllOGFlYTdhNjU1YjRlZjc1MjM4MjM5MDlmY2EwNzljNjU4OTA=
12
- data.tar.gz: !binary |-
13
- Y2UzZDgxNWFlMGQ3YmMwODY2OTQyNmVhZDU3YWQ5ODk3MDRjNWQwZTJhODMy
14
- Njk2ODQyZjQ1MTA1YjZjMmMxZDM2YTcyOWE3ODIxN2Q1ZjQzNDQ3MmM3NGI2
15
- YWU4NzZkZmQ3NWM1ZTNlZWI4NzIzMDFhZDZjODQ1MzhkMjlkMDk=
data/Guardfile DELETED
@@ -1,6 +0,0 @@
1
- guard 'rspec' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch(%r{^app/controllers/(.+)\.rb$}) { |m| "spec/controllers/#{m[1]}_spec.rb" }
5
- watch('spec/spec_helper.rb') { "spec" }
6
- end
data/HISTORY.md DELETED
@@ -1,148 +0,0 @@
1
- 1.3.2
2
- ======
3
-
4
- Adds the ability to "tag" requests and a new config value: :app_name
5
-
6
- {
7
- :tag_report_uri => true,
8
- :enforce => true,
9
- :app_name => 'twitter',
10
- :report_uri => 'csp_reports'
11
- }
12
-
13
- Results in
14
- report-uri csp_reports?enforce=true&app_name=twitter
15
-
16
-
17
- 1.3.1
18
- ======
19
-
20
- Bugfix release: same-origin detection would error out when the URL containined invalid values (like |)
21
-
22
- 1.3.0
23
- ======
24
-
25
- - CSP nonce support was added back and is compliant.
26
- - Bugs:
27
- -- enforce, disable_fill_missing, and disable_chrome_extension did not accept lambdas for no good reason
28
- -- IF a default-src was specified, and an img-src was not, and disable_fill_missing was true, the img-src value would be :data
29
-
30
- 1.2.0
31
- ======
32
- - Allow procs to be used as config values.
33
-
34
- 1.1.1
35
- ======
36
-
37
- Bug fix release.
38
- - Parsing of CSP reports was busted.
39
- - Forwarded reports did not include the original referer, ip, UA
40
-
41
- 1.1.0
42
- ======
43
-
44
- - Remove brwsr dependency (no more runtime dependencies)
45
- - Stop serving X- prefixed CSP headers
46
-
47
- This change means that all requests get all headers, even if the browser doesn't grok it.
48
-
49
- 1.0.0
50
- ======
51
-
52
- Features:
53
-
54
- - Use non-prefixed header names for Firefox >= 23, Chrome >= 25
55
- - Use csp 1.0 compliant header for firefox >= 23
56
-
57
- Bug Fix:
58
-
59
- - Stop sending CSP on safari 5.1+
60
-
61
- 0.5.0
62
- ======
63
-
64
- - X-Content-Type-Options also applied to Chrome requests
65
-
66
- 0.4.3
67
- ======
68
-
69
- - Safari 5 is just completely broken when CSP is used, both mobile and desktop versions
70
-
71
- 0.4.2
72
- ======
73
-
74
- - Stupid bug where Fixnums couldn't be used for config values
75
- - Doc updates
76
-
77
- 0.4.1
78
- ======
79
-
80
- - Allow strings or ints in the HSTS max-age (@reedloden)
81
-
82
- 0.4.0
83
- =======
84
-
85
- - Treat each header as it's own before_filter. This allows you to `skip_before_filter :set_X_header, :only => :bad_idea
86
- - Should be backwards compatible, but it is a change to the API.
87
-
88
- 0.3.0
89
- =======
90
-
91
- - Greatly reduce the need to use the forward_endpoint attribute. If you are posting from your site to a host that matches TLD+1 (e.g. translate.twitter.com matches twitter.com), use a protocol relative value for report-uri. This will alleviate the need to use forwarding. If your host doesn't match, you still need to use forwarding due to host mismatches for Firefox.
92
-
93
- 0.2.3
94
- =======
95
-
96
- - Fix error in report-uri logic for Firefox forwarding.
97
-
98
- 0.2.2
99
- =======
100
-
101
- - Stop applying chrome-extension: to Firefox directives.
102
-
103
- 0.2.1
104
- =======
105
-
106
- - Firefox headers will now stop overriding report_uri when only a path is supplied
107
-
108
- 0.2.0
109
- =======
110
-
111
- - 0.1.0 introduced a serious regression in which child controllers overwrote parent controller config values
112
- - Decoupling of CSP headers and the request object. Allows you to generate static values to save cycles:
113
-
114
- ```ruby
115
- FIREFOX = SecureHeaders::ContentSecurityPolicy.new(config, :ua => "Firefox", :ssl => true).value
116
- CHROME = SecureHeaders::ContentSecurityPolicy.new(config, :ua => "Chrome", :ssl => true).value
117
- ```
118
- - :forward_endpoint now acts as the endpoint that reports are forwarded to (when using the internal forwarder feature for cross-host reporting)
119
- - Skeleton applications have been added to test isolated application configurations
120
- - Cleanup by @bemurphy
121
-
122
- 0.1.1
123
- =======
124
-
125
- Bug fix. Firefox doesn't seem to like the default-src directive, reverting back to 'allow'
126
-
127
- 0.1.0
128
- =======
129
-
130
- Notes:
131
- ------
132
-
133
- - Gem is renamed to secure_headers. This will make bundler happy. https://github.com/twitter/secureheaders/pull/26
134
-
135
- Features:
136
- ------
137
-
138
- - ability to apply two headers, one in enforce mode, one in "experimental" mode https://github.com/twitter/secureheaders/pull/11
139
- - Rails 3.0 support https://github.com/twitter/secureheaders/pull/28
140
-
141
- Bug fixes, misc:
142
- ------
143
-
144
- - Fix issue where settings in application_controller were ignored if no intializer was supplied https://github.com/twitter/secureheaders/pull/25
145
- - Better support for other frameworks, including docs from @achui, @bmaland
146
- - Rails 4 routes support from @jviney https://github.com/twitter/secureheaders/pull/13
147
- - data: automatically whitelisted for img-src
148
- - Doc updates from @ming13, @theverything, @dcollazo