rack 2.1.4.2 → 2.1.4.3
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.rdoc +17 -3
- data/lib/rack/multipart/parser.rb +15 -4
- data/lib/rack/utils.rb +15 -4
- data/lib/rack.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6c6bc44966ead6d6a9da2aaf2491e17ae23f2ad2a812ebca495b804a4574405
|
4
|
+
data.tar.gz: 7aa862a282ed242ed951ca59158e3078a05f19ea377009cd96e4dd09ebf5f513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce33f287708bb007eac0960c5ab16dadbc759bdea9266f0d3ca51c9d79bab83c815a6d8b73450cd1878f3a2e10cf26b1892304352b027bd7924c07ea1a28c31
|
7
|
+
data.tar.gz: 264d2812f22b99a85e83b65664d1d08380c1699384a21f3c144837f4a6449a5b3a05e3df3187b19082da4e6e51695dce23dc4e98f5463bb7361e34614286ff8d
|
data/CHANGELOG.md
CHANGED
data/README.rdoc
CHANGED
@@ -166,16 +166,30 @@ This helps prevent a rogue client from flooding a Request.
|
|
166
166
|
|
167
167
|
Default to 65536 characters (4 kiB in worst case).
|
168
168
|
|
169
|
-
===
|
169
|
+
=== multipart_file_limit
|
170
170
|
|
171
|
-
The maximum number of parts a request can contain.
|
171
|
+
The maximum number of parts with a filename a request can contain.
|
172
172
|
Accepting too many part can lead to the server running out of file handles.
|
173
173
|
|
174
174
|
The default is 128, which means that a single request can't upload more than 128 files at once.
|
175
175
|
|
176
176
|
Set to 0 for no limit.
|
177
177
|
|
178
|
-
Can also be set via the +
|
178
|
+
Can also be set via the +RACK_MULTIPART_FILE_LIMIT+ environment variable.
|
179
|
+
|
180
|
+
(This is also aliased as +multipart_part_limit+ and +RACK_MULTIPART_PART_LIMIT+ for compatibility)
|
181
|
+
|
182
|
+
=== multipart_total_part_limit
|
183
|
+
|
184
|
+
The maximum total number of parts a request can contain of any type, including
|
185
|
+
both file and non-file form fields.
|
186
|
+
|
187
|
+
The default is 4096, which means that a single request can't contain more than
|
188
|
+
4096 parts.
|
189
|
+
|
190
|
+
Set to 0 for no limit.
|
191
|
+
|
192
|
+
Can also be set via the +RACK_MULTIPART_TOTAL_PART_LIMIT+ environment variable.
|
179
193
|
|
180
194
|
== Changelog
|
181
195
|
|
@@ -7,6 +7,7 @@ require 'rack/core_ext/regexp'
|
|
7
7
|
module Rack
|
8
8
|
module Multipart
|
9
9
|
class MultipartPartLimitError < Errno::EMFILE; end
|
10
|
+
class MultipartTotalPartLimitError < StandardError; end
|
10
11
|
|
11
12
|
class Parser
|
12
13
|
using ::Rack::RegexpExtensions
|
@@ -148,7 +149,7 @@ module Rack
|
|
148
149
|
|
149
150
|
@mime_parts[mime_index] = klass.new(body, head, filename, content_type, name)
|
150
151
|
|
151
|
-
|
152
|
+
check_part_limits
|
152
153
|
end
|
153
154
|
|
154
155
|
def on_mime_body mime_index, content
|
@@ -160,13 +161,23 @@ module Rack
|
|
160
161
|
|
161
162
|
private
|
162
163
|
|
163
|
-
def
|
164
|
-
|
165
|
-
|
164
|
+
def check_part_limits
|
165
|
+
file_limit = Utils.multipart_file_limit
|
166
|
+
part_limit = Utils.multipart_total_part_limit
|
167
|
+
|
168
|
+
if file_limit && file_limit > 0
|
169
|
+
if @open_files >= file_limit
|
166
170
|
@mime_parts.each(&:close)
|
167
171
|
raise MultipartPartLimitError, 'Maximum file multiparts in content reached'
|
168
172
|
end
|
169
173
|
end
|
174
|
+
|
175
|
+
if part_limit && part_limit > 0
|
176
|
+
if @mime_parts.size >= part_limit
|
177
|
+
@mime_parts.each(&:close)
|
178
|
+
raise MultipartTotalPartLimitError, 'Maximum total multiparts in content reached'
|
179
|
+
end
|
180
|
+
end
|
170
181
|
end
|
171
182
|
end
|
172
183
|
|
data/lib/rack/utils.rb
CHANGED
@@ -59,13 +59,24 @@ module Rack
|
|
59
59
|
module_function :unescape
|
60
60
|
|
61
61
|
class << self
|
62
|
-
attr_accessor :
|
62
|
+
attr_accessor :multipart_total_part_limit
|
63
|
+
|
64
|
+
attr_accessor :multipart_file_limit
|
65
|
+
|
66
|
+
# multipart_part_limit is the original name of multipart_file_limit, but
|
67
|
+
# the limit only counts parts with filenames.
|
68
|
+
alias multipart_part_limit multipart_file_limit
|
69
|
+
alias multipart_part_limit= multipart_file_limit=
|
63
70
|
end
|
64
71
|
|
65
|
-
# The maximum number of parts a request can contain. Accepting too
|
66
|
-
# can lead to the server running out of file handles.
|
72
|
+
# The maximum number of file parts a request can contain. Accepting too
|
73
|
+
# many parts can lead to the server running out of file handles.
|
67
74
|
# Set to `0` for no limit.
|
68
|
-
self.
|
75
|
+
self.multipart_file_limit = (ENV['RACK_MULTIPART_PART_LIMIT'] || ENV['RACK_MULTIPART_FILE_LIMIT'] || 128).to_i
|
76
|
+
|
77
|
+
# The maximum total number of parts a request can contain. Accepting too
|
78
|
+
# many can lead to excessive memory use and parsing time.
|
79
|
+
self.multipart_total_part_limit = (ENV['RACK_MULTIPART_TOTAL_PART_LIMIT'] || 4096).to_i
|
69
80
|
|
70
81
|
def self.param_depth_limit
|
71
82
|
default_query_parser.param_depth_limit
|
data/lib/rack.rb
CHANGED
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: 2.1.4.
|
4
|
+
version: 2.1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.1
|
188
|
+
rubygems_version: 3.4.1
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: a modular Ruby webserver interface
|