Skip to content

Commit

Permalink
Use YAML.load to load classes beyond the basic types
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1789153

Followup to ManageIQ/manageiq#19701

At the very least, we know MiqExpression objects are in the YAML but other
custom classes could be in the YAML so we need to use YAML.load to return to the
prior behavior.
  • Loading branch information
jrafanie committed Jan 9, 2020
1 parent a6d920f commit 7675a05
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def set_pre_prov_vars

unless %w[image_miq_request_new miq_template_miq_request_new].include?(params[:pressed])
path_to_report = ManageIQ::UI::Classic::Engine.root.join("product", "views", provisioning_report).to_s
@view = MiqReport.new(YAML.safe_load(File.open(path_to_report), [Symbol]))
@view = MiqReport.new(YAML.load(File.open(path_to_report), [Symbol]))
@view.db = get_template_kls.to_s
report_scopes = %i[eligible_for_provisioning non_deprecated]
options = options_for_provisioning(@view.db, report_scopes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
it "use report_name when is passed" do
report_name = "ProvisionCloudTemplates.yaml"
path_to_report = ManageIQ::UI::Classic::Engine.root.join("product", "views", report_name).to_s
view = MiqReport.new(YAML.safe_load(File.open(path_to_report), [Symbol]))
view = MiqReport.new(YAML.load(File.open(path_to_report), [Symbol]))
expect(controller).to_not receive(:get_db_view)
controller.params = {:active_tree => "instances_tree"}
controller.params = {:model_name => "ManageIQ::Providers::CloudManager::Template"}
Expand Down
4 changes: 2 additions & 2 deletions spec/support/report_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def numeric_chart_simple
end

def null_data_chart_with_basic_condition
exp = YAML.safe_load('--- !ruby/object:MiqExpression
exp = YAML.load('--- !ruby/object:MiqExpression
exp:
INCLUDES:
field: Name
Expand All @@ -82,7 +82,7 @@ def null_data_chart_with_basic_condition
end

def null_data_chart_with_complex_condition
exp = YAML.safe_load('--- !ruby/object:MiqExpression
exp = YAML.load('--- !ruby/object:MiqExpression
exp:
and:
- IS:
Expand Down

0 comments on commit 7675a05

Please sign in to comment.