2024/02/22分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Allow for more complex hash arguments for
orderwhich mimicswhereinActiveRecord::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_oneassociation 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向けの対応。