rack 3.0.15 → 3.0.17
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +27 -0
- data/lib/rack/mock_response.rb +31 -2
- data/lib/rack/query_parser.rb +51 -8
- data/lib/rack/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3edf21b75cf99b2e46bdeca610592537a1bf049ca57602943af9d7f8bd446666
|
4
|
+
data.tar.gz: 2619cfe2fd66de38a387978af8db591635402a66c841b532dc52abe841058454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6d0fdc1d2f981c38ae3c1a0a84c126b440d39394d9ec18c5c5ed07770efe01c95d0c6a64a195b2ad4bd5d4d900e1eff08872fd972cb979aec8429331cabc40
|
7
|
+
data.tar.gz: 61b44c13230df6379b8c760d2e7e5c6756f7b42a2f81d14c2cc21cf94eefa781d7e4b53d8f411fc724fef5b987959d791463cef4aa42a9a5e2c480b7470b8e1d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
|
4
4
|
|
5
|
+
## [3.0.17] - 2025-05-18
|
6
|
+
|
7
|
+
- Optional support for `CGI::Cookie` if not available. ([#2327](https://github.com/rack/rack/pull/2327), [#2333](https://github.com/rack/rack/pull/2333), [@earlopain])
|
8
|
+
|
9
|
+
## [3.0.16] - 2025-05-06
|
10
|
+
|
11
|
+
### Security
|
12
|
+
|
13
|
+
- [CVE-2025-46727](https://github.com/rack/rack/security/advisories/GHSA-gjh7-p2fx-99vx) Unbounded parameter parsing in `Rack::QueryParser` can lead to memory exhaustion.
|
14
|
+
|
5
15
|
## [3.0.15] - 2025-04-13
|
6
16
|
|
7
17
|
- Ensure `Rack::ETag` correctly updates response body. ([#2324](https://github.com/rack/rack/pull/2324), [@ioquatix])
|
@@ -204,6 +214,16 @@ All notable changes to this project will be documented in this file. For info on
|
|
204
214
|
- Fix multipart filename generation for filenames that contain spaces. Encode spaces as "%20" instead of "+" which will be decoded properly by the multipart parser. ([#1736](https://github.com/rack/rack/pull/1645), [@muirdm](https://github.com/muirdm))
|
205
215
|
- `Rack::Request#scheme` returns `ws` or `wss` when one of the `X-Forwarded-Scheme` / `X-Forwarded-Proto` headers is set to `ws` or `wss`, respectively. ([#1730](https://github.com/rack/rack/issues/1730), [@erwanst](https://github.com/erwanst))
|
206
216
|
|
217
|
+
## [2.2.15] - 2025-05-18
|
218
|
+
|
219
|
+
- Optional support for `CGI::Cookie` if not available. ([#2327](https://github.com/rack/rack/pull/2327), [#2333](https://github.com/rack/rack/pull/2333), [@earlopain])
|
220
|
+
|
221
|
+
## [2.2.14] - 2025-05-06
|
222
|
+
|
223
|
+
### Security
|
224
|
+
|
225
|
+
- [CVE-2025-46727](https://github.com/rack/rack/security/advisories/GHSA-gjh7-p2fx-99vx) Unbounded parameter parsing in `Rack::QueryParser` can lead to memory exhaustion.
|
226
|
+
|
207
227
|
## [2.2.13] - 2025-03-11
|
208
228
|
|
209
229
|
### Security
|
@@ -982,3 +1002,4 @@ Items below this line are from the previously maintained HISTORY.md and NEWS.md
|
|
982
1002
|
[@amatsuda]: https://github.com/amatsuda "Akira Matsuda"
|
983
1003
|
[@wjordan]: https://github.com/wjordan "Will Jordan"
|
984
1004
|
[@BlakeWilliams]: https://github.com/BlakeWilliams "Blake Williams"
|
1005
|
+
[@earlopain]: https://github.com/earlopain "Earlopain"
|
data/README.md
CHANGED
@@ -165,6 +165,33 @@ quickly and without doing the same web stuff all over:
|
|
165
165
|
Rack exposes several configuration parameters to control various features of the
|
166
166
|
implementation.
|
167
167
|
|
168
|
+
### `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
|
169
|
+
|
170
|
+
This environment variable sets the default for the maximum query string bytesize
|
171
|
+
that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
|
172
|
+
that exceeds this number of bytes will result in a
|
173
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
174
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
175
|
+
|
176
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
177
|
+
the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
|
178
|
+
|
179
|
+
### `RACK_QUERY_PARSER_PARAMS_LIMIT`
|
180
|
+
|
181
|
+
This environment variable sets the default for the maximum number of query
|
182
|
+
parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
|
183
|
+
query string with more than this many query parameters will result in a
|
184
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
185
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
186
|
+
|
187
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
188
|
+
the `params_limit` keyword argument when creating the `Rack::QueryParser`.
|
189
|
+
|
190
|
+
This is implemented by counting the number of parameter separators in the
|
191
|
+
query string, before attempting parsing, so if the same parameter key is
|
192
|
+
used multiple times in the query, each counts as a separate parameter for
|
193
|
+
this check.
|
194
|
+
|
168
195
|
### `param_depth_limit`
|
169
196
|
|
170
197
|
```ruby
|
data/lib/rack/mock_response.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'cgi/cookie'
|
4
3
|
require 'time'
|
5
4
|
|
6
5
|
require_relative 'response'
|
@@ -11,6 +10,36 @@ module Rack
|
|
11
10
|
# MockRequest.
|
12
11
|
|
13
12
|
class MockResponse < Rack::Response
|
13
|
+
begin
|
14
|
+
# Recent versions of the CGI gem may not provide `CGI::Cookie`.
|
15
|
+
require 'cgi/cookie'
|
16
|
+
Cookie = CGI::Cookie
|
17
|
+
rescue LoadError
|
18
|
+
class Cookie
|
19
|
+
attr_reader :name, :value, :path, :domain, :expires, :secure
|
20
|
+
|
21
|
+
def initialize(args)
|
22
|
+
@name = args["name"]
|
23
|
+
@value = args["value"]
|
24
|
+
@path = args["path"]
|
25
|
+
@domain = args["domain"]
|
26
|
+
@expires = args["expires"]
|
27
|
+
@secure = args["secure"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(method_name, *args, &block)
|
31
|
+
@value.send(method_name, *args, &block)
|
32
|
+
end
|
33
|
+
# :nocov:
|
34
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
35
|
+
# :nocov:
|
36
|
+
|
37
|
+
def respond_to_missing?(method_name, include_all = false)
|
38
|
+
@value.respond_to?(method_name, include_all) || super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
14
43
|
class << self
|
15
44
|
alias [] new
|
16
45
|
end
|
@@ -84,7 +113,7 @@ module Rack
|
|
84
113
|
header_value.split("\n").each do |cookie|
|
85
114
|
cookie_name, cookie_filling = cookie.split('=', 2)
|
86
115
|
cookie_attributes = identify_cookie_attributes cookie_filling
|
87
|
-
parsed_cookie =
|
116
|
+
parsed_cookie = Cookie.new(
|
88
117
|
'name' => cookie_name.strip,
|
89
118
|
'value' => cookie_attributes.fetch('value'),
|
90
119
|
'path' => cookie_attributes.fetch('path', nil),
|
data/lib/rack/query_parser.rb
CHANGED
@@ -16,27 +16,54 @@ module Rack
|
|
16
16
|
# sequence.
|
17
17
|
class InvalidParameterError < ArgumentError; end
|
18
18
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
class
|
19
|
+
# QueryLimitError is for errors raised when the query provided exceeds one
|
20
|
+
# of the query parser limits.
|
21
|
+
class QueryLimitError < RangeError
|
22
|
+
end
|
23
|
+
|
24
|
+
# ParamsTooDeepError is the old name for the error that is raised when params
|
25
|
+
# are recursively nested over the specified limit. Make it the same as
|
26
|
+
# as QueryLimitError, so that code that rescues ParamsTooDeepError error
|
27
|
+
# to handle bad query strings also now handles other limits.
|
28
|
+
ParamsTooDeepError = QueryLimitError
|
22
29
|
|
23
|
-
def self.make_default(_key_space_limit=(not_deprecated = true; nil), param_depth_limit)
|
30
|
+
def self.make_default(_key_space_limit=(not_deprecated = true; nil), param_depth_limit, **options)
|
24
31
|
unless not_deprecated
|
25
32
|
warn("`first argument `key_space limit` is deprecated and no longer has an effect. Please call with only one argument, which will be required in a future version of Rack", uplevel: 1)
|
26
33
|
end
|
27
34
|
|
28
|
-
new Params, param_depth_limit
|
35
|
+
new Params, param_depth_limit, **options
|
29
36
|
end
|
30
37
|
|
31
38
|
attr_reader :param_depth_limit
|
32
39
|
|
33
|
-
|
40
|
+
env_int = lambda do |key, val|
|
41
|
+
if str_val = ENV[key]
|
42
|
+
begin
|
43
|
+
val = Integer(str_val, 10)
|
44
|
+
rescue ArgumentError
|
45
|
+
raise ArgumentError, "non-integer value provided for environment variable #{key}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
val
|
50
|
+
end
|
51
|
+
|
52
|
+
BYTESIZE_LIMIT = env_int.call("RACK_QUERY_PARSER_BYTESIZE_LIMIT", 4194304)
|
53
|
+
private_constant :BYTESIZE_LIMIT
|
54
|
+
|
55
|
+
PARAMS_LIMIT = env_int.call("RACK_QUERY_PARSER_PARAMS_LIMIT", 4096)
|
56
|
+
private_constant :PARAMS_LIMIT
|
57
|
+
|
58
|
+
def initialize(params_class, _key_space_limit=(not_deprecated = true; nil), param_depth_limit, bytesize_limit: BYTESIZE_LIMIT, params_limit: PARAMS_LIMIT)
|
34
59
|
unless not_deprecated
|
35
60
|
warn("`second argument `key_space limit` is deprecated and no longer has an effect. Please call with only two arguments, which will be required in a future version of Rack", uplevel: 1)
|
36
61
|
end
|
37
62
|
|
38
63
|
@params_class = params_class
|
39
64
|
@param_depth_limit = param_depth_limit
|
65
|
+
@bytesize_limit = bytesize_limit
|
66
|
+
@params_limit = params_limit
|
40
67
|
end
|
41
68
|
|
42
69
|
# Stolen from Mongrel, with some small modifications:
|
@@ -48,7 +75,7 @@ module Rack
|
|
48
75
|
|
49
76
|
params = make_params
|
50
77
|
|
51
|
-
(qs
|
78
|
+
check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
|
52
79
|
next if p.empty?
|
53
80
|
k, v = p.split('=', 2).map!(&unescaper)
|
54
81
|
|
@@ -75,7 +102,7 @@ module Rack
|
|
75
102
|
params = make_params
|
76
103
|
|
77
104
|
unless qs.nil? || qs.empty?
|
78
|
-
(qs
|
105
|
+
check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
|
79
106
|
k, v = p.split('=', 2).map! { |s| unescape(s) }
|
80
107
|
|
81
108
|
_normalize_params(params, k, v, 0)
|
@@ -190,6 +217,22 @@ module Rack
|
|
190
217
|
true
|
191
218
|
end
|
192
219
|
|
220
|
+
def check_query_string(qs, sep)
|
221
|
+
if qs
|
222
|
+
if qs.bytesize > @bytesize_limit
|
223
|
+
raise QueryLimitError, "total query size (#{qs.bytesize}) exceeds limit (#{@bytesize_limit})"
|
224
|
+
end
|
225
|
+
|
226
|
+
if (param_count = qs.count(sep.is_a?(String) ? sep : '&')) >= @params_limit
|
227
|
+
raise QueryLimitError, "total number of query parameters (#{param_count+1}) exceeds limit (#{@params_limit})"
|
228
|
+
end
|
229
|
+
|
230
|
+
qs
|
231
|
+
else
|
232
|
+
''
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
193
236
|
def unescape(string, encoding = Encoding::UTF_8)
|
194
237
|
URI.decode_www_form_component(string, encoding)
|
195
238
|
end
|
data/lib/rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: minitest
|
@@ -75,9 +75,9 @@ email: leah@vuxu.org
|
|
75
75
|
executables: []
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files:
|
78
|
-
- README.md
|
79
78
|
- CHANGELOG.md
|
80
79
|
- CONTRIBUTING.md
|
80
|
+
- README.md
|
81
81
|
files:
|
82
82
|
- CHANGELOG.md
|
83
83
|
- CONTRIBUTING.md
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubygems_version: 3.6.
|
165
|
+
rubygems_version: 3.6.7
|
166
166
|
specification_version: 4
|
167
167
|
summary: A modular Ruby webserver interface.
|
168
168
|
test_files: []
|