actionpack 6.0.4 → 6.1.0.rc1

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