From 53b4b32d37bc1c3167a9bda7f8553a58ce6411d3 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 9 Jan 2020 11:48:29 -0500 Subject: [PATCH] Use YAML.load to load classes beyond the basic types https://bugzilla.redhat.com/show_bug.cgi?id=1789153 Followup to ManageIQ/manageiq#19701 We're trying to load MiqAeMethodService::MiqAeServiceService and ActiveSupport::HashWithIndifferentAccess in these places. The prior behavior in core was to treat YAML.safe_load like YAML.load so let's change these to .load for now. If we want to use safe_load, we'll need to enumerate all of the additional classes we want to allow to be loaded beyond the ruby basic types. --- .../miq_ae_method_service/miq_ae_service_model_base_spec.rb | 4 ++-- spec/engine/miq_ae_state_machine_retry_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb index 100705f9c..fd788f48e 100644 --- a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb +++ b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb @@ -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) 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) expect { model_from_yaml.reload }.to raise_error( NoMethodError, "undefined method `reload' for nil:NilClass" diff --git a/spec/engine/miq_ae_state_machine_retry_spec.rb b/spec/engine/miq_ae_state_machine_retry_spec.rb index 0c320ad83..223c44856 100644 --- a/spec/engine/miq_ae_state_machine_retry_spec.rb +++ b/spec/engine/miq_ae_state_machine_retry_spec.rb @@ -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) end end