-
Notifications
You must be signed in to change notification settings - Fork 897
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_auth now handles recursive settings #18631
Conversation
|
@@ -20,13 +20,14 @@ def walk(settings, path = [], &block) | |||
key_path = path.dup << key | |||
|
|||
yield key, value, key_path, settings | |||
next if key == settings || value == settings |
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.
How would the key equal the settings object? And would that even lead to this recursion behavior?
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. you win. I got in examples on all 3 of these cases.
|
||
case value | ||
when settings.class | ||
walk(value, key_path, &block) | ||
when Array | ||
value.each_with_index do |v, i| | ||
walk(v, key_path.dup << i, &block) if v.kind_of?(settings.class) | ||
walk(v, key_path.dup << i, &block) if v.kind_of?(settings.class) && v != settings |
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.
Can you add a test for this case? I don't think the one below covers it.
situation: 1. For one customer, miq_request_tasks has an options hash with recursive values. 2. fix_auth recurses all the options looking for passwords to convert before: it recurses forever after: it now detects the recursion and does not go forever NOTE: this only detects very simple recursive cases. https://bugzilla.redhat.com/show_bug.cgi?id=1696237
a77c17c
to
2eabc44
Compare
Checked commit kbrock@2eabc44 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/lib/vmdb/settings_spec.rb
|
fix_auth now handles recursive settings (cherry picked from commit 365c1a0) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702072
Hammer backport details:
|
situation:
miq_request_tasks
has anoptions
hash with recursive values.fix_auth
recurses all theoptions
looking for passwords to convert.before
it recurses forever
after
it now detects the recursion and does not go forever
NOTE: this only detects very simple recursive cases.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1696237
(Review spec with ignore whitespace may be easier to view)