actionpack 6.1.3.2 → 6.1.4.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cfba18fd1e2c6507de318e22c9cab8f878c22b9cbce70065f9c2ff9053f1d96
4
- data.tar.gz: 178c4347f79392aaa6d452c3eeb406cbecf66a9b3ece0d244f98d7a4fa15b6ab
3
+ metadata.gz: c4f96dedfeb45e9898fe25e2383c8d0641b5fb7b98e7e895c9a4900fc7c68d57
4
+ data.tar.gz: 9b80b457cefe5a494ae84ea5dd14c429e3f072014ad8370ab45be040a8e642c3
5
5
  SHA512:
6
- metadata.gz: 6479340989a0677d3e64e0723a67c0cc64ea4dc9d5fcfe6bfad6538703582f3b95bc2426b68c56c2dda3a1b66842e7ed890b70fefbf136c8a198d23336525447
7
- data.tar.gz: 9021e02a953bf859d984e3722561745d0b562292b3fe3566ee1d362a9eb8c06af868f2d17db7dd5558e31871f626a39d8d9a7bb9b34697c5d26b8b58a533db4f
6
+ metadata.gz: e894d8ff3debdb9c577f3eaea0a93529c4d80c0710d9aa25d79c4ddf0a1c10cdda2130ef8eb06c4cd5a924ea283d36418de9e9f5bfbbb688dae110db4a5835d3
7
+ data.tar.gz: 5949504ae1fc94cea643ebbe0b52aeac410d92d6685b8abc18cd59a5016b2083927eeba539ae88eae46c088cf66a3d294b860f15cb36dc12928dc44d1bb53603
data/CHANGELOG.md CHANGED
@@ -1,3 +1,82 @@
1
+ ## Rails 6.1.4.7 (March 08, 2022) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.1.4.6 (February 11, 2022) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 6.1.4.5 (February 11, 2022) ##
12
+
13
+ * Under certain circumstances, the middleware isn't informed that the
14
+ response body has been fully closed which result in request state not
15
+ being fully reset before the next request
16
+
17
+ [CVE-2022-23633]
18
+
19
+
20
+ ## Rails 6.1.4.4 (December 15, 2021) ##
21
+
22
+ * Fix issue with host protection not allowing host with port in development.
23
+
24
+
25
+ ## Rails 6.1.4.3 (December 14, 2021) ##
26
+
27
+ * Fix issue with host protection not allowing localhost in development.
28
+
29
+
30
+ ## Rails 6.1.4.2 (December 14, 2021) ##
31
+
32
+ * Fix X_FORWARDED_HOST protection. [CVE-2021-44528]
33
+
34
+ ## Rails 6.1.4.1 (August 19, 2021) ##
35
+
36
+ * [CVE-2021-22942] Fix possible open redirect in Host Authorization middleware.
37
+
38
+ Specially crafted "X-Forwarded-Host" headers in combination with certain
39
+ "allowed host" formats can cause the Host Authorization middleware in Action
40
+ Pack to redirect users to a malicious website.
41
+
42
+ ## Rails 6.1.4 (June 24, 2021) ##
43
+
44
+ * Ignore file fixtures on `db:fixtures:load`
45
+
46
+ *Kevin Sjöberg*
47
+
48
+ * Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
49
+
50
+ *Dylan Thacker-Smith*
51
+
52
+ * Correctly place optional path parameter booleans.
53
+
54
+ Previously, if you specify a url parameter that is part of the path as false it would include that part
55
+ of the path as parameter for example:
56
+
57
+ ```
58
+ get "(/optional/:optional_id)/things" => "foo#foo", as: :things
59
+ things_path(optional_id: false) # => /things?optional_id=false
60
+ ```
61
+
62
+ After this change, true and false will be treated the same when used as optional path parameters. Meaning now:
63
+
64
+ ```
65
+ get '(this/:my_bool)/that' as: :that
66
+
67
+ that_path(my_bool: true) # => `/this/true/that`
68
+ that_path(my_bool: false) # => `/this/false/that`
69
+ ```
70
+
71
+ *Adam Hess*
72
+
73
+ * Add support for 'private, no-store' Cache-Control headers.
74
+
75
+ Previously, 'no-store' was exclusive; no other directives could be specified.
76
+
77
+ *Alex Smith*
78
+
79
+
1
80
  ## Rails 6.1.3.2 (May 05, 2021) ##
2
81
 
3
82
  * Prevent open redirects by correctly escaping the host allow list
@@ -44,7 +44,7 @@ module ActionController
44
44
  # template digest from the ETag.
45
45
  def pick_template_for_etag(options)
46
46
  unless options[:template] == false
47
- options[:template] || "#{controller_path}/#{action_name}"
47
+ options[:template] || lookup_context.find_all(action_name, _prefixes).first&.virtual_path
48
48
  end
49
49
  end
50
50
 
@@ -127,6 +127,11 @@ module ActionController
127
127
  class Buffer < ActionDispatch::Response::Buffer #:nodoc:
128
128
  include MonitorMixin
129
129
 
130
+ class << self
131
+ attr_accessor :queue_size
132
+ end
133
+ @queue_size = 10
134
+
130
135
  # Ignore that the client has disconnected.
131
136
  #
132
137
  # If this value is `true`, calling `write` after the client
@@ -136,7 +141,7 @@ module ActionController
136
141
  attr_accessor :ignore_disconnect
137
142
 
138
143
  def initialize(response)
139
- super(response, SizedQueue.new(10))
144
+ super(response, build_queue(self.class.queue_size))
140
145
  @error_callback = lambda { true }
141
146
  @cv = new_cond
142
147
  @aborted = false
@@ -214,6 +219,10 @@ module ActionController
214
219
  yield str
215
220
  end
216
221
  end
222
+
223
+ def build_queue(queue_size)
224
+ queue_size ? SizedQueue.new(queue_size) : Queue.new
225
+ end
217
226
  end
218
227
 
219
228
  class Response < ActionDispatch::Response #:nodoc: all
@@ -281,7 +281,10 @@ module ActionController
281
281
  return false unless request.has_content_type?
282
282
 
283
283
  ref = request.content_mime_type.ref
284
+
284
285
  _wrapper_formats.include?(ref) && _wrapper_key && !request.parameters.key?(_wrapper_key)
286
+ rescue ActionDispatch::Http::Parameters::ParseError
287
+ false
285
288
  end
286
289
 
287
290
  def _perform_parameter_wrapping
@@ -295,8 +298,6 @@ module ActionController
295
298
 
296
299
  # This will display the wrapped hash in the log file.
297
300
  request.filtered_parameters.merge! wrapped_filtered_hash
298
- rescue ActionDispatch::Http::Parameters::ParseError
299
- # swallow parse error exception
300
301
  end
301
302
  end
302
303
  end
@@ -24,6 +24,9 @@ module ActionController
24
24
  def new_controller_thread # :nodoc:
25
25
  yield
26
26
  end
27
+
28
+ # Avoid a deadlock from the queue filling up
29
+ Buffer.queue_size = nil
27
30
  end
28
31
 
29
32
  # ActionController::TestCase will be deprecated and moved to a gem in the future.
@@ -195,31 +195,30 @@ module ActionDispatch
195
195
 
196
196
  control.merge! cache_control
197
197
 
198
+ options = []
199
+
198
200
  if control[:no_store]
199
- self._cache_control = NO_STORE
201
+ options << PRIVATE if control[:private]
202
+ options << NO_STORE
200
203
  elsif control[:no_cache]
201
- options = []
202
204
  options << PUBLIC if control[:public]
203
205
  options << NO_CACHE
204
206
  options.concat(control[:extras]) if control[:extras]
205
-
206
- self._cache_control = options.join(", ")
207
207
  else
208
208
  extras = control[:extras]
209
209
  max_age = control[:max_age]
210
210
  stale_while_revalidate = control[:stale_while_revalidate]
211
211
  stale_if_error = control[:stale_if_error]
212
212
 
213
- options = []
214
213
  options << "max-age=#{max_age.to_i}" if max_age
215
214
  options << (control[:public] ? PUBLIC : PRIVATE)
216
215
  options << MUST_REVALIDATE if control[:must_revalidate]
217
216
  options << "stale-while-revalidate=#{stale_while_revalidate.to_i}" if stale_while_revalidate
218
217
  options << "stale-if-error=#{stale_if_error.to_i}" if stale_if_error
219
218
  options.concat(extras) if extras
220
-
221
- self._cache_control = options.join(", ")
222
219
  end
220
+
221
+ self._cache_control = options.join(", ")
223
222
  end
224
223
  end
225
224
  end
@@ -103,7 +103,7 @@ module ActionDispatch
103
103
  parameterized_parts = recall.merge(options)
104
104
 
105
105
  keys_to_keep = route.parts.reverse_each.drop_while { |part|
106
- !(options.key?(part) || route.scope_options.key?(part)) || (options[part] || recall[part]).nil?
106
+ !(options.key?(part) || route.scope_options.key?(part)) || (options[part].nil? && recall[part].nil?)
107
107
  } | route.required_parts
108
108
 
109
109
  parameterized_parts.delete_if do |bad_key, _|
@@ -118,7 +118,7 @@ module ActionDispatch
118
118
  end
119
119
  end
120
120
 
121
- parameterized_parts.keep_if { |_, v| v }
121
+ parameterized_parts.compact!
122
122
  parameterized_parts
123
123
  end
124
124
 
@@ -40,7 +40,7 @@ module ActionDispatch
40
40
  @parameters.each do |index|
41
41
  param = parts[index]
42
42
  value = hash[param.name]
43
- return "" unless value
43
+ return "" if value.nil?
44
44
  parts[index] = param.escape value
45
45
  end
46
46
 
@@ -9,7 +9,7 @@ module ActionDispatch
9
9
  end
10
10
 
11
11
  def call(env)
12
- state = @executor.run!
12
+ state = @executor.run!(reset: true)
13
13
  begin
14
14
  response = @app.call(env)
15
15
  returned = response << ::Rack::BodyProxy.new(response.pop) { state.complete! }
@@ -15,6 +15,17 @@ module ActionDispatch
15
15
  # application will be executed and rendered. If no +response_app+ is given, a
16
16
  # default one will run, which responds with <tt>403 Forbidden</tt>.
17
17
  class HostAuthorization
18
+ ALLOWED_HOSTS_IN_DEVELOPMENT = [".localhost", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")]
19
+ PORT_REGEX = /(?::\d+)/ # :nodoc:
20
+ IPV4_HOSTNAME = /(?<host>\d+\.\d+\.\d+\.\d+)#{PORT_REGEX}?/ # :nodoc:
21
+ IPV6_HOSTNAME = /(?<host>[a-f0-9]*:[a-f0-9.:]+)/i # :nodoc:
22
+ IPV6_HOSTNAME_WITH_PORT = /\[#{IPV6_HOSTNAME}\]#{PORT_REGEX}/i # :nodoc:
23
+ VALID_IP_HOSTNAME = Regexp.union( # :nodoc:
24
+ /\A#{IPV4_HOSTNAME}\z/,
25
+ /\A#{IPV6_HOSTNAME}\z/,
26
+ /\A#{IPV6_HOSTNAME_WITH_PORT}\z/,
27
+ )
28
+
18
29
  class Permissions # :nodoc:
19
30
  def initialize(hosts)
20
31
  @hosts = sanitize_hosts(hosts)
@@ -26,11 +37,17 @@ module ActionDispatch
26
37
 
27
38
  def allows?(host)
28
39
  @hosts.any? do |allowed|
29
- allowed === host
30
- rescue
31
- # IPAddr#=== raises an error if you give it a hostname instead of
32
- # IP. Treat similar errors as blocked access.
33
- false
40
+ if allowed.is_a?(IPAddr)
41
+ begin
42
+ allowed === extract_hostname(host)
43
+ rescue
44
+ # IPAddr#=== raises an error if you give it a hostname instead of
45
+ # IP. Treat similar errors as blocked access.
46
+ false
47
+ end
48
+ else
49
+ allowed === host
50
+ end
34
51
  end
35
52
  end
36
53
 
@@ -46,16 +63,20 @@ module ActionDispatch
46
63
  end
47
64
 
48
65
  def sanitize_regexp(host)
49
- /\A#{host}\z/
66
+ /\A#{host}#{PORT_REGEX}?\z/
50
67
  end
51
68
 
52
69
  def sanitize_string(host)
53
70
  if host.start_with?(".")
54
- /\A(.+\.)?#{Regexp.escape(host[1..-1])}\z/i
71
+ /\A([a-z0-9-]+\.)?#{Regexp.escape(host[1..-1])}#{PORT_REGEX}?\z/i
55
72
  else
56
- /\A#{Regexp.escape host}\z/i
73
+ /\A#{Regexp.escape host}#{PORT_REGEX}?\z/i
57
74
  end
58
75
  end
76
+
77
+ def extract_hostname(host)
78
+ host.slice(VALID_IP_HOSTNAME, "host") || host
79
+ end
59
80
  end
60
81
 
61
82
  DEFAULT_RESPONSE_APP = -> env do
@@ -103,20 +124,10 @@ module ActionDispatch
103
124
 
104
125
  private
105
126
  def authorized?(request)
106
- valid_host = /
107
- \A
108
- (?<host>[a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])
109
- (:\d+)?
110
- \z
111
- /x
112
-
113
- origin_host = valid_host.match(
114
- request.get_header("HTTP_HOST").to_s.downcase)
115
- forwarded_host = valid_host.match(
116
- request.x_forwarded_host.to_s.split(/,\s?/).last)
117
-
118
- origin_host && @permissions.allows?(origin_host[:host]) && (
119
- forwarded_host.nil? || @permissions.allows?(forwarded_host[:host]))
127
+ origin_host = request.get_header("HTTP_HOST")
128
+ forwarded_host = request.x_forwarded_host&.split(/,\s?/)&.last
129
+
130
+ @permissions.allows?(origin_host) && (forwarded_host.blank? || @permissions.allows?(forwarded_host))
120
131
  end
121
132
 
122
133
  def excluded?(request)
@@ -6,6 +6,7 @@
6
6
  <%= @exception.message %>
7
7
  <% if defined?(ActiveStorage) && @exception.message.match?(%r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}}) %>
8
8
  To resolve this issue run: bin/rails active_storage:install
9
+ <% end %>
9
10
  <% if defined?(ActionMailbox) && @exception.message.match?(%r{#{ActionMailbox::InboundEmail.table_name}}) %>
10
11
  To resolve this issue run: bin/rails action_mailbox:install
11
12
  <% end %>
@@ -9,8 +9,8 @@ module ActionPack
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 3
13
- PRE = "2"
12
+ TINY = 4
13
+ PRE = "7"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.3.2
4
+ version: 6.1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.1.3.2
19
+ version: 6.1.4.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.1.3.2
26
+ version: 6.1.4.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 6.1.3.2
101
+ version: 6.1.4.7
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 6.1.3.2
108
+ version: 6.1.4.7
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 6.1.3.2
115
+ version: 6.1.4.7
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 6.1.3.2
122
+ version: 6.1.4.7
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -309,10 +309,10 @@ licenses:
309
309
  - MIT
310
310
  metadata:
311
311
  bug_tracker_uri: https://github.com/rails/rails/issues
312
- changelog_uri: https://github.com/rails/rails/blob/v6.1.3.2/actionpack/CHANGELOG.md
313
- documentation_uri: https://api.rubyonrails.org/v6.1.3.2/
312
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.4.7/actionpack/CHANGELOG.md
313
+ documentation_uri: https://api.rubyonrails.org/v6.1.4.7/
314
314
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
315
- source_code_uri: https://github.com/rails/rails/tree/v6.1.3.2/actionpack
315
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.4.7/actionpack
316
316
  post_install_message:
317
317
  rdoc_options: []
318
318
  require_paths:
@@ -329,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  version: '0'
330
330
  requirements:
331
331
  - none
332
- rubygems_version: 3.1.2
332
+ rubygems_version: 3.1.6
333
333
  signing_key:
334
334
  specification_version: 4
335
335
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).