-
Notifications
You must be signed in to change notification settings - Fork 898
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 brakeman fingerprint patch on clones #23191
Fix brakeman fingerprint patch on clones #23191
Conversation
end | ||
end | ||
|
||
context "with a cloned spec/manageiq dir" do # This is also the CI case for a plugin |
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.
@jrafanie When I ran these tests without the code fix, all of them passed except this one, and within this one the engine one passed but the core case did not. So, the code fix specifically fixes this case without breaking the other cases.
Checked commits Fryguy/manageiq@b4ad486~...00b8966 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint lib/extensions/brakeman_fingerprint_patch.rb
spec/lib/extensions/brakeman_fingerprint_patch_spec.rb
|
@@ -40,12 +40,12 @@ def self.rails_engine_paths | |||
# are standalone objects. | |||
def file_string | |||
engine_path = BrakemanFingerprintPatch.rails_engine_paths.detect { |p| self.file.absolute.start_with?(p) } | |||
if engine_path | |||
if engine_path.nil? || (Rails.root.to_s.start_with?(engine_path) && self.file.absolute.start_with?(Rails.root.to_s)) |
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.
So, when have a core cloned underneath the engine we have 2 cases
- issue in an engine file, such as:
/Users/user/dev/manageiq-ui-classic/app/controllers/application_controller.rb
- issue in a core file, such as
/Users/user/dev/manageiq-ui-classic/spec/manageiq/lib/ansible/runner.rb
In both of those cases, we get an engine_path
, but in reality, only the issue in an engine file one is actually in the engine, whereas the core file just happens to be under the engine directory, but is actually an issue in core. So, we do additional checks to
- see if the Rails root starts with the engine_path, which tells us we are in the core cloned underneath the engine case
- then see if the issue path starts with the rails root, which tells us that the file is actually a core issue and not an engine issue
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.
Wow, that's too bad we need to check it like this in a patch of brakeman.
Just checking... Do we still think it's worth checking all of the engines here? I know it's been a bit frustrating that an engine issue was causing unrelated core test failures. Is it just more convenient to pull in all the engines and test each one?
Honestly, if we tested in UI classic only, the rest of the engines could probably be included in the core tests. UI classic is likely the noisest offender for brakeman issues outside of core. I'm just wondering if it's worth it.
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.
It's a really good idea. I think what I'd like to do is get this merged to get us green then I can investigate that
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.
Ok, I researched this a little, and I thikn the way we have it is the best way. The brakeman app technically always runs from the main app, and what we do is just tell it more engines to check. From core, we just loop through all of the engines and add all of them. From an engine, we just add the engine itself only.
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.
Right, I think the problem is where the problem is reported. If we add something in an engine that breaks core, it makes core red and we become hesitant to merge while it's being fixed whereas the engine is not aware of the problem. We can look at it as a followup, I just wanted to make sure the complexity still made sense.
@jrafanie Regarding the rubocops
|
@jrafanie Please review.