Skip to content
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

Ensure YAML safe loading in Rails 6.1 #1399

Closed
wants to merge 1 commit into from

Conversation

tlconnor
Copy link
Contributor

As part of the fix for CVE-2022-32224 Rails intruduced safe YAML loading and the ActiveRecord.yaml_column_permitted_classes config.

PaperTrail added support for respecting the new configuration here #1397

The CVE-2022-32224 fix was also backported to Rails versions 5.2.8.1, 6.0.5.1, and, 6.1.6.1, however the name of the configuration is slightly different from that in Rails 7.x.

7.0.3.1 ActiveRecord.yaml_column_permitted_classes
6.1.6.1 ActiveRecord::Base.yaml_column_permitted_classes
6.0.5.1 ActiveRecord::Base.yaml_column_permitted_classes
5.2.8.1 ActiveRecord::Base.yaml_column_permitted_classes

PaperTrail currently doesn't support this alternative configuration naming, which means it will silent fall back to unsafe YAML loading.

This PR updates PaperTrail::Serializers::YAML to be compatible with safe YAML loading for the Rails 5.2 / 6.0 / 6.1 branches.

  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@tlconnor tlconnor force-pushed the yamlSafeLoadRails6 branch 2 times, most recently from 51b17d3 to 4a5bd75 Compare August 26, 2022 04:22
As part of the fix for CVE-2022-32224 Rails intruduced safe YAML loading
and the `ActiveRecord.yaml_column_permitted_classes` config.

PaperTrail added support for respecting the new configuration here
paper-trail-gem#1397

The CVE-2022-32224 fix was also backported to Rails versions 5.2.8.1,
6.0.5.1, and, 6.1.6.1, however the name of the confiuration is slightly
different from that in Rails 7.x.

    7.0.3.1 ActiveRecord.yaml_column_permitted_classes
    6.1.6.1 ActiveRecord::Base.yaml_column_permitted_classes
    6.0.5.1 ActiveRecord::Base.yaml_column_permitted_classes
    5.2.8.1 ActiveRecord::Base.yaml_column_permitted_classes

PaperTrail currently doesn't support this alternative configuration
naming, which means it will silent fall back to unsafe YAML loading.

This commit updates `PaperTrail::Serializers::YAML` to be compatible
with safe YAML loading for the Rails 5.2 / 6.0 / 6.1 branches.
@jaredbeck
Copy link
Member

jaredbeck commented Aug 26, 2022

.. PR ready to go, however it is failing CI based on the SimpleCov line coverage requirement. I'm not sure how to resolve that because the lower coverage is due to Rails version specific branches in the code.

Can you write new tests so that we maintain the same level of coverage? If that is difficult because of the conditionals, then I'm OK with lowering the coverage requirement slightly. (We're talking about fractions of a percentage point, right?)

Also, Simplecov is already ignoring /spec/dummy_app, right? Hopefully it is ignoring all of /spec.

@jaredbeck
Copy link
Member

Merged offline. Please test master.

@jaredbeck jaredbeck closed this Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants