-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues loading serialized logs #4376
Fix issues loading serialized logs #4376
Conversation
The new Psych version required by Ruby 3.1 no longer allows the loading of arbitrary classes into YAML by default. We switch to `#safe_load` and enable the class we're currently using. See: ruby/psych@cb50aa8 ruby/psych@1764942 [skip ci]
9169af9
to
5d86c11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @waiting-for-dev!
We are putting it on hold, as we'll rescue from Psych exception about unknown classes and print a message redirecting to the new preference. |
5d86c11
to
f3a5a62
Compare
Done. @albertoalmagro, @aldesantis, do you want to take a final look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waiting-for-dev the implementation looks good, but I've left a couple of suggestions. Let me know your thoughts!
`Spree::LogEntry` loads details from a YAML string that can potentially contain any serialized Ruby object if users have overridden some part of the codebase. New Psych (YAML parser) version packed with Ruby 3.1 requires that, by default, users are explicit about which type of classes are allowed to be loaded (see ruby/psych@cb50aa8 and ruby/psych@1764942). On 008168c, we updated our code to allow instances of `ActiveMerchant::Billing::Response`. However, as [noted in a comment](solidusio@008168c#r73483078), it seems we're missing, at least, instances of `ActiveSupport::TimeWithZone`. We need to add all classes used internally and leave a door open for users to add their own classes (via a new `log_entry_permitted_classes` preference).
f3a5a62
to
c8e274f
Compare
By default, `YAML.safe_load` won't allow YAML aliases to be parsed. However, we need them at least for older versions of serialized `ActiveSupport::TimeWithZone`. We add a configuration option so that users can still disable it. Depending on the source of the YAML, parsing aliases could open gates to entity expansion attacks (a DoS created by nesting self-references).
c8e274f
to
256bf7c
Compare
Spree::LogEntry
loads details from a YAML string that can potentiallycontain any serialized Ruby object if users have overridden some part of
the codebase.
New Psych (YAML parser) version packed with Ruby 3.1 requires that, by
default, users are explicit about which type of classes are allowed to
be loaded (see ruby/psych@cb50aa8 and ruby/psych@1764942).
On 008168c, we updated our code to allow instances of
ActiveMerchant::Billing::Response
. However, as noted in acomment,
it seems we're missing, at least, instances of
ActiveSupport::TimeWithZone
.We need to add all classes used internally and leave a door open for
users to add their own classes (via a new
log_entry_permitted_classes
preference).
On top of that, by default,
YAML.safe_load
won't allow YAML aliases to be parsed.However, we need them at least for older versions of serialized
ActiveSupport::TimeWithZone
.We add a configuration option so that users can still disable it.
Depending on the source of the YAML, parsing aliases could open gates to
entity expansion attacks (a DoS created by nesting self-references).
Checklist: