-
Notifications
You must be signed in to change notification settings - Fork 896
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
Keep full model name when parsing expression with tag #16211
Keep full model name when parsing expression with tag #16211
Conversation
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.
LGTM thanks @yrudman 👍
lib/miq_expression/tag.rb
Outdated
@@ -1,6 +1,6 @@ | |||
class MiqExpression::Tag < MiqExpression::Target | |||
REGEX = / | |||
(?<model_name>([[:alnum:]]*(::)?)?) | |||
(?<model_name>([[:alnum:]]*(::)?)*) |
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.
@yrudman you need probably limit count of ::
Problem is failing case like, it is too slow.
MiqExpression::Tag.parse('ManageIQ::Providers::CloudManagermanaged-se')
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.
👍 nice catch @lpichler
parsing your example from console never finished and was interrupted after 2 minutes.
And parsing it on master returning nil
. So, limiting ::
looks like good idea.
…finity loop inside regex when parsing strings like 'ManageIQ::Providers::CloudManagermanaged-se'
d6b9717
to
7822c56
Compare
9a6f26d
to
1ef3fb0
Compare
Checked commits yrudman/manageiq@071592a~...1ef3fb0 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
https://bugzilla.redhat.com/show_bug.cgi?id=1519809 This will prevent an infinite loop inside regex when parsing strings like "ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name" This is a manual partial backport of b19567a which was in PR: ManageIQ#16211 Before this change, this will spin at 100% cpu in rails console: MiqExpression::Tag.parse("ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name") After this change, it returns nil nearly immediately.
https://bugzilla.redhat.com/show_bug.cgi?id=1519809 This will prevent an infinite loop inside regex when parsing strings like "ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name" This is a manual partial backport of b19567a which was in PR: ManageIQ#16211 Before this change, this will spin at 100% cpu in rails console: MiqExpression::Tag.parse("ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name") After this change, it returns nil nearly immediately.
Issue:
MiqExpression::Tag.parse
does not return full model name. Parsing tag likeManageIQ::Providers::CloudManager.managed-service_level
will returnCloudManager
and>> "CloudManager".safe_constantize => nil
https://bugzilla.redhat.com/show_bug.cgi?id=1501333
Solution:
keep full model name when parsing
Example: group has assigned filter expression
and tag was assigned to some instances of gce provider
BEFORE:
AFTER:
@miq-bot add-label bug, core
\cc @gtanzillo @imtayadeway