-
-
Notifications
You must be signed in to change notification settings - Fork 234
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 YAML.load to YAML.unsafe_load if possible with rails 6.1 tests #306
Conversation
@atatb I'm curious on your thoughts on instead forcing users to opt into unsafe YAML parsing. At first glance, using Did you run into this problem because you have a YAML file that you use with the |
@cjlarose Thank you for your comment!
Exactly I came across this problem due to my unsafe yaml file using regex and anchors with aliases like the below for example.
Also unfortunately one of a gem (reet) used in my rails app started to depend on I could solve this issue by adding old version's psych gem in my Gemfile explicitly but it should be just a workaround and the root cause to solve is to specify which YAML.load (safe or unsafe) to use in code, I guessed. In case of config gem, because a psych which is generally used (like by ruby built-in) uses unsafe mode for That's my main motivation to make this PR as well but I still have some considerations so let me write them down in the list below.
|
Awesome. Thanks so much for providing the context!
This makes sense. I guess if people really need to use
I actually think the PR as written does the right thing for now: we're just preserving the existing unsafe-by-default parsing, regardless of which version of |
@cjlarose Thanks! |
* Fix YAML.load to YAML.unsafe_load if possible * Add YAML.unsafe_load tests with rails 6.1
Published in version 3.1.1 |
YAML.load uses safe mode by default from Psych version 4.0.0 (and plan to be used in ruby 3.1 ?), so that unsafe yaml descriptions such as alias and disallowed classes and so on are failed in loading.
In this PR, I fixed to use YAML.unsafe_load instead of YAML.load if unsafe_load is available.
(unsafe_load is implemented in Psych 3.3.2 and YAML.load is still unsafe then.)
For the testing, psych >= 4 needs to be added to the dependency explicitly (unless other gems depend on this specific version of psych) and I don't bother the existing tests, so I added a new rails 6.1 to the test matrix with psych >= 4 dependency.
ref: