-
Notifications
You must be signed in to change notification settings - Fork 0
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
Backport OpenStruct fix to version shipped in Ruby 3.1 #3
Conversation
The OpenStruct implementation differs between Ruby 2.7 and 3.1. The latter comes with OpenStruct 0.5.2. That version has a bug that was fixed [here](ruby/ostruct#37). The TL;DR of the impact of that bug in this repo is that brakeman includes JSON with an attribute named `class`. This shadows the normal `class` method and causes `self.class.ancestors` to blow up. The fix uses the aliased `class!` method to do the Right Thing™.
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.
Pioneering Ruby 3.1 🎉 !
This looks like a great solution to me. We can remove it when everyone is on Ruby 3.1.
@wassimk This isn't working as-is. I'll rework and then ping you again. Sorry for the bother! |
@wassimk I reworked this to back port the patch to the broken version. The prior attempt of installing a later version of ostruct did not work because ostruct is a "default" gem and so one cannot "activate" a newer version. This fix can get reverted once all repos that use |
Thank you for fixing this for everyone else too. 👏🏼 |
@molawson I tagged you for a second review because I saw you in the commit history too 😅 |
Problem Statement
The OpenStruct implementation differs between Ruby 2.7 and 3.1. The
latter comes with OpenStruct 0.5.2. That version has a bug that was
fixed in version 0.5.4.
The TL;DR of the impact of that bug in this repo is that brakeman
includes JSON with an attribute named
class
. This shadows the normalclass
method and causesself.class.ancestors
to blow up. The fixuses the aliased
class!
method to do the Right Thing™.Here is a failing Publishing run. We're on Ruby 3.1.
Here is a snippet illustrating the error:
Fix
Backport the fix to broken versions of
ostruct
. Tested in publishing SAT.