2024/02/22分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Allow for more complex hash arguments for
order
which mimicswhere
inActiveRecord::Relation
. - The fix ensures that the association is joined using the appropriate join type (either inner join or left outer join) based on the existing joins in the scope.
- Fix
has_one
association autosave setting the foreign key attribute when it is unchanged.
Merge pull request #32770 from zealot128/patch-2
actionpack/lib/action_controller/metal/request_forgery_protection.rb
の修正です。
form_for
などのpathに相対path(e.g. ./post_one
)を指定した場合に、Request Forgeryのチェックが正しく行えてなかったのを修正しています。
ActiveRecord::Relation#order
supports hash like ActiveRecord::Relation#where
(#50000)
activerecord/lib/active_record/relation/query_methods.rb
の修正です。
ActiveRecord::Relation#order
にjoinしているtableのattributeを指定出来るよう修正しています。
Topic.includes(:posts).order(posts: { created_at: :desc })
Fix inconsistent results of params.deep_transform_keys (#50361)
actionpack/lib/action_controller/metal/strong_parameters.rb
の修正です。
ActionController::Parameters#deep_transform_keys
でkeyがnested hasheやArrayの場合にもtransform処理が行えるよう修正しています。
Fix an issue in the where.associated
method
activerecord/lib/active_record/relation/query_methods.rb
の修正です。
where.associated
を使用した場合、必ず指定したassociationに対してJOIN
が実行されていたのを、associationに対するjoinが指定されていた場合、そのjoinを使用するよう修正しています。
# before Post.left_joins(:author).where.associated(:author) # `associated`メソッドは`JOIN`を使用する # after Post.left_joins(:author).where.associated(:author) # `associated`メソッドは`LEFT JOIN`を使用する
Fix ReDoS in accept header scanning
actionpack/lib/action_dispatch/http/mime_type.rb
の修正です。
Accept headerのパース処理で、ReDoS出来てしまう可能性があるバグがあったのを修正しています。CVE-2024-26142。
参考:Possible ReDoS vulnerability in Accept header parsing in Action Dispatch
fix XSS vulnerability when using translation
actionpack/lib/abstract_controller/translation.rb
の修正です。
controllerでtranslation helper(e.g. translate
、t
)をkeyが_html
で終わっている、かつ、:default
の値にユーザが入力した値を使用している場合に、XSS出来てしまうバグがあったのを修正しています。CVE-2024-26143。
class ArticlesController < ApplicationController def show @message = t("message_html", default: untrusted_input) # The `show` template displays the contents of `@message` end end
参考:Possible XSS Vulnerability in Action Controller - Security Announcements - Ruby on Rails Discussions
Merge pull request #50901 from joshuay03/fix-autosave-has-one-setting-fk-when-unchanged
activerecord/lib/active_record/autosave_association.rb
の修正です。
has_one
associationのautosave処理で、値を変更していないのにforeign key attributeを変更してしまい、その影響で、raise_on_assign_to_attr_readonly
がtrueの場合にActiveRecord::ReadOnlyAttributeError
をraiseしてしまう、というバグがあったのを修正しています。
Respect raise_on_missing_ in controller
actionpack/lib/abstract_controller/translation.rb
、
activesupport/lib/active_support/html_safe_translation.rb
の修正です。
先のtranslation helperのセキュリティ対応により、raise_on_missing_translations
がcontrollerでtranslation helperを使用した場合に無視されてしまうようになったのを、再度raise_on_missing_translations
がcontrollerでも動作するよう修正しています。
Refactor InternalMetadata, MigrationContext to belong to the pool
Active Recordの修正です。
connection pollがInternalMetadata及びMigrationContextを保持するようリファクタリングしています。他のリファクタリング同様、PoC: Add an option to disable connection checkout caching向けの対応。