actionpack 6.0.3.3 → 6.1.1

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