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

fix_auth now handles recursive settings #18631

Merged
merged 1 commit into from
Apr 5, 2019

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Apr 4, 2019

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.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1696237

(Review spec with ignore whitespace may be easier to view)

@kbrock
Copy link
Member Author

kbrock commented Apr 4, 2019

  1. cops 46, 49, 59 are unchanged code (I indented them) - I want to leave as close to original.
  2. cops 72: Rails serialize and fix_auth both use YAML.load - I need to keep consistent with them.

@kbrock kbrock requested a review from Fryguy April 5, 2019 12:53
@@ -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
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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
@kbrock kbrock force-pushed the recursive_passwords branch from a77c17c to 2eabc44 Compare April 5, 2019 14:51
@miq-bot
Copy link
Member

miq-bot commented Apr 5, 2019

Checked commit kbrock@2eabc44 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 4 offenses detected

spec/lib/vmdb/settings_spec.rb

@carbonin carbonin self-assigned this Apr 5, 2019
@carbonin carbonin merged commit 365c1a0 into ManageIQ:master Apr 5, 2019
@carbonin carbonin added this to the Sprint 109 Ending Apr 15, 2019 milestone Apr 5, 2019
@kbrock kbrock deleted the recursive_passwords branch April 5, 2019 17:26
simaishi pushed a commit that referenced this pull request Apr 22, 2019
fix_auth now handles recursive settings

(cherry picked from commit 365c1a0)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702072
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 58bf5843bf92e394639fe05d8b75aaa2948d27a8
Author: Nick Carboni <[email protected]>
Date:   Fri Apr 5 11:24:48 2019 -0400

    Merge pull request #18631 from kbrock/recursive_passwords
    
    fix_auth now handles recursive settings
    
    (cherry picked from commit 365c1a02de560bf7ce9e173c61986de08e19baee)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants