rack 1.6.10 → 1.6.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/lib/rack.rb +1 -1
- data/lib/rack/request.rb +17 -4
- data/lib/rack/showexceptions.rb +1 -1
- data/rack.gemspec +1 -1
- data/test/spec_request.rb +5 -0
- data/test/spec_showexceptions.rb +13 -0
- metadata +42 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b455a83d19e7b00bb4feb2287b28116434155cf52ea772cb9b532495f49938cc
|
4
|
+
data.tar.gz: 99a947eaf73e0207a642c92398e26062d5dc508455c72447e865a6aaec86dc5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc84a2788ac063238c547ea118a1e14624ace7ebc683cbf34842e57f5d4ac6fd843c4be0c3e717d7351da297a5e664f7b93255c2b37f3a73dc0939a4eb5596f
|
7
|
+
data.tar.gz: ff727aec584e743839a3a9c3fbe9f88d3c6c481b3f9fdf6f472a182b6caef19de7835c9a5222359fe5bb296eab79030df880e220756693fbc244b7fd5f05756c
|
data/lib/rack.rb
CHANGED
data/lib/rack/request.rb
CHANGED
@@ -13,6 +13,8 @@ module Rack
|
|
13
13
|
# The environment of the request.
|
14
14
|
attr_reader :env
|
15
15
|
|
16
|
+
SCHEME_WHITELIST = %w(https http).freeze
|
17
|
+
|
16
18
|
def initialize(env)
|
17
19
|
@env = env
|
18
20
|
end
|
@@ -68,10 +70,8 @@ module Rack
|
|
68
70
|
'https'
|
69
71
|
elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
|
70
72
|
'https'
|
71
|
-
elsif
|
72
|
-
|
73
|
-
elsif @env['HTTP_X_FORWARDED_PROTO']
|
74
|
-
@env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
|
73
|
+
elsif forwarded_scheme
|
74
|
+
forwarded_scheme
|
75
75
|
else
|
76
76
|
@env["rack.url_scheme"]
|
77
77
|
end
|
@@ -394,5 +394,18 @@ module Rack
|
|
394
394
|
s
|
395
395
|
end
|
396
396
|
end
|
397
|
+
|
398
|
+
def forwarded_scheme
|
399
|
+
scheme_headers = [
|
400
|
+
@env['HTTP_X_FORWARDED_SCHEME'],
|
401
|
+
@env['HTTP_X_FORWARDED_PROTO'].to_s.split(',')[0]
|
402
|
+
]
|
403
|
+
|
404
|
+
scheme_headers.each do |header|
|
405
|
+
return header if SCHEME_WHITELIST.include?(header)
|
406
|
+
end
|
407
|
+
|
408
|
+
nil
|
409
|
+
end
|
397
410
|
end
|
398
411
|
end
|
data/lib/rack/showexceptions.rb
CHANGED
data/rack.gemspec
CHANGED
data/test/spec_request.rb
CHANGED
@@ -425,6 +425,11 @@ describe Rack::Request do
|
|
425
425
|
request.should.be.ssl?
|
426
426
|
end
|
427
427
|
|
428
|
+
should "prevent scheme abuse" do
|
429
|
+
request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_X_FORWARDED_SCHEME' => 'a."><script>alert(1)</script>'))
|
430
|
+
request.scheme.should.not.equal 'a."><script>alert(1)</script>'
|
431
|
+
end
|
432
|
+
|
428
433
|
should "parse cookies" do
|
429
434
|
req = Rack::Request.new \
|
430
435
|
Rack::MockRequest.env_for("", "HTTP_COOKIE" => "foo=bar;quux=h&m")
|
data/test/spec_showexceptions.rb
CHANGED
@@ -82,4 +82,17 @@ describe Rack::ShowExceptions do
|
|
82
82
|
res.should =~ /ShowExceptions/
|
83
83
|
res.should =~ /unknown location/
|
84
84
|
end
|
85
|
+
|
86
|
+
it "knows to prefer plaintext for non-html" do
|
87
|
+
# We don't need an app for this
|
88
|
+
exc = Rack::ShowExceptions.new(nil)
|
89
|
+
|
90
|
+
[
|
91
|
+
[{ "HTTP_ACCEPT" => "text/plain" }, true],
|
92
|
+
[{ "HTTP_ACCEPT" => "text/foo" }, true],
|
93
|
+
[{ "HTTP_ACCEPT" => "text/html" }, false]
|
94
|
+
].each do |env, expected|
|
95
|
+
assert_equal(expected, exc.prefers_plaintext?(env))
|
96
|
+
end
|
97
|
+
end
|
85
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neukirchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bacon
|
@@ -256,57 +256,57 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
requirements: []
|
258
258
|
rubyforge_project: rack
|
259
|
-
rubygems_version: 2.6
|
259
|
+
rubygems_version: 2.7.6
|
260
260
|
signing_key:
|
261
261
|
specification_version: 4
|
262
262
|
summary: a modular Ruby webserver interface
|
263
263
|
test_files:
|
264
|
-
- test/
|
265
|
-
- test/spec_auth_digest.rb
|
266
|
-
- test/spec_body_proxy.rb
|
267
|
-
- test/spec_builder.rb
|
268
|
-
- test/spec_cascade.rb
|
269
|
-
- test/spec_cgi.rb
|
270
|
-
- test/spec_chunked.rb
|
271
|
-
- test/spec_commonlogger.rb
|
272
|
-
- test/spec_conditionalget.rb
|
273
|
-
- test/spec_config.rb
|
274
|
-
- test/spec_content_length.rb
|
275
|
-
- test/spec_content_type.rb
|
264
|
+
- test/spec_multipart.rb
|
276
265
|
- test/spec_deflater.rb
|
277
|
-
- test/
|
266
|
+
- test/spec_static.rb
|
267
|
+
- test/spec_session_cookie.rb
|
268
|
+
- test/spec_commonlogger.rb
|
269
|
+
- test/spec_session_pool.rb
|
270
|
+
- test/spec_methodoverride.rb
|
278
271
|
- test/spec_etag.rb
|
279
|
-
- test/
|
280
|
-
- test/spec_file.rb
|
272
|
+
- test/spec_version.rb
|
281
273
|
- test/spec_handler.rb
|
282
|
-
- test/
|
283
|
-
- test/
|
284
|
-
- test/
|
285
|
-
- test/spec_lock.rb
|
286
|
-
- test/spec_logger.rb
|
287
|
-
- test/spec_methodoverride.rb
|
274
|
+
- test/spec_thin.rb
|
275
|
+
- test/spec_showexceptions.rb
|
276
|
+
- test/spec_session_abstract_id.rb
|
288
277
|
- test/spec_mime.rb
|
289
|
-
- test/spec_mock.rb
|
290
|
-
- test/spec_mongrel.rb
|
291
|
-
- test/spec_multipart.rb
|
292
|
-
- test/spec_nulllogger.rb
|
293
278
|
- test/spec_recursive.rb
|
279
|
+
- test/spec_cgi.rb
|
280
|
+
- test/spec_content_type.rb
|
294
281
|
- test/spec_request.rb
|
295
|
-
- test/
|
296
|
-
- test/
|
282
|
+
- test/spec_showstatus.rb
|
283
|
+
- test/spec_chunked.rb
|
297
284
|
- test/spec_runtime.rb
|
285
|
+
- test/spec_fastcgi.rb
|
286
|
+
- test/spec_builder.rb
|
287
|
+
- test/spec_config.rb
|
288
|
+
- test/spec_mongrel.rb
|
289
|
+
- test/spec_utils.rb
|
298
290
|
- test/spec_sendfile.rb
|
299
|
-
- test/
|
300
|
-
- test/
|
301
|
-
- test/spec_session_cookie.rb
|
302
|
-
- test/spec_session_memcache.rb
|
303
|
-
- test/spec_session_pool.rb
|
304
|
-
- test/spec_showexceptions.rb
|
305
|
-
- test/spec_showstatus.rb
|
306
|
-
- test/spec_static.rb
|
291
|
+
- test/spec_lobster.rb
|
292
|
+
- test/spec_lint.rb
|
307
293
|
- test/spec_tempfile_reaper.rb
|
308
|
-
- test/
|
309
|
-
- test/
|
310
|
-
- test/
|
311
|
-
- test/
|
294
|
+
- test/spec_mock.rb
|
295
|
+
- test/spec_conditionalget.rb
|
296
|
+
- test/spec_server.rb
|
297
|
+
- test/spec_directory.rb
|
312
298
|
- test/spec_webrick.rb
|
299
|
+
- test/spec_response.rb
|
300
|
+
- test/spec_file.rb
|
301
|
+
- test/spec_body_proxy.rb
|
302
|
+
- test/spec_logger.rb
|
303
|
+
- test/spec_auth_digest.rb
|
304
|
+
- test/spec_urlmap.rb
|
305
|
+
- test/spec_nulllogger.rb
|
306
|
+
- test/spec_cascade.rb
|
307
|
+
- test/spec_auth_basic.rb
|
308
|
+
- test/spec_head.rb
|
309
|
+
- test/spec_lock.rb
|
310
|
+
- test/spec_rewindable_input.rb
|
311
|
+
- test/spec_session_memcache.rb
|
312
|
+
- test/spec_content_length.rb
|