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

Use YAML.load to load classes beyond the basic types #407

Merged

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Jan 9, 2020

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

Followup to ManageIQ/manageiq#19701

The prior behavior in core was to treat YAML.safe_load like YAML.load so let's change
some of these to .load for now. We'll enumerate the list of classes where we
can.

Also, fix typo of backtick instead of quote.

@coveralls
Copy link

coveralls commented Jan 9, 2020

Pull Request Test Coverage Report for Build 3557

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 85.396%

Totals Coverage Status
Change from base Build 3481: 0.0%
Covered Lines: 5064
Relevant Lines: 5930

💛 - Coveralls

@@ -104,13 +104,13 @@
end

it 'loads object from yaml' do
expect(YAML.safe_load(svc_service.to_yaml)).to eq(svc_service)
expect(YAML.load(svc_service.to_yaml)).to eq(svc_service)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest we pass MiqAeMethodService::MiqAeServiceService to safe_load on this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to see you say Service Service Service 🤣

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need HashWithIndifferentAccess too. I'll check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just Service ServiceService was enough

end

it 'loads invalid svc_model for objects without related ar_model' do
yaml = svc_service.to_yaml
service.delete
model_from_yaml = YAML.safe_load(yaml)
model_from_yaml = YAML.load(yaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, Pass MiqAeMethodService::MiqAeServiceService to safe_load.

@@ -280,6 +280,6 @@ def create_restart_model(script1, script2, script3)
expect(MiqQueue.count).to eq(2)
q = MiqQueue.where(:state => 'ready').first
expect(q[:server_guid]).to be_nil
expect(YAML.safe_load(q.args.first[:ae_state_data])).to eq(ae_state_data)
expect(YAML.load(q.args.first[:ae_state_data])).to eq(ae_state_data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is better off using load for now.

@jrafanie jrafanie force-pushed the fix_invalid_usage_of_yaml_safe_load branch from 53b4b32 to 9c9f88b Compare January 9, 2020 18:47
https://bugzilla.redhat.com/show_bug.cgi?id=1789153

Followup to ManageIQ/manageiq#19701

The prior behavior in core was to treat YAML.safe_load like YAML.load so let's change
some of these to .load for now.  We'll enumerate the list of classes where we
can.
https://bugzilla.redhat.com/show_bug.cgi?id=1789153

Followup to ManageIQ/manageiq#19701

Seen when run locally or in travis output:

```
472.50s$ bundle exec rake
** ManageIQ master, codename: Jansa
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's 'rails' settings.
** ManageIQ master, codename: Jansa
/home/travis/build/ManageIQ/manageiq-automation_engine/vendor/bundle/gems/rspec-core-3.9.1/exe/rspec: No such file or directory - does
/home/travis/build/ManageIQ/manageiq-automation_engine/vendor/bundle/gems/rspec-core-3.9.1/exe/rspec: No such file or directory - does
Randomized with seed 8807
....
```
@jrafanie jrafanie force-pushed the fix_invalid_usage_of_yaml_safe_load branch from 9c9f88b to c51ae7a Compare January 9, 2020 19:16
@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2020

Checked commits jrafanie/manageiq-automation_engine@963ffa9~...c51ae7a with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 1 offense detected

spec/engine/miq_ae_state_machine_retry_spec.rb

@gmcculloug gmcculloug merged commit 6fe3c54 into ManageIQ:master Jan 9, 2020
@gmcculloug gmcculloug added this to the Sprint 128 Ending Jan 20, 2020 milestone Jan 9, 2020
@jrafanie jrafanie deleted the fix_invalid_usage_of_yaml_safe_load branch January 31, 2024 16:40
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.

5 participants