actionpack 5.2.8.1 → 6.0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +274 -346
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/abstract_controller/base.rb +4 -3
  6. data/lib/abstract_controller/caching/fragments.rb +6 -22
  7. data/lib/abstract_controller/caching.rb +1 -1
  8. data/lib/abstract_controller/callbacks.rb +12 -0
  9. data/lib/abstract_controller/collector.rb +1 -2
  10. data/lib/abstract_controller/helpers.rb +7 -6
  11. data/lib/abstract_controller/railties/routes_helpers.rb +1 -1
  12. data/lib/abstract_controller/translation.rb +4 -4
  13. data/lib/action_controller/api.rb +2 -1
  14. data/lib/action_controller/base.rb +2 -7
  15. data/lib/action_controller/caching.rb +1 -2
  16. data/lib/action_controller/log_subscriber.rb +8 -5
  17. data/lib/action_controller/metal/basic_implicit_render.rb +1 -1
  18. data/lib/action_controller/metal/conditional_get.rb +9 -3
  19. data/lib/action_controller/metal/content_security_policy.rb +0 -1
  20. data/lib/action_controller/metal/data_streaming.rb +5 -6
  21. data/lib/action_controller/metal/default_headers.rb +17 -0
  22. data/lib/action_controller/metal/etag_with_template_digest.rb +1 -1
  23. data/lib/action_controller/metal/exceptions.rb +23 -2
  24. data/lib/action_controller/metal/flash.rb +5 -5
  25. data/lib/action_controller/metal/force_ssl.rb +15 -56
  26. data/lib/action_controller/metal/head.rb +1 -1
  27. data/lib/action_controller/metal/helpers.rb +3 -4
  28. data/lib/action_controller/metal/http_authentication.rb +20 -21
  29. data/lib/action_controller/metal/implicit_render.rb +4 -14
  30. data/lib/action_controller/metal/instrumentation.rb +3 -6
  31. data/lib/action_controller/metal/live.rb +29 -31
  32. data/lib/action_controller/metal/mime_responds.rb +13 -2
  33. data/lib/action_controller/metal/params_wrapper.rb +18 -14
  34. data/lib/action_controller/metal/redirecting.rb +5 -5
  35. data/lib/action_controller/metal/renderers.rb +4 -4
  36. data/lib/action_controller/metal/rendering.rb +2 -3
  37. data/lib/action_controller/metal/request_forgery_protection.rb +25 -48
  38. data/lib/action_controller/metal/streaming.rb +0 -1
  39. data/lib/action_controller/metal/strong_parameters.rb +65 -44
  40. data/lib/action_controller/metal/url_for.rb +1 -1
  41. data/lib/action_controller/metal.rb +8 -6
  42. data/lib/action_controller/railties/helpers.rb +1 -1
  43. data/lib/action_controller/renderer.rb +17 -3
  44. data/lib/action_controller/template_assertions.rb +1 -1
  45. data/lib/action_controller/test_case.rb +7 -8
  46. data/lib/action_controller.rb +5 -1
  47. data/lib/action_dispatch/http/cache.rb +14 -11
  48. data/lib/action_dispatch/http/content_disposition.rb +45 -0
  49. data/lib/action_dispatch/http/content_security_policy.rb +28 -17
  50. data/lib/action_dispatch/http/filter_parameters.rb +8 -7
  51. data/lib/action_dispatch/http/filter_redirect.rb +1 -2
  52. data/lib/action_dispatch/http/headers.rb +1 -2
  53. data/lib/action_dispatch/http/mime_negotiation.rb +13 -6
  54. data/lib/action_dispatch/http/mime_type.rb +14 -8
  55. data/lib/action_dispatch/http/parameter_filter.rb +5 -79
  56. data/lib/action_dispatch/http/parameters.rb +15 -6
  57. data/lib/action_dispatch/http/request.rb +21 -14
  58. data/lib/action_dispatch/http/response.rb +40 -21
  59. data/lib/action_dispatch/http/upload.rb +9 -1
  60. data/lib/action_dispatch/http/url.rb +81 -82
  61. data/lib/action_dispatch/journey/formatter.rb +2 -3
  62. data/lib/action_dispatch/journey/gtg/builder.rb +0 -1
  63. data/lib/action_dispatch/journey/gtg/transition_table.rb +0 -1
  64. data/lib/action_dispatch/journey/nfa/simulator.rb +0 -2
  65. data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -1
  66. data/lib/action_dispatch/journey/nodes/node.rb +9 -8
  67. data/lib/action_dispatch/journey/path/pattern.rb +6 -3
  68. data/lib/action_dispatch/journey/route.rb +5 -4
  69. data/lib/action_dispatch/journey/router/utils.rb +10 -10
  70. data/lib/action_dispatch/journey/router.rb +0 -4
  71. data/lib/action_dispatch/journey/routes.rb +0 -2
  72. data/lib/action_dispatch/journey/scanner.rb +10 -4
  73. data/lib/action_dispatch/journey/visitors.rb +1 -4
  74. data/lib/action_dispatch/middleware/actionable_exceptions.rb +46 -0
  75. data/lib/action_dispatch/middleware/callbacks.rb +2 -4
  76. data/lib/action_dispatch/middleware/cookies.rb +62 -78
  77. data/lib/action_dispatch/middleware/debug_exceptions.rb +45 -61
  78. data/lib/action_dispatch/middleware/debug_locks.rb +5 -5
  79. data/lib/action_dispatch/middleware/debug_view.rb +66 -0
  80. data/lib/action_dispatch/middleware/exception_wrapper.rb +49 -16
  81. data/lib/action_dispatch/middleware/flash.rb +1 -1
  82. data/lib/action_dispatch/middleware/host_authorization.rb +121 -0
  83. data/lib/action_dispatch/middleware/public_exceptions.rb +6 -3
  84. data/lib/action_dispatch/middleware/remote_ip.rb +9 -12
  85. data/lib/action_dispatch/middleware/request_id.rb +2 -2
  86. data/lib/action_dispatch/middleware/session/abstract_store.rb +0 -1
  87. data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -7
  88. data/lib/action_dispatch/middleware/show_exceptions.rb +1 -2
  89. data/lib/action_dispatch/middleware/ssl.rb +8 -8
  90. data/lib/action_dispatch/middleware/stack.rb +38 -2
  91. data/lib/action_dispatch/middleware/static.rb +6 -7
  92. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
  93. data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
  94. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +3 -1
  95. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +1 -1
  96. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +4 -2
  97. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +45 -35
  98. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
  99. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
  100. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +26 -4
  101. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +1 -1
  102. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +7 -4
  103. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +5 -2
  104. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +4 -0
  105. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
  106. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
  107. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +2 -2
  108. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -1
  109. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +2 -2
  110. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +3 -0
  111. data/lib/action_dispatch/railtie.rb +7 -2
  112. data/lib/action_dispatch/request/session.rb +9 -2
  113. data/lib/action_dispatch/routing/inspector.rb +97 -50
  114. data/lib/action_dispatch/routing/mapper.rb +63 -42
  115. data/lib/action_dispatch/routing/polymorphic_routes.rb +3 -6
  116. data/lib/action_dispatch/routing/route_set.rb +25 -31
  117. data/lib/action_dispatch/routing/url_for.rb +2 -2
  118. data/lib/action_dispatch/routing.rb +21 -20
  119. data/lib/action_dispatch/system_test_case.rb +44 -6
  120. data/lib/action_dispatch/system_testing/browser.rb +38 -7
  121. data/lib/action_dispatch/system_testing/driver.rb +11 -2
  122. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +6 -5
  123. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +7 -6
  124. data/lib/action_dispatch/testing/assertion_response.rb +0 -1
  125. data/lib/action_dispatch/testing/assertions/response.rb +2 -3
  126. data/lib/action_dispatch/testing/assertions/routing.rb +15 -3
  127. data/lib/action_dispatch/testing/assertions.rb +1 -1
  128. data/lib/action_dispatch/testing/integration.rb +33 -12
  129. data/lib/action_dispatch/testing/request_encoder.rb +2 -2
  130. data/lib/action_dispatch/testing/test_process.rb +2 -2
  131. data/lib/action_dispatch/testing/test_response.rb +4 -32
  132. data/lib/action_dispatch.rb +7 -2
  133. data/lib/action_pack/gem_version.rb +3 -3
  134. data/lib/action_pack.rb +1 -1
  135. metadata +30 -16
  136. data/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +0 -26
data/CHANGELOG.md CHANGED
@@ -1,34 +1,40 @@
1
- ## Rails 5.2.8.1 (July 12, 2022) ##
1
+ ## Rails 6.0.6.1 (January 17, 2023) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 5.2.8 (May 09, 2022) ##
6
+ ## Rails 6.0.6 (September 09, 2022) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 5.2.7.1 (April 26, 2022) ##
11
+ ## Rails 6.0.5.1 (July 12, 2022) ##
12
12
 
13
- * Allow Content Security Policy DSL to generate for API responses.
13
+ * No changes.
14
14
 
15
- *Tim Wade*
16
15
 
17
- ## Rails 5.2.7 (March 10, 2022) ##
16
+ ## Rails 6.0.5 (May 09, 2022) ##
18
17
 
19
18
  * No changes.
20
19
 
21
- ## Rails 5.2.6.3 (March 08, 2022) ##
20
+
21
+ ## Rails 6.0.4.8 (April 26, 2022) ##
22
+
23
+ * Allow Content Security Policy DSL to generate for API responses.
24
+
25
+ *Tim Wade*
26
+
27
+ ## Rails 6.0.4.7 (March 08, 2022) ##
22
28
 
23
29
  * No changes.
24
30
 
25
31
 
26
- ## Rails 5.2.6.2 (February 11, 2022) ##
32
+ ## Rails 6.0.4.6 (February 11, 2022) ##
27
33
 
28
34
  * No changes.
29
35
 
30
36
 
31
- ## Rails 5.2.6.1 (February 11, 2022) ##
37
+ ## Rails 6.0.4.5 (February 11, 2022) ##
32
38
 
33
39
  * Under certain circumstances, the middleware isn't informed that the
34
40
  response body has been fully closed which result in request state not
@@ -37,7 +43,29 @@
37
43
  [CVE-2022-23633]
38
44
 
39
45
 
40
- ## Rails 5.2.6 (May 05, 2021) ##
46
+ ## Rails 6.0.4.4 (December 15, 2021) ##
47
+
48
+ * Fix issue with host protection not allowing host with port in development.
49
+
50
+
51
+ ## Rails 6.0.4.3 (December 14, 2021) ##
52
+
53
+ * Fix issue with host protection not allowing localhost in development.
54
+
55
+
56
+ ## Rails 6.0.4.2 (December 14, 2021) ##
57
+
58
+ * Fix X_FORWARDED_HOST protection. [CVE-2021-44528]
59
+
60
+ ## Rails 6.1.4.1 (August 19, 2021) ##
61
+
62
+ * [CVE-2021-22942] Fix possible open redirect in Host Authorization middleware.
63
+
64
+ Specially crafted "X-Forwarded-Host" headers in combination with certain
65
+ "allowed host" formats can cause the Host Authorization middleware in Action
66
+ Pack to redirect users to a malicious website.
67
+
68
+ ## Rails 6.0.4 (June 15, 2021) ##
41
69
 
42
70
  * Accept base64_urlsafe CSRF tokens to make forward compatible.
43
71
 
@@ -46,34 +74,29 @@
46
74
  the CSRF token to a browser in a client-readable cookie does not work properly
47
75
  out of the box: the value has to be url-encoded and decoded to survive transport.
48
76
 
49
- In this version, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently
77
+ In Rails 6.1, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently
50
78
  safe to transport. Validation accepts both urlsafe tokens, and strict-encoded
51
79
  tokens for backwards compatibility.
52
80
 
53
- How the tokes are encoded is controllr by the `action_controller.urlsafe_csrf_tokens`
54
- config.
55
-
56
- In Rails 5.2.5, the CSRF token format was accidentally changed to urlsafe-encoded.
57
-
58
- **Atention**: If you already upgraded your application to 5.2.5, set the config
59
- `urlsafe_csrf_tokens` to `true`, otherwise your form submission will start to fail
60
- during the deploy of this new version.
81
+ In Rails 5.2.5, the CSRF token format is accidentally changed to urlsafe-encoded.
82
+ If you upgrade apps from 5.2.5, set the config `urlsafe_csrf_tokens = true`.
61
83
 
62
84
  ```ruby
63
85
  Rails.application.config.action_controller.urlsafe_csrf_tokens = true
64
86
  ```
65
87
 
66
- If you are upgrading from 5.2.4.x, you don't need to change this configuration.
67
-
68
88
  *Scott Blum*, *Étienne Barrié*
69
89
 
90
+ * Signed and encrypted cookies can now store `false` as their value when
91
+ `action_dispatch.use_cookies_with_metadata` is enabled.
70
92
 
71
- ## Rails 5.2.5 (March 26, 2021) ##
93
+ *Rolandas Barysas*
72
94
 
73
- * No changes.
74
95
 
96
+ ## Rails 6.0.3.7 (May 05, 2021) ##
75
97
 
76
- ## Rails 5.2.4.6 (May 05, 2021) ##
98
+ * Prevent catastrophic backtracking during mime parsing
99
+ CVE-2021-22902
77
100
 
78
101
  * Prevent regex DoS in HTTP token authentication
79
102
  CVE-2021-22904
@@ -88,502 +111,407 @@
88
111
 
89
112
  *Gannon McGibbon*
90
113
 
91
- ## Rails 5.2.4.5 (February 10, 2021) ##
114
+ ## Rails 6.0.3.6 (March 26, 2021) ##
92
115
 
93
116
  * No changes.
94
117
 
95
118
 
96
- ## Rails 5.2.4.4 (September 09, 2020) ##
97
-
98
- * No changes.
119
+ ## Rails 6.0.3.5 (February 10, 2021) ##
99
120
 
121
+ * Prevent open redirect when allowed host starts with a dot
100
122
 
101
- ## Rails 5.2.4.3 (May 18, 2020) ##
123
+ [CVE-2021-22881]
102
124
 
103
- * [CVE-2020-8166] HMAC raw CSRF token before masking it, so it cannot be used to reconstruct a per-form token
104
-
105
- * [CVE-2020-8164] Return self when calling #each, #each_pair, and #each_value instead of the raw @parameters hash
125
+ Thanks to @tktech (https://hackerone.com/tktech) for reporting this
126
+ issue and the patch!
106
127
 
128
+ *Aaron Patterson*
107
129
 
108
- ## Rails 5.2.4.2 (March 19, 2020) ##
109
-
110
- * No changes.
111
-
112
-
113
- ## Rails 5.2.4.1 (December 18, 2019) ##
114
-
115
- * Fix possible information leak / session hijacking vulnerability.
116
-
117
- The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
118
- gem dalli to be updated as well.
119
130
 
120
- _Breaking changes:_
121
- * `session.id` now returns an instance of `Rack::Session::SessionId` and not a String (use `session.id.public_id` to restore the old behaviour, see #38063)
122
- * Accessing the session id using `session[:session_id]`/`session['session_id']` no longer works with
123
- ruby 2.2 (see https://github.com/rails/rails/commit/2a52a38cb51b65d71cf91fc960777213cf96f962#commitcomment-37929811)
131
+ ## Rails 6.0.3.4 (October 07, 2020) ##
124
132
 
125
- CVE-2019-16782.
133
+ * [CVE-2020-8264] Prevent XSS in Actionable Exceptions
126
134
 
127
135
 
128
- ## Rails 5.2.4 (November 27, 2019) ##
136
+ ## Rails 6.0.3.3 (September 09, 2020) ##
129
137
 
130
138
  * No changes.
131
139
 
132
140
 
133
- ## Rails 5.2.3 (March 27, 2019) ##
141
+ ## Rails 6.0.3.2 (June 17, 2020) ##
134
142
 
135
- * Allow using `public` and `no-cache` together in the the Cache Control header.
143
+ * [CVE-2020-8185] Only allow ActionableErrors if show_detailed_exceptions is enabled
136
144
 
137
- Before this change, even if `public` was specified in the Cache Control header,
138
- it was excluded when `no-cache` was included. This change preserves the
139
- `public` value as is.
145
+ ## Rails 6.0.3.1 (May 18, 2020) ##
140
146
 
141
- Fixes #34780.
147
+ * [CVE-2020-8166] HMAC raw CSRF token before masking it, so it cannot be used to reconstruct a per-form token
142
148
 
143
- *Yuji Yaginuma*
149
+ * [CVE-2020-8164] Return self when calling #each, #each_pair, and #each_value instead of the raw @parameters hash
144
150
 
145
- * Allow `nil` params for `ActionController::TestCase`.
146
151
 
147
- *Ryo Nakamura*
152
+ ## Rails 6.0.3 (May 06, 2020) ##
148
153
 
154
+ * Include child session assertion count in ActionDispatch::IntegrationTest
149
155
 
150
- ## Rails 5.2.2.1 (March 11, 2019) ##
156
+ `IntegrationTest#open_session` uses `dup` to create the new session, which
157
+ meant it had its own copy of `@assertions`. This prevented the assertions
158
+ from being correctly counted and reported.
151
159
 
152
- * No changes.
160
+ Child sessions now have their `attr_accessor` overriden to delegate to the
161
+ root session.
153
162
 
163
+ Fixes #32142
154
164
 
155
- ## Rails 5.2.2 (December 04, 2018) ##
165
+ *Sam Bostock*
156
166
 
157
- * Reset Capybara sessions if failed system test screenshot raising an exception.
158
167
 
159
- Reset Capybara sessions if `take_failed_screenshot` raise exception
160
- in system test `after_teardown`.
168
+ ## Rails 6.0.2.2 (March 19, 2020) ##
161
169
 
162
- *Maxim Perepelitsa*
170
+ * No changes.
163
171
 
164
- * Use request object for context if there's no controller
165
172
 
166
- There is no controller instance when using a redirect route or a
167
- mounted rack application so pass the request object as the context
168
- when resolving dynamic CSP sources in this scenario.
173
+ ## Rails 6.0.2.1 (December 18, 2019) ##
169
174
 
170
- Fixes #34200.
175
+ * Fix possible information leak / session hijacking vulnerability.
171
176
 
172
- *Andrew White*
177
+ The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
178
+ gem dalli to be updated as well.
173
179
 
174
- * Apply mapping to symbols returned from dynamic CSP sources
180
+ CVE-2019-16782.
175
181
 
176
- Previously if a dynamic source returned a symbol such as :self it
177
- would be converted to a string implicity, e.g:
178
182
 
179
- policy.default_src -> { :self }
183
+ ## Rails 6.0.2 (December 13, 2019) ##
180
184
 
181
- would generate the header:
185
+ * Allow using mountable engine route helpers in System Tests.
182
186
 
183
- Content-Security-Policy: default-src self
187
+ *Chalo Fernandez*
184
188
 
185
- and now it generates:
186
189
 
187
- Content-Security-Policy: default-src 'self'
190
+ ## Rails 6.0.1 (November 5, 2019) ##
188
191
 
189
- *Andrew White*
192
+ * `ActionDispatch::SystemTestCase` now inherits from `ActiveSupport::TestCase`
193
+ rather than `ActionDispatch::IntegrationTest`. This permits running jobs in
194
+ system tests.
190
195
 
191
- * Fix `rails routes -c` for controller name consists of multiple word.
196
+ *George Claghorn*, *Edouard Chin*
192
197
 
193
- *Yoshiyuki Kinjo*
198
+ * Registered MIME types may contain extra flags:
194
199
 
195
- * Call the `#redirect_to` block in controller context.
200
+ ```ruby
201
+ Mime::Type.register "text/html; fragment", :html_fragment
202
+ ```
196
203
 
197
- *Steven Peckins*
204
+ *Aaron Patterson*
198
205
 
199
206
 
200
- ## Rails 5.2.1.1 (November 27, 2018) ##
207
+ ## Rails 6.0.0 (August 16, 2019) ##
201
208
 
202
209
  * No changes.
203
210
 
204
211
 
205
- ## Rails 5.2.1 (August 07, 2018) ##
212
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
206
213
 
207
- * Prevent `?null=` being passed on JSON encoded test requests.
214
+ * Add the ability to set the CSP nonce only to the specified directives.
208
215
 
209
- `RequestEncoder#encode_params` won't attempt to parse params if
210
- there are none.
216
+ Fixes #35137.
211
217
 
212
- So call like this will no longer append a `?null=` query param.
218
+ *Yuji Yaginuma*
213
219
 
214
- get foos_url, as: :json
220
+ * Keep part when scope option has value.
215
221
 
216
- *Alireza Bashiri*
222
+ When a route was defined within an optional scope, if that route didn't
223
+ take parameters the scope was lost when using path helpers. This commit
224
+ ensures scope is kept both when the route takes parameters or when it
225
+ doesn't.
217
226
 
218
- * Ensure `ActionController::Parameters#transform_values` and
219
- `ActionController::Parameters#transform_values!` converts hashes into
220
- parameters.
227
+ Fixes #33219
221
228
 
222
- *Kevin Sjöberg*
229
+ *Alberto Almagro*
223
230
 
224
- * Fix strong parameters `permit!` with nested arrays.
231
+ * Change `ActionDispatch::Response#content_type` to return Content-Type header as it is.
225
232
 
226
- Given:
227
- ```
228
- params = ActionController::Parameters.new(nested_arrays: [[{ x: 2, y: 3 }, { x: 21, y: 42 }]])
229
- params.permit!
230
- ```
233
+ Previously, `ActionDispatch::Response#content_type` returned value does NOT
234
+ contain charset part. This behavior changed to returned Content-Type header
235
+ containing charset part as it is.
231
236
 
232
- `params[:nested_arrays][0][0].permitted?` will now return `true` instead of `false`.
237
+ If you want just MIME type, please use `ActionDispatch::Response#media_type`
238
+ instead.
233
239
 
234
- *Steve Hull*
240
+ Enable `action_dispatch.return_only_media_type_on_content_type` to use this change.
241
+ If not enabled, `ActionDispatch::Response#content_type` returns the same
242
+ value as before version, but its behavior is deprecate.
235
243
 
236
- * Reset `RAW_POST_DATA` and `CONTENT_LENGTH` request environment between test requests in
237
- `ActionController::TestCase` subclasses.
238
-
239
- *Eugene Kenny*
240
-
241
- * Output only one Content-Security-Policy nonce header value per request.
244
+ *Yuji Yaginuma*
242
245
 
243
- Fixes #32597.
246
+ * Calling `ActionController::Parameters#transform_keys/!` without a block now returns
247
+ an enumerator for the parameters instead of the underlying hash.
244
248
 
245
- *Andrey Novikov*, *Andrew White*
249
+ *Eugene Kenny*
246
250
 
247
- * Only disable GPUs for headless Chrome on Windows.
251
+ * Fix a bug where DebugExceptions throws an error when malformed query parameters are provided
248
252
 
249
- It is not necessary anymore for Linux and macOS machines.
253
+ *Yuki Nishijima*, *Stan Lo*
250
254
 
251
- https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1
252
255
 
253
- *Stefan Wrobel*
256
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
254
257
 
255
- * Fix system tests transactions not closed between examples.
258
+ * Make system tests take a failed screenshot in a `before_teardown` hook
259
+ rather than an `after_teardown` hook.
256
260
 
257
- *Sergey Tarasov*
261
+ This helps minimize the time gap between when an assertion fails and when
262
+ the screenshot is taken (reducing the time in which the page could have
263
+ been dynamically updated after the assertion failed).
258
264
 
265
+ *Richard Macklin*
259
266
 
260
- ## Rails 5.2.0 (April 09, 2018) ##
267
+ * Introduce `ActionDispatch::ActionableExceptions`.
261
268
 
262
- * Check exclude before flagging cookies as secure.
269
+ The `ActionDispatch::ActionableExceptions` middleware dispatches actions
270
+ from `ActiveSupport::ActionableError` descendants.
263
271
 
264
- *Catherine Khuu*
272
+ Actionable errors let's you dispatch actions from Rails' error pages.
265
273
 
266
- * Always yield a CSP policy instance from `content_security_policy`
274
+ *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
267
275
 
268
- This allows a controller action to enable the policy individually
269
- for a controller and/or specific actions.
276
+ * Raise an `ArgumentError` if a resource custom param contains a colon (`:`).
270
277
 
271
- *Andrew White*
278
+ After this change it's not possible anymore to configure routes like this:
272
279
 
273
- * Add the ability to disable the global CSP in a controller, e.g:
280
+ ```
281
+ routes.draw do
282
+ resources :users, param: 'name/:sneaky'
283
+ end
284
+ ```
274
285
 
275
- class LegacyPagesController < ApplicationController
276
- content_security_policy false, only: :index
277
- end
286
+ Fixes #30467.
278
287
 
279
- *Andrew White*
288
+ *Josua Schmid*
280
289
 
281
- * Add alias method `to_hash` to `to_h` for `cookies`.
282
- Add alias method `to_h` to `to_hash` for `session`.
283
290
 
284
- *Igor Kasyanchuk*
291
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
285
292
 
286
- * Update the default HSTS max-age value to 31536000 seconds (1 year)
287
- to meet the minimum max-age requirement for https://hstspreload.org/.
293
+ * No changes.
288
294
 
289
- *Grant Bourque*
290
295
 
291
- * Add support for automatic nonce generation for Rails UJS.
296
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
292
297
 
293
- Because the UJS library creates a script tag to process responses it
294
- normally requires the script-src attribute of the content security
295
- policy to include 'unsafe-inline'.
298
+ * Make debug exceptions works in an environment where ActiveStorage is not loaded.
296
299
 
297
- To work around this we generate a per-request nonce value that is
298
- embedded in a meta tag in a similar fashion to how CSRF protection
299
- embeds its token in a meta tag. The UJS library can then read the
300
- nonce value and set it on the dynamically generated script tag to
301
- enable it to execute without needing 'unsafe-inline' enabled.
300
+ *Tomoyuki Kurosawa*
302
301
 
303
- Nonce generation isn't 100% safe - if your script tag is including
304
- user generated content in someway then it may be possible to exploit
305
- an XSS vulnerability which can take advantage of the nonce. It is
306
- however an improvement on a blanket permission for inline scripts.
302
+ * `ActionDispatch::SystemTestCase.driven_by` can now be called with a block
303
+ to define specific browser capabilities.
307
304
 
308
- It is also possible to use the nonce within your own script tags by
309
- using `nonce: true` to set the nonce value on the tag, e.g
305
+ *Edouard Chin*
310
306
 
311
- <%= javascript_tag nonce: true do %>
312
- alert('Hello, World!');
313
- <% end %>
314
307
 
315
- Fixes #31689.
308
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
316
309
 
317
- *Andrew White*
310
+ * Remove deprecated `fragment_cache_key` helper in favor of `combined_fragment_cache_key`.
318
311
 
319
- * Matches behavior of `Hash#each` in `ActionController::Parameters#each`.
312
+ *Rafael Mendonça França*
320
313
 
321
- Rails 5.0 introduced a bug when looping through controller params using `each`. Only the keys of params hash were passed to the block, e.g.
314
+ * Remove deprecated methods in `ActionDispatch::TestResponse`.
322
315
 
323
- # Parameters: {"param"=>"1", "param_two"=>"2"}
324
- def index
325
- params.each do |name|
326
- puts name
327
- end
328
- end
316
+ `#success?`, `missing?` and `error?` were deprecated in Rails 5.2 in favor of
317
+ `#successful?`, `not_found?` and `server_error?`.
329
318
 
330
- # Prints
331
- # param
332
- # param_two
319
+ *Rafael Mendonça França*
333
320
 
334
- In Rails 5.2 the bug has been fixed and name will be an array (which was the behavior for all versions prior to 5.0), instead of a string.
321
+ * Introduce `ActionDispatch::HostAuthorization`.
335
322
 
336
- To fix the code above simply change as per example below:
323
+ This is a new middleware that guards against DNS rebinding attacks by
324
+ explicitly permitting the hosts a request can be made to.
337
325
 
338
- # Parameters: {"param"=>"1", "param_two"=>"2"}
339
- def index
340
- params.each do |name, value|
341
- puts name
342
- end
343
- end
326
+ Each host is checked with the case operator (`#===`) to support `Regexp`,
327
+ `Proc`, `IPAddr` and custom objects as host allowances.
344
328
 
345
- # Prints
346
- # param
347
- # param_two
329
+ *Genadi Samokovarov*
348
330
 
349
- *Dominic Cleal*
331
+ * Allow using `parsed_body` in `ActionController::TestCase`.
350
332
 
351
- * Add `Referrer-Policy` header to default headers set.
333
+ In addition to `ActionDispatch::IntegrationTest`, allow using
334
+ `parsed_body` in `ActionController::TestCase`:
352
335
 
353
- *Guillermo Iguaran*
336
+ ```
337
+ class SomeControllerTest < ActionController::TestCase
338
+ def test_some_action
339
+ post :action, body: { foo: 'bar' }
340
+ assert_equal({ "foo" => "bar" }, response.parsed_body)
341
+ end
342
+ end
343
+ ```
354
344
 
355
- * Changed the system tests to set Puma as default server only when the
356
- user haven't specified manually another server.
345
+ Fixes #34676.
357
346
 
358
- *Guillermo Iguaran*
347
+ *Tobias Bühlmann*
359
348
 
360
- * Add secure `X-Download-Options` and `X-Permitted-Cross-Domain-Policies` to
361
- default headers set.
349
+ * Raise an error on root route naming conflicts.
362
350
 
363
- *Guillermo Iguaran*
351
+ Raises an `ArgumentError` when multiple root routes are defined in the
352
+ same context instead of assigning nil names to subsequent roots.
364
353
 
365
- * Add headless firefox support to System Tests.
354
+ *Gannon McGibbon*
366
355
 
367
- *bogdanvlviv*
356
+ * Allow rescue from parameter parse errors:
368
357
 
369
- * Changed the default system test screenshot output from `inline` to `simple`.
358
+ ```
359
+ rescue_from ActionDispatch::Http::Parameters::ParseError do
360
+ head :unauthorized
361
+ end
362
+ ```
370
363
 
371
- `inline` works well for iTerm2 but not everyone uses iTerm2. Some terminals like
372
- Terminal.app ignore the `inline` and output the path to the file since it can't
373
- render the image. Other terminals, like those on Ubuntu, cannot handle the image
374
- inline, but also don't handle it gracefully and instead of outputting the file
375
- path, it dumps binary into the terminal.
364
+ *Gannon McGibbon*, *Josh Cheek*
376
365
 
377
- Commit 9d6e28 fixes this by changing the default for screenshot to be `simple`.
366
+ * Reset Capybara sessions if failed system test screenshot raising an exception.
378
367
 
379
- *Eileen M. Uchitelle*
368
+ Reset Capybara sessions if `take_failed_screenshot` raise exception
369
+ in system test `after_teardown`.
380
370
 
381
- * Register most popular audio/video/font mime types supported by modern browsers.
371
+ *Maxim Perepelitsa*
382
372
 
383
- *Guillermo Iguaran*
373
+ * Use request object for context if there's no controller
384
374
 
385
- * Fix optimized url helpers when using relative url root.
375
+ There is no controller instance when using a redirect route or a
376
+ mounted rack application so pass the request object as the context
377
+ when resolving dynamic CSP sources in this scenario.
386
378
 
387
- Fixes #31220.
379
+ Fixes #34200.
388
380
 
389
381
  *Andrew White*
390
382
 
391
- * Add DSL for configuring Content-Security-Policy header.
392
-
393
- The DSL allows you to configure a global Content-Security-Policy
394
- header and then override within a controller. For more information
395
- about the Content-Security-Policy header see MDN:
396
-
397
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
398
-
399
- Example global policy:
400
-
401
- # config/initializers/content_security_policy.rb
402
- Rails.application.config.content_security_policy do |p|
403
- p.default_src :self, :https
404
- p.font_src :self, :https, :data
405
- p.img_src :self, :https, :data
406
- p.object_src :none
407
- p.script_src :self, :https
408
- p.style_src :self, :https, :unsafe_inline
409
- end
410
-
411
- Example controller overrides:
412
-
413
- # Override policy inline
414
- class PostsController < ApplicationController
415
- content_security_policy do |p|
416
- p.upgrade_insecure_requests true
417
- end
418
- end
383
+ * Apply mapping to symbols returned from dynamic CSP sources
419
384
 
420
- # Using literal values
421
- class PostsController < ApplicationController
422
- content_security_policy do |p|
423
- p.base_uri "https://www.example.com"
424
- end
425
- end
385
+ Previously if a dynamic source returned a symbol such as :self it
386
+ would be converted to a string implicitly, e.g:
426
387
 
427
- # Using mixed static and dynamic values
428
- class PostsController < ApplicationController
429
- content_security_policy do |p|
430
- p.base_uri :self, -> { "https://#{current_user.domain}.example.com" }
431
- end
432
- end
388
+ policy.default_src -> { :self }
433
389
 
434
- Allows you to also only report content violations for migrating
435
- legacy content using the `content_security_policy_report_only`
436
- configuration attribute, e.g;
390
+ would generate the header:
437
391
 
438
- # config/initializers/content_security_policy.rb
439
- Rails.application.config.content_security_policy_report_only = true
392
+ Content-Security-Policy: default-src self
440
393
 
441
- # controller override
442
- class PostsController < ApplicationController
443
- content_security_policy_report_only only: :index
444
- end
394
+ and now it generates:
445
395
 
446
- Note that this feature does not validate the header for performance
447
- reasons since the header is calculated at runtime.
396
+ Content-Security-Policy: default-src 'self'
448
397
 
449
398
  *Andrew White*
450
399
 
451
- * Make `assert_recognizes` to traverse mounted engines.
452
-
453
- *Yuichiro Kaneko*
454
-
455
- * Remove deprecated `ActionController::ParamsParser::ParseError`.
456
-
457
- *Rafael Mendonça França*
458
-
459
- * Add `:allow_other_host` option to `redirect_back` method.
400
+ * Add `ActionController::Parameters#each_value`.
460
401
 
461
- When `allow_other_host` is set to `false`, the `redirect_back` will not allow redirecting from a
462
- different host. `allow_other_host` is `true` by default.
402
+ *Lukáš Zapletal*
463
403
 
464
- *Tim Masliuchenko*
404
+ * Deprecate `ActionDispatch::Http::ParameterFilter` in favor of `ActiveSupport::ParameterFilter`.
465
405
 
466
- * Add headless chrome support to System Tests.
467
-
468
- *Yuji Yaginuma*
469
-
470
- * Add ability to enable Early Hints for HTTP/2
471
-
472
- If supported by the server, and enabled in Puma this allows H2 Early Hints to be used.
473
-
474
- The `javascript_include_tag` and the `stylesheet_link_tag` automatically add Early Hints if requested.
475
-
476
- *Eileen M. Uchitelle*, *Aaron Patterson*
477
-
478
- * Simplify cookies middleware with key rotation support
406
+ *Yoshiyuki Kinjo*
479
407
 
480
- Use the `rotate` method for both `MessageEncryptor` and
481
- `MessageVerifier` to add key rotation support for encrypted and
482
- signed cookies. This also helps simplify support for legacy cookie
483
- security.
408
+ * Encode Content-Disposition filenames on `send_data` and `send_file`.
409
+ Previously, `send_data 'data', filename: "\u{3042}.txt"` sends
410
+ `"filename=\"\u{3042}.txt\""` as Content-Disposition and it can be
411
+ garbled.
412
+ Now it follows [RFC 2231](https://tools.ietf.org/html/rfc2231) and
413
+ [RFC 5987](https://tools.ietf.org/html/rfc5987) and sends
414
+ `"filename=\"%3F.txt\"; filename*=UTF-8''%E3%81%82.txt"`.
415
+ Most browsers can find filename correctly and old browsers fallback to ASCII
416
+ converted name.
484
417
 
485
- *Michael J Coyne*
418
+ *Fumiaki Matsushima*
486
419
 
487
- * Use Capybara registered `:puma` server config.
420
+ * Expose `ActionController::Parameters#each_key` which allows iterating over
421
+ keys without allocating an array.
488
422
 
489
- The Capybara registered `:puma` server ensures the puma server is run in process so
490
- connection sharing and open request detection work correctly by default.
423
+ *Richard Schneeman*
491
424
 
492
- *Thomas Walpole*
425
+ * Purpose metadata for signed/encrypted cookies.
493
426
 
494
- * Cookies `:expires` option supports `ActiveSupport::Duration` object.
427
+ Rails can now thwart attacks that attempt to copy signed/encrypted value
428
+ of a cookie and use it as the value of another cookie.
495
429
 
496
- cookies[:user_name] = { value: "assain", expires: 1.hour }
497
- cookies[:key] = { value: "a yummy cookie", expires: 6.months }
430
+ It does so by stashing the cookie-name in the purpose field which is
431
+ then signed/encrypted along with the cookie value. Then, on a server-side
432
+ read, we verify the cookie-names and discard any attacked cookies.
498
433
 
499
- Pull Request: #30121
434
+ Enable `action_dispatch.use_cookies_with_metadata` to use this feature, which
435
+ writes cookies with the new purpose and expiry metadata embedded.
500
436
 
501
437
  *Assain Jaleel*
502
438
 
503
- * Enforce signed/encrypted cookie expiry server side.
504
-
505
- Rails can thwart attacks by malicious clients that don't honor a cookie's expiry.
506
-
507
- It does so by stashing the expiry within the written cookie and relying on the
508
- signing/encrypting to vouch that it hasn't been tampered with. Then on a
509
- server-side read, the expiry is verified and any expired cookie is discarded.
439
+ * Raises `ActionController::RespondToMismatchError` with conflicting `respond_to` invocations.
510
440
 
511
- Pull Request: #30121
441
+ `respond_to` can match multiple types and lead to undefined behavior when
442
+ multiple invocations are made and the types do not match:
512
443
 
513
- *Assain Jaleel*
514
-
515
- * Make `take_failed_screenshot` work within engine.
444
+ respond_to do |outer_type|
445
+ outer_type.js do
446
+ respond_to do |inner_type|
447
+ inner_type.html { render body: "HTML" }
448
+ end
449
+ end
450
+ end
516
451
 
517
- Fixes #30405.
452
+ *Patrick Toomey*
518
453
 
519
- *Yuji Yaginuma*
454
+ * `ActionDispatch::Http::UploadedFile` now delegates `to_path` to its tempfile.
520
455
 
521
- * Deprecate `ActionDispatch::TestResponse` response aliases.
456
+ This allows uploaded file objects to be passed directly to `File.read`
457
+ without raising a `TypeError`:
522
458
 
523
- `#success?`, `#missing?` & `#error?` are not supported by the actual
524
- `ActionDispatch::Response` object and can produce false-positives. Instead,
525
- use the response helpers provided by `Rack::Response`.
459
+ uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file)
460
+ File.read(uploaded_file)
526
461
 
527
- *Trevor Wistaff*
462
+ *Aaron Kromer*
528
463
 
529
- * Protect from forgery by default
464
+ * Pass along arguments to underlying `get` method in `follow_redirect!`
530
465
 
531
- Rather than protecting from forgery in the generated `ApplicationController`,
532
- add it to `ActionController::Base` depending on
533
- `config.action_controller.default_protect_from_forgery`. This configuration
534
- defaults to false to support older versions which have removed it from their
535
- `ApplicationController`, but is set to true for Rails 5.2.
466
+ Now all arguments passed to `follow_redirect!` are passed to the underlying
467
+ `get` method. This for example allows to set custom headers for the
468
+ redirection request to the server.
536
469
 
537
- *Lisa Ugray*
470
+ follow_redirect!(params: { foo: :bar })
538
471
 
539
- * Fallback `ActionController::Parameters#to_s` to `Hash#to_s`.
472
+ *Remo Fritzsche*
540
473
 
541
- *Kir Shatrov*
474
+ * Introduce a new error page to when the implicit render page is accessed in the browser.
542
475
 
543
- * `driven_by` now registers poltergeist and capybara-webkit.
476
+ Now instead of showing an error page that with exception and backtraces we now show only
477
+ one informative page.
544
478
 
545
- If poltergeist or capybara-webkit are set as drivers is set for System Tests,
546
- `driven_by` will register the driver and set additional options passed via
547
- the `:options` parameter.
479
+ *Vinicius Stock*
548
480
 
549
- Refer to the respective driver's documentation to see what options can be passed.
481
+ * Introduce `ActionDispatch::DebugExceptions.register_interceptor`.
550
482
 
551
- *Mario Chavez*
483
+ Exception aware plugin authors can use the newly introduced
484
+ `.register_interceptor` method to get the processed exception, instead of
485
+ monkey patching DebugExceptions.
552
486
 
553
- * AEAD encrypted cookies and sessions with GCM.
487
+ ActionDispatch::DebugExceptions.register_interceptor do |request, exception|
488
+ HypoteticalPlugin.capture_exception(request, exception)
489
+ end
554
490
 
555
- Encrypted cookies now use AES-GCM which couples authentication and
556
- encryption in one faster step and produces shorter ciphertexts. Cookies
557
- encrypted using AES in CBC HMAC mode will be seamlessly upgraded when
558
- this new mode is enabled via the
559
- `action_dispatch.use_authenticated_cookie_encryption` configuration value.
491
+ *Genadi Samokovarov*
560
492
 
561
- *Michael J Coyne*
493
+ * Output only one Content-Security-Policy nonce header value per request.
562
494
 
563
- * Change the cache key format for fragments to make it easier to debug key churn. The new format is:
495
+ Fixes #32597.
564
496
 
565
- views/template/action.html.erb:7a1156131a6928cb0026877f8b749ac9/projects/123
566
- ^template path ^template tree digest ^class ^id
497
+ *Andrey Novikov*, *Andrew White*
567
498
 
568
- *DHH*
499
+ * Move default headers configuration into their own module that can be included in controllers.
569
500
 
570
- * Add support for recyclable cache keys with fragment caching. This uses the new versioned entries in the
571
- `ActiveSupport::Cache` stores and relies on the fact that Active Record has split `#cache_key` and `#cache_version`
572
- to support it.
501
+ *Kevin Deisz*
573
502
 
574
- *DHH*
503
+ * Add method `dig` to `session`.
575
504
 
576
- * Add `action_controller_api` and `action_controller_base` load hooks to be called in `ActiveSupport.on_load`
505
+ *claudiob*, *Takumi Shotoku*
577
506
 
578
- `ActionController::Base` and `ActionController::API` have differing implementations. This means that
579
- the one umbrella hook `action_controller` is not able to address certain situations where a method
580
- may not exist in a certain implementation.
507
+ * Controller level `force_ssl` has been deprecated in favor of
508
+ `config.force_ssl`.
581
509
 
582
- This is fixed by adding two new hooks so you can target `ActionController::Base` vs `ActionController::API`
510
+ *Derek Prior*
583
511
 
584
- Fixes #27013.
512
+ * Rails 6 requires Ruby 2.5.0 or newer.
585
513
 
586
- *Julian Nadeau*
514
+ *Jeremy Daer*, *Kasper Timm Hansen*
587
515
 
588
516
 
589
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/actionpack/CHANGELOG.md) for previous changes.
517
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionpack/CHANGELOG.md) for previous changes.