actionpack 6.0.3.4 → 6.1.2

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.

Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +274 -223
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/abstract_controller.rb +1 -0
  6. data/lib/abstract_controller/base.rb +35 -2
  7. data/lib/abstract_controller/callbacks.rb +2 -2
  8. data/lib/abstract_controller/helpers.rb +105 -90
  9. data/lib/abstract_controller/rendering.rb +9 -9
  10. data/lib/abstract_controller/translation.rb +8 -2
  11. data/lib/action_controller.rb +2 -3
  12. data/lib/action_controller/api.rb +2 -2
  13. data/lib/action_controller/base.rb +4 -2
  14. data/lib/action_controller/caching.rb +0 -1
  15. data/lib/action_controller/log_subscriber.rb +3 -3
  16. data/lib/action_controller/metal.rb +2 -2
  17. data/lib/action_controller/metal/conditional_get.rb +11 -3
  18. data/lib/action_controller/metal/content_security_policy.rb +1 -1
  19. data/lib/action_controller/metal/cookies.rb +3 -1
  20. data/lib/action_controller/metal/data_streaming.rb +1 -1
  21. data/lib/action_controller/metal/etag_with_template_digest.rb +2 -4
  22. data/lib/action_controller/metal/exceptions.rb +33 -0
  23. data/lib/action_controller/metal/head.rb +7 -4
  24. data/lib/action_controller/metal/helpers.rb +11 -1
  25. data/lib/action_controller/metal/http_authentication.rb +4 -2
  26. data/lib/action_controller/metal/implicit_render.rb +1 -1
  27. data/lib/action_controller/metal/instrumentation.rb +11 -9
  28. data/lib/action_controller/metal/live.rb +1 -1
  29. data/lib/action_controller/metal/logging.rb +20 -0
  30. data/lib/action_controller/metal/mime_responds.rb +6 -2
  31. data/lib/action_controller/metal/parameter_encoding.rb +35 -4
  32. data/lib/action_controller/metal/params_wrapper.rb +14 -8
  33. data/lib/action_controller/metal/permissions_policy.rb +46 -0
  34. data/lib/action_controller/metal/redirecting.rb +1 -1
  35. data/lib/action_controller/metal/rendering.rb +6 -0
  36. data/lib/action_controller/metal/request_forgery_protection.rb +48 -24
  37. data/lib/action_controller/metal/rescue.rb +1 -1
  38. data/lib/action_controller/metal/strong_parameters.rb +103 -15
  39. data/lib/action_controller/renderer.rb +24 -13
  40. data/lib/action_controller/test_case.rb +62 -56
  41. data/lib/action_dispatch.rb +3 -2
  42. data/lib/action_dispatch/http/cache.rb +12 -10
  43. data/lib/action_dispatch/http/content_disposition.rb +2 -2
  44. data/lib/action_dispatch/http/content_security_policy.rb +5 -1
  45. data/lib/action_dispatch/http/filter_parameters.rb +1 -1
  46. data/lib/action_dispatch/http/filter_redirect.rb +1 -1
  47. data/lib/action_dispatch/http/headers.rb +3 -2
  48. data/lib/action_dispatch/http/mime_negotiation.rb +20 -8
  49. data/lib/action_dispatch/http/mime_type.rb +28 -15
  50. data/lib/action_dispatch/http/parameters.rb +1 -19
  51. data/lib/action_dispatch/http/permissions_policy.rb +173 -0
  52. data/lib/action_dispatch/http/request.rb +26 -8
  53. data/lib/action_dispatch/http/response.rb +17 -16
  54. data/lib/action_dispatch/http/url.rb +3 -2
  55. data/lib/action_dispatch/journey.rb +0 -2
  56. data/lib/action_dispatch/journey/formatter.rb +53 -28
  57. data/lib/action_dispatch/journey/gtg/builder.rb +22 -36
  58. data/lib/action_dispatch/journey/gtg/simulator.rb +8 -7
  59. data/lib/action_dispatch/journey/gtg/transition_table.rb +6 -4
  60. data/lib/action_dispatch/journey/nfa/dot.rb +0 -11
  61. data/lib/action_dispatch/journey/nodes/node.rb +4 -3
  62. data/lib/action_dispatch/journey/parser.rb +13 -13
  63. data/lib/action_dispatch/journey/parser.y +1 -1
  64. data/lib/action_dispatch/journey/path/pattern.rb +13 -18
  65. data/lib/action_dispatch/journey/route.rb +7 -18
  66. data/lib/action_dispatch/journey/router.rb +26 -30
  67. data/lib/action_dispatch/journey/router/utils.rb +6 -4
  68. data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -2
  69. data/lib/action_dispatch/middleware/cookies.rb +74 -33
  70. data/lib/action_dispatch/middleware/debug_exceptions.rb +10 -17
  71. data/lib/action_dispatch/middleware/debug_view.rb +1 -1
  72. data/lib/action_dispatch/middleware/exception_wrapper.rb +29 -17
  73. data/lib/action_dispatch/middleware/host_authorization.rb +25 -5
  74. data/lib/action_dispatch/middleware/public_exceptions.rb +1 -1
  75. data/lib/action_dispatch/middleware/remote_ip.rb +5 -4
  76. data/lib/action_dispatch/middleware/request_id.rb +4 -5
  77. data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -2
  78. data/lib/action_dispatch/middleware/session/cookie_store.rb +2 -2
  79. data/lib/action_dispatch/middleware/show_exceptions.rb +2 -0
  80. data/lib/action_dispatch/middleware/ssl.rb +12 -7
  81. data/lib/action_dispatch/middleware/stack.rb +18 -0
  82. data/lib/action_dispatch/middleware/static.rb +154 -93
  83. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +22 -0
  84. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +2 -5
  85. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +2 -2
  86. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +2 -2
  87. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +100 -8
  88. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
  89. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +21 -1
  90. data/lib/action_dispatch/railtie.rb +3 -2
  91. data/lib/action_dispatch/request/session.rb +2 -8
  92. data/lib/action_dispatch/request/utils.rb +26 -2
  93. data/lib/action_dispatch/routing/inspector.rb +8 -7
  94. data/lib/action_dispatch/routing/mapper.rb +102 -71
  95. data/lib/action_dispatch/routing/polymorphic_routes.rb +12 -11
  96. data/lib/action_dispatch/routing/redirection.rb +3 -3
  97. data/lib/action_dispatch/routing/route_set.rb +49 -41
  98. data/lib/action_dispatch/routing/url_for.rb +1 -0
  99. data/lib/action_dispatch/system_test_case.rb +29 -24
  100. data/lib/action_dispatch/system_testing/browser.rb +33 -27
  101. data/lib/action_dispatch/system_testing/driver.rb +6 -7
  102. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +47 -6
  103. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +4 -7
  104. data/lib/action_dispatch/testing/assertions.rb +1 -1
  105. data/lib/action_dispatch/testing/assertions/response.rb +2 -4
  106. data/lib/action_dispatch/testing/assertions/routing.rb +5 -5
  107. data/lib/action_dispatch/testing/integration.rb +38 -27
  108. data/lib/action_dispatch/testing/test_process.rb +29 -4
  109. data/lib/action_dispatch/testing/test_request.rb +3 -3
  110. data/lib/action_pack.rb +1 -1
  111. data/lib/action_pack/gem_version.rb +3 -3
  112. metadata +18 -19
  113. data/lib/action_controller/metal/force_ssl.rb +0 -58
  114. data/lib/action_dispatch/http/parameter_filter.rb +0 -12
  115. data/lib/action_dispatch/journey/nfa/builder.rb +0 -78
  116. data/lib/action_dispatch/journey/nfa/simulator.rb +0 -47
  117. data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -119
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3767927eaf2709c272ca4da197a4e356dbd7d4fffaf78a10eb4f4f9ee5b0d0d
4
- data.tar.gz: cf187c693653a55c75afd103afc829422ea107936e03aabddb594ac52f6cfad8
3
+ metadata.gz: 3e18f4e0dba4fd1daa12ad504b7846ed7c35d319d793d8a999719c5f454a3a55
4
+ data.tar.gz: 34eca75e2ce98348b71a0138e46ff0bcbd3b2bd26888eff928c15cb5b20779a7
5
5
  SHA512:
6
- metadata.gz: 3b93fe304a8ec1ed90fc09a076fd54d6beee63fff8e7594e4b71c0c67b57515f0c53f9ac11435ca7f81940dd03b17a671f6b5d1065d2c063d6c40fe367a5808e
7
- data.tar.gz: ec62a4e0f89af114bfe4d00e88ca875fec9c2f68f81ee1fd27aef57629ea0e2680968b5a10d092813b054c55b4c654cf0b57dd029d4d55bfaf4fb1f3ba409176
6
+ metadata.gz: 73a46bd410d9b4d54b56d19c0f0ac5d47ac799566ba950af6bfeff17cdc370336cccd9c4b46ab8ab8dc9fca16d30b808193d496f05374f1dfd78fdd5b3b5753f
7
+ data.tar.gz: ce290325486805965e58919f0aabc7a702604a0495eb7028eb94be089b82ec9684eec54472842a72eabc9b79656f0012887cf217f82cf4ca0bf2e546634adadc
data/CHANGELOG.md CHANGED
@@ -1,386 +1,437 @@
1
- ## Rails 6.0.3.4 (October 07, 2020) ##
1
+ ## Rails 6.1.2 (February 09, 2021) ##
2
2
 
3
- * [CVE-2020-8264] Prevent XSS in Actionable Exceptions
3
+ * Fix error in `ActionController::LogSubscriber` that would happen when throwing inside a controller action.
4
4
 
5
+ *Janko Marohnić*
5
6
 
6
- ## Rails 6.0.3.3 (September 09, 2020) ##
7
-
8
- * No changes.
7
+ * Fix `fixture_file_upload` deprecation when `file_fixture_path` is a relative path.
9
8
 
9
+ *Eugene Kenny*
10
10
 
11
- ## Rails 6.0.3.2 (June 17, 2020) ##
12
11
 
13
- * [CVE-2020-8185] Only allow ActionableErrors if show_detailed_exceptions is enabled
12
+ ## Rails 6.1.1 (January 07, 2021) ##
14
13
 
15
- ## Rails 6.0.3.1 (May 18, 2020) ##
14
+ * Fix nil translation key lookup in controllers/
16
15
 
17
- * [CVE-2020-8166] HMAC raw CSRF token before masking it, so it cannot be used to reconstruct a per-form token
16
+ *Jan Klimo*
18
17
 
19
- * [CVE-2020-8164] Return self when calling #each, #each_pair, and #each_value instead of the raw @parameters hash
18
+ * Quietly handle unknown HTTP methods in Action Dispatch SSL middleware.
20
19
 
21
- ## Rails 6.0.3 (May 06, 2020) ##
20
+ *Alex Robbin*
22
21
 
23
- * Include child session assertion count in ActionDispatch::IntegrationTest
22
+ * Change the request method to a `GET` when passing failed requests down to `config.exceptions_app`.
24
23
 
25
- `IntegrationTest#open_session` uses `dup` to create the new session, which
26
- meant it had its own copy of `@assertions`. This prevented the assertions
27
- from being correctly counted and reported.
24
+ *Alex Robbin*
28
25
 
29
- Child sessions now have their `attr_accessor` overriden to delegate to the
30
- root session.
31
26
 
32
- Fixes #32142
27
+ ## Rails 6.1.0 (December 09, 2020) ##
33
28
 
34
- *Sam Bostock*
29
+ * Support for the HTTP header `Feature-Policy` has been revised to reflect
30
+ its [rename](https://github.com/w3c/webappsec-permissions-policy/pull/379) to [`Permissions-Policy`](https://w3c.github.io/webappsec-permissions-policy/#permissions-policy-http-header-field).
35
31
 
32
+ ```ruby
33
+ Rails.application.config.permissions_policy do |p|
34
+ p.camera :none
35
+ p.gyroscope :none
36
+ p.microphone :none
37
+ p.usb :none
38
+ p.fullscreen :self
39
+ p.payment :self, "https://secure-example.com"
40
+ end
41
+ ```
36
42
 
37
- ## Rails 6.0.2.2 (March 19, 2020) ##
43
+ *Julien Grillot*
38
44
 
39
- * No changes.
45
+ * Allow `ActionDispatch::HostAuthorization` to exclude specific requests.
40
46
 
47
+ Host Authorization checks can be skipped for specific requests. This allows for health check requests to be permitted for requests with missing or non-matching host headers.
41
48
 
42
- ## Rails 6.0.2.1 (December 18, 2019) ##
49
+ *Chris Bisnett*
43
50
 
44
- * Fix possible information leak / session hijacking vulnerability.
51
+ * Add `config.action_dispatch.request_id_header` to allow changing the name of
52
+ the unique X-Request-Id header
45
53
 
46
- The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
47
- gem dalli to be updated as well.
54
+ *Arlston Fernandes*
48
55
 
49
- CVE-2019-16782.
56
+ * Deprecate `config.action_dispatch.return_only_media_type_on_content_type`.
50
57
 
58
+ *Rafael Mendonça França*
51
59
 
52
- ## Rails 6.0.2 (December 13, 2019) ##
60
+ * Change `ActionDispatch::Response#content_type` to return the full Content-Type header.
53
61
 
54
- * Allow using mountable engine route helpers in System Tests.
62
+ *Rafael Mendonça França*
55
63
 
56
- *Chalo Fernandez*
64
+ * Remove deprecated `ActionDispatch::Http::ParameterFilter`.
57
65
 
66
+ *Rafael Mendonça França*
58
67
 
59
- ## Rails 6.0.1 (November 5, 2019) ##
68
+ * Added support for exclusive no-store Cache-Control header.
60
69
 
61
- * `ActionDispatch::SystemTestCase` now inherits from `ActiveSupport::TestCase`
62
- rather than `ActionDispatch::IntegrationTest`. This permits running jobs in
63
- system tests.
70
+ If `no-store` is set on Cache-Control header it is exclusive (all other cache directives are dropped).
64
71
 
65
- *George Claghorn*, *Edouard Chin*
72
+ *Chris Kruger*
66
73
 
67
- * Registered MIME types may contain extra flags:
74
+ * Catch invalid UTF-8 parameters for POST requests and respond with BadRequest.
68
75
 
69
- ```ruby
70
- Mime::Type.register "text/html; fragment", :html_fragment
71
- ```
76
+ Additionally, perform `#set_binary_encoding` in `ActionDispatch::Http::Request#GET` and
77
+ `ActionDispatch::Http::Request#POST` prior to validating encoding.
72
78
 
73
- *Aaron Patterson*
79
+ *Adrianna Chang*
74
80
 
81
+ * Allow `assert_recognizes` routing assertions to work on mounted root routes.
75
82
 
76
- ## Rails 6.0.0 (August 16, 2019) ##
83
+ *Gannon McGibbon*
77
84
 
78
- * No changes.
85
+ * Change default redirection status code for non-GET/HEAD requests to 308 Permanent Redirect for `ActionDispatch::SSL`.
79
86
 
87
+ *Alan Tan*, *Oz Ben-David*
80
88
 
81
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
89
+ * Fix `follow_redirect!` to follow redirection with same HTTP verb when following
90
+ a 308 redirection.
82
91
 
83
- * Add the ability to set the CSP nonce only to the specified directives.
92
+ *Alan Tan*
84
93
 
85
- Fixes #35137.
94
+ * When multiple domains are specified for a cookie, a domain will now be
95
+ chosen only if it is equal to or is a superdomain of the request host.
86
96
 
87
- *Yuji Yaginuma*
97
+ *Jonathan Hefner*
88
98
 
89
- * Keep part when scope option has value.
99
+ * `ActionDispatch::Static` handles precompiled Brotli (.br) files.
90
100
 
91
- When a route was defined within an optional scope, if that route didn't
92
- take parameters the scope was lost when using path helpers. This commit
93
- ensures scope is kept both when the route takes parameters or when it
94
- doesn't.
101
+ Adds to existing support for precompiled gzip (.gz) files.
102
+ Brotli files are preferred due to much better compression.
95
103
 
96
- Fixes #33219
104
+ When the browser requests /some.js with `Accept-Encoding: br`,
105
+ we check for public/some.js.br and serve that file, if present, with
106
+ `Content-Encoding: br` and `Vary: Accept-Encoding` headers.
97
107
 
98
- *Alberto Almagro*
108
+ *Ryan Edward Hall*, *Jeremy Daer*
99
109
 
100
- * Change `ActionDispatch::Response#content_type` to return Content-Type header as it is.
110
+ * Add raise_on_missing_translations support for controllers.
101
111
 
102
- Previously, `ActionDispatch::Response#content_type` returned value does NOT
103
- contain charset part. This behavior changed to returned Content-Type header
104
- containing charset part as it is.
112
+ This configuration determines whether an error should be raised for missing translations.
113
+ It can be enabled through `config.i18n.raise_on_missing_translations`. Note that described
114
+ configuration also affects raising error for missing translations in views.
105
115
 
106
- If you want just MIME type, please use `ActionDispatch::Response#media_type`
107
- instead.
116
+ *fatkodima*
108
117
 
109
- Enable `action_dispatch.return_only_media_type_on_content_type` to use this change.
110
- If not enabled, `ActionDispatch::Response#content_type` returns the same
111
- value as before version, but its behavior is deprecate.
118
+ * Added `compact` and `compact!` to `ActionController::Parameters`.
112
119
 
113
- *Yuji Yaginuma*
120
+ *Eugene Kenny*
114
121
 
115
- * Calling `ActionController::Parameters#transform_keys/!` without a block now returns
116
- an enumerator for the parameters instead of the underlying hash.
122
+ * Calling `each_pair` or `each_value` on an `ActionController::Parameters`
123
+ without passing a block now returns an enumerator.
117
124
 
118
125
  *Eugene Kenny*
119
126
 
120
- * Fix a bug where DebugExceptions throws an error when malformed query parameters are provided
127
+ * `fixture_file_upload` now uses path relative to `file_fixture_path`
121
128
 
122
- *Yuki Nishijima*, *Stan Lo*
129
+ Previously the path had to be relative to `fixture_path`.
130
+ You can change your existing code as follow:
123
131
 
132
+ ```ruby
133
+ # Before
134
+ fixture_file_upload('files/dog.png')
124
135
 
125
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
136
+ # After
137
+ fixture_file_upload('dog.png')
138
+ ```
126
139
 
127
- * Make system tests take a failed screenshot in a `before_teardown` hook
128
- rather than an `after_teardown` hook.
140
+ *Edouard Chin*
129
141
 
130
- This helps minimize the time gap between when an assertion fails and when
131
- the screenshot is taken (reducing the time in which the page could have
132
- been dynamically updated after the assertion failed).
142
+ * Remove deprecated `force_ssl` at the controller level.
133
143
 
134
- *Richard Macklin*
144
+ *Rafael Mendonça França*
135
145
 
136
- * Introduce `ActionDispatch::ActionableExceptions`.
146
+ * The +helper+ class method for controllers loads helper modules specified as
147
+ strings/symbols with `String#constantize` instead of `require_dependency`.
137
148
 
138
- The `ActionDispatch::ActionableExceptions` middleware dispatches actions
139
- from `ActiveSupport::ActionableError` descendants.
149
+ Remember that support for strings/symbols is only a convenient API. You can
150
+ always pass a module object:
140
151
 
141
- Actionable errors let's you dispatch actions from Rails' error pages.
152
+ ```ruby
153
+ helper UtilsHelper
154
+ ```
142
155
 
143
- *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
156
+ which is recommended because it is simple and direct. When a string/symbol
157
+ is received, `helper` just manipulates and inflects the argument to obtain
158
+ that same module object.
144
159
 
145
- * Raise an `ArgumentError` if a resource custom param contains a colon (`:`).
160
+ *Xavier Noria*, *Jean Boussier*
146
161
 
147
- After this change it's not possible anymore to configure routes like this:
162
+ * Correctly identify the entire localhost IPv4 range as trusted proxy.
148
163
 
149
- ```
150
- routes.draw do
151
- resources :users, param: 'name/:sneaky'
152
- end
153
- ```
164
+ *Nick Soracco*
154
165
 
155
- Fixes #30467.
166
+ * `url_for` will now use "https://" as the default protocol when
167
+ `Rails.application.config.force_ssl` is set to true.
156
168
 
157
- *Josua Schmid*
169
+ *Jonathan Hefner*
158
170
 
171
+ * Accept and default to base64_urlsafe CSRF tokens.
159
172
 
160
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
173
+ Base64 strict-encoded CSRF tokens are not inherently websafe, which makes
174
+ them difficult to deal with. For example, the common practice of sending
175
+ the CSRF token to a browser in a client-readable cookie does not work properly
176
+ out of the box: the value has to be url-encoded and decoded to survive transport.
161
177
 
162
- * No changes.
178
+ Now, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently safe
179
+ to transport. Validation accepts both urlsafe tokens, and strict-encoded tokens
180
+ for backwards compatibility.
163
181
 
182
+ *Scott Blum*
164
183
 
165
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
184
+ * Support rolling deploys for cookie serialization/encryption changes.
166
185
 
167
- * Make debug exceptions works in an environment where ActiveStorage is not loaded.
186
+ In a distributed configuration like rolling update, users may observe
187
+ both old and new instances during deployment. Users may be served by a
188
+ new instance and then by an old instance.
168
189
 
169
- *Tomoyuki Kurosawa*
190
+ That means when the server changes `cookies_serializer` from `:marshal`
191
+ to `:hybrid` or the server changes `use_authenticated_cookie_encryption`
192
+ from `false` to `true`, users may lose their sessions if they access the
193
+ server during deployment.
170
194
 
171
- * `ActionDispatch::SystemTestCase.driven_by` can now be called with a block
172
- to define specific browser capabilities.
195
+ We added fallbacks to downgrade the cookie format when necessary during
196
+ deployment, ensuring compatibility on both old and new instances.
173
197
 
174
- *Edouard Chin*
198
+ *Masaki Hara*
175
199
 
200
+ * `ActionDispatch::Request.remote_ip` has ip address even when all sites are trusted.
176
201
 
177
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
202
+ Before, if all `X-Forwarded-For` sites were trusted, the `remote_ip` would default to `127.0.0.1`.
203
+ Now, the furthest proxy site is used. e.g.: It now gives an ip address when using curl from the load balancer.
178
204
 
179
- * Remove deprecated `fragment_cache_key` helper in favor of `combined_fragment_cache_key`.
205
+ *Keenan Brock*
180
206
 
181
- *Rafael Mendonça França*
207
+ * Fix possible information leak / session hijacking vulnerability.
182
208
 
183
- * Remove deprecated methods in `ActionDispatch::TestResponse`.
209
+ The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
210
+ gem dalli to be updated as well.
184
211
 
185
- `#success?`, `missing?` and `error?` were deprecated in Rails 5.2 in favor of
186
- `#successful?`, `not_found?` and `server_error?`.
212
+ CVE-2019-16782.
187
213
 
188
- *Rafael Mendonça França*
214
+ * Include child session assertion count in ActionDispatch::IntegrationTest.
189
215
 
190
- * Introduce `ActionDispatch::HostAuthorization`.
216
+ `IntegrationTest#open_session` uses `dup` to create the new session, which
217
+ meant it had its own copy of `@assertions`. This prevented the assertions
218
+ from being correctly counted and reported.
191
219
 
192
- This is a new middleware that guards against DNS rebinding attacks by
193
- explicitly permitting the hosts a request can be made to.
220
+ Child sessions now have their `attr_accessor` overridden to delegate to the
221
+ root session.
194
222
 
195
- Each host is checked with the case operator (`#===`) to support `Regexp`,
196
- `Proc`, `IPAddr` and custom objects as host allowances.
223
+ Fixes #32142.
197
224
 
198
- *Genadi Samokovarov*
225
+ *Sam Bostock*
199
226
 
200
- * Allow using `parsed_body` in `ActionController::TestCase`.
227
+ * Add SameSite protection to every written cookie.
201
228
 
202
- In addition to `ActionDispatch::IntegrationTest`, allow using
203
- `parsed_body` in `ActionController::TestCase`:
229
+ Enabling `SameSite` cookie protection is an addition to CSRF protection,
230
+ where cookies won't be sent by browsers in cross-site POST requests when set to `:lax`.
204
231
 
205
- ```
206
- class SomeControllerTest < ActionController::TestCase
207
- def test_some_action
208
- post :action, body: { foo: 'bar' }
209
- assert_equal({ "foo" => "bar" }, response.parsed_body)
210
- end
211
- end
212
- ```
232
+ `:strict` disables cookies being sent in cross-site GET or POST requests.
213
233
 
214
- Fixes #34676.
234
+ Passing `:none` disables this protection and is the same as previous versions albeit a `; SameSite=None` is appended to the cookie.
215
235
 
216
- *Tobias Bühlmann*
236
+ See upgrade instructions in config/initializers/new_framework_defaults_6_1.rb.
217
237
 
218
- * Raise an error on root route naming conflicts.
238
+ More info [here](https://tools.ietf.org/html/draft-west-first-party-cookies-07)
219
239
 
220
- Raises an `ArgumentError` when multiple root routes are defined in the
221
- same context instead of assigning nil names to subsequent roots.
240
+ _NB: Technically already possible as Rack supports SameSite protection, this is to ensure it's applied to all cookies_
222
241
 
223
- *Gannon McGibbon*
242
+ *Cédric Fabianski*
224
243
 
225
- * Allow rescue from parameter parse errors:
244
+ * Bring back the feature that allows loading external route files from the router.
226
245
 
227
- ```
228
- rescue_from ActionDispatch::Http::Parameters::ParseError do
229
- head :unauthorized
246
+ This feature existed back in 2012 but got reverted with the incentive that
247
+ https://github.com/rails/routing_concerns was a better approach. Turned out
248
+ that this wasn't fully the case and loading external route files from the router
249
+ can be helpful for applications with a really large set of routes.
250
+ Without this feature, application needs to implement routes reloading
251
+ themselves and it's not straightforward.
252
+
253
+ ```ruby
254
+ # config/routes.rb
255
+
256
+ Rails.application.routes.draw do
257
+ draw(:admin)
230
258
  end
259
+
260
+ # config/routes/admin.rb
261
+
262
+ get :foo, to: 'foo#bar'
231
263
  ```
232
264
 
233
- *Gannon McGibbon*, *Josh Cheek*
265
+ *Yehuda Katz*, *Edouard Chin*
234
266
 
235
- * Reset Capybara sessions if failed system test screenshot raising an exception.
267
+ * Fix system test driver option initialization for non-headless browsers.
236
268
 
237
- Reset Capybara sessions if `take_failed_screenshot` raise exception
238
- in system test `after_teardown`.
269
+ *glaszig*
239
270
 
240
- *Maxim Perepelitsa*
271
+ * `redirect_to.action_controller` notifications now include the `ActionDispatch::Request` in
272
+ their payloads as `:request`.
241
273
 
242
- * Use request object for context if there's no controller
274
+ *Austin Story*
243
275
 
244
- There is no controller instance when using a redirect route or a
245
- mounted rack application so pass the request object as the context
246
- when resolving dynamic CSP sources in this scenario.
276
+ * `respond_to#any` no longer returns a response's Content-Type based on the
277
+ request format but based on the block given.
247
278
 
248
- Fixes #34200.
279
+ Example:
249
280
 
250
- *Andrew White*
281
+ ```ruby
282
+ def my_action
283
+ respond_to do |format|
284
+ format.any { render(json: { foo: 'bar' }) }
285
+ end
286
+ end
251
287
 
252
- * Apply mapping to symbols returned from dynamic CSP sources
288
+ get('my_action.csv')
289
+ ```
253
290
 
254
- Previously if a dynamic source returned a symbol such as :self it
255
- would be converted to a string implicitly, e.g:
291
+ The previous behaviour was to respond with a `text/csv` Content-Type which
292
+ is inaccurate since a JSON response is being rendered.
256
293
 
257
- policy.default_src -> { :self }
294
+ Now it correctly returns a `application/json` Content-Type.
258
295
 
259
- would generate the header:
296
+ *Edouard Chin*
260
297
 
261
- Content-Security-Policy: default-src self
298
+ * Replaces (back)slashes in failure screenshot image paths with dashes.
262
299
 
263
- and now it generates:
300
+ If a failed test case contained a slash or a backslash, a screenshot would be created in a
301
+ nested directory, causing issues with `tmp:clear`.
264
302
 
265
- Content-Security-Policy: default-src 'self'
303
+ *Damir Zekic*
266
304
 
267
- *Andrew White*
305
+ * Add `params.member?` to mimic Hash behavior.
268
306
 
269
- * Add `ActionController::Parameters#each_value`.
307
+ *Younes Serraj*
270
308
 
271
- *Lukáš Zapletal*
309
+ * `process_action.action_controller` notifications now include the following in their payloads:
272
310
 
273
- * Deprecate `ActionDispatch::Http::ParameterFilter` in favor of `ActiveSupport::ParameterFilter`.
311
+ * `:request` - the `ActionDispatch::Request`
312
+ * `:response` - the `ActionDispatch::Response`
274
313
 
275
- *Yoshiyuki Kinjo*
314
+ *George Claghorn*
276
315
 
277
- * Encode Content-Disposition filenames on `send_data` and `send_file`.
278
- Previously, `send_data 'data', filename: "\u{3042}.txt"` sends
279
- `"filename=\"\u{3042}.txt\""` as Content-Disposition and it can be
280
- garbled.
281
- Now it follows [RFC 2231](https://tools.ietf.org/html/rfc2231) and
282
- [RFC 5987](https://tools.ietf.org/html/rfc5987) and sends
283
- `"filename=\"%3F.txt\"; filename*=UTF-8''%E3%81%82.txt"`.
284
- Most browsers can find filename correctly and old browsers fallback to ASCII
285
- converted name.
316
+ * Updated `ActionDispatch::Request.remote_ip` setter to clear set the instance
317
+ `remote_ip` to `nil` before setting the header that the value is derived
318
+ from.
286
319
 
287
- *Fumiaki Matsushima*
320
+ Fixes #37383.
288
321
 
289
- * Expose `ActionController::Parameters#each_key` which allows iterating over
290
- keys without allocating an array.
322
+ *Norm Provost*
291
323
 
292
- *Richard Schneeman*
324
+ * `ActionController::Base.log_at` allows setting a different log level per request.
293
325
 
294
- * Purpose metadata for signed/encrypted cookies.
326
+ ```ruby
327
+ # Use the debug level if a particular cookie is set.
328
+ class ApplicationController < ActionController::Base
329
+ log_at :debug, if: -> { cookies[:debug] }
330
+ end
331
+ ```
295
332
 
296
- Rails can now thwart attacks that attempt to copy signed/encrypted value
297
- of a cookie and use it as the value of another cookie.
333
+ *George Claghorn*
298
334
 
299
- It does so by stashing the cookie-name in the purpose field which is
300
- then signed/encrypted along with the cookie value. Then, on a server-side
301
- read, we verify the cookie-names and discard any attacked cookies.
335
+ * Allow system test screen shots to be taken more than once in
336
+ a test by prefixing the file name with an incrementing counter.
302
337
 
303
- Enable `action_dispatch.use_cookies_with_metadata` to use this feature, which
304
- writes cookies with the new purpose and expiry metadata embedded.
338
+ Add an environment variable `RAILS_SYSTEM_TESTING_SCREENSHOT_HTML` to
339
+ enable saving of HTML during a screenshot in addition to the image.
340
+ This uses the same image name, with the extension replaced with `.html`
305
341
 
306
- *Assain Jaleel*
342
+ *Tom Fakes*
307
343
 
308
- * Raises `ActionController::RespondToMismatchError` with conflicting `respond_to` invocations.
344
+ * Add `Vary: Accept` header when using `Accept` header for response.
309
345
 
310
- `respond_to` can match multiple types and lead to undefined behavior when
311
- multiple invocations are made and the types do not match:
346
+ For some requests like `/users/1`, Rails uses requests' `Accept`
347
+ header to determine what to return. And if we don't add `Vary`
348
+ in the response header, browsers might accidentally cache different
349
+ types of content, which would cause issues: e.g. javascript got displayed
350
+ instead of html content. This PR fixes these issues by adding `Vary: Accept`
351
+ in these types of requests. For more detailed problem description, please read:
312
352
 
313
- respond_to do |outer_type|
314
- outer_type.js do
315
- respond_to do |inner_type|
316
- inner_type.html { render body: "HTML" }
317
- end
318
- end
319
- end
353
+ https://github.com/rails/rails/pull/36213
320
354
 
321
- *Patrick Toomey*
355
+ Fixes #25842.
322
356
 
323
- * `ActionDispatch::Http::UploadedFile` now delegates `to_path` to its tempfile.
357
+ *Stan Lo*
324
358
 
325
- This allows uploaded file objects to be passed directly to `File.read`
326
- without raising a `TypeError`:
359
+ * Fix IntegrationTest `follow_redirect!` to follow redirection using the same HTTP verb when following
360
+ a 307 redirection.
327
361
 
328
- uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file)
329
- File.read(uploaded_file)
362
+ *Edouard Chin*
330
363
 
331
- *Aaron Kromer*
364
+ * System tests require Capybara 3.26 or newer.
332
365
 
333
- * Pass along arguments to underlying `get` method in `follow_redirect!`
366
+ *George Claghorn*
334
367
 
335
- Now all arguments passed to `follow_redirect!` are passed to the underlying
336
- `get` method. This for example allows to set custom headers for the
337
- redirection request to the server.
368
+ * Reduced log noise handling ActionController::RoutingErrors.
338
369
 
339
- follow_redirect!(params: { foo: :bar })
370
+ *Alberto Fernández-Capel*
340
371
 
341
- *Remo Fritzsche*
372
+ * Add DSL for configuring HTTP Feature Policy.
342
373
 
343
- * Introduce a new error page to when the implicit render page is accessed in the browser.
374
+ This new DSL provides a way to configure an HTTP Feature Policy at a
375
+ global or per-controller level. Full details of HTTP Feature Policy
376
+ specification and guidelines can be found at MDN:
344
377
 
345
- Now instead of showing an error page that with exception and backtraces we now show only
346
- one informative page.
378
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
347
379
 
348
- *Vinicius Stock*
380
+ Example global policy:
349
381
 
350
- * Introduce `ActionDispatch::DebugExceptions.register_interceptor`.
382
+ ```ruby
383
+ Rails.application.config.feature_policy do |f|
384
+ f.camera :none
385
+ f.gyroscope :none
386
+ f.microphone :none
387
+ f.usb :none
388
+ f.fullscreen :self
389
+ f.payment :self, "https://secure.example.com"
390
+ end
391
+ ```
351
392
 
352
- Exception aware plugin authors can use the newly introduced
353
- `.register_interceptor` method to get the processed exception, instead of
354
- monkey patching DebugExceptions.
393
+ Example controller level policy:
355
394
 
356
- ActionDispatch::DebugExceptions.register_interceptor do |request, exception|
357
- HypoteticalPlugin.capture_exception(request, exception)
358
- end
395
+ ```ruby
396
+ class PagesController < ApplicationController
397
+ feature_policy do |p|
398
+ p.geolocation "https://example.com"
399
+ end
400
+ end
401
+ ```
359
402
 
360
- *Genadi Samokovarov*
403
+ *Jacob Bednarz*
361
404
 
362
- * Output only one Content-Security-Policy nonce header value per request.
405
+ * Add the ability to set the CSP nonce only to the specified directives.
363
406
 
364
- Fixes #32597.
407
+ Fixes #35137.
365
408
 
366
- *Andrey Novikov*, *Andrew White*
409
+ *Yuji Yaginuma*
367
410
 
368
- * Move default headers configuration into their own module that can be included in controllers.
411
+ * Keep part when scope option has value.
369
412
 
370
- *Kevin Deisz*
413
+ When a route was defined within an optional scope, if that route didn't
414
+ take parameters the scope was lost when using path helpers. This commit
415
+ ensures scope is kept both when the route takes parameters or when it
416
+ doesn't.
371
417
 
372
- * Add method `dig` to `session`.
418
+ Fixes #33219.
373
419
 
374
- *claudiob*, *Takumi Shotoku*
420
+ *Alberto Almagro*
421
+
422
+ * Added `deep_transform_keys` and `deep_transform_keys!` methods to ActionController::Parameters.
375
423
 
376
- * Controller level `force_ssl` has been deprecated in favor of
377
- `config.force_ssl`.
424
+ *Gustavo Gutierrez*
378
425
 
379
- *Derek Prior*
426
+ * Calling `ActionController::Parameters#transform_keys`/`!` without a block now returns
427
+ an enumerator for the parameters instead of the underlying hash.
428
+
429
+ *Eugene Kenny*
380
430
 
381
- * Rails 6 requires Ruby 2.5.0 or newer.
431
+ * Fix strong parameters blocks all attributes even when only some keys are invalid (non-numerical).
432
+ It should only block invalid key's values instead.
382
433
 
383
- *Jeremy Daer*, *Kasper Timm Hansen*
434
+ *Stan Lo*
384
435
 
385
436
 
386
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionpack/CHANGELOG.md) for previous changes.
437
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionpack/CHANGELOG.md) for previous changes.