File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
lib/miq_automation_engine/engine/miq_ae_engine Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,14 @@ class AutomateMethodException < StandardError
110
110
require 'drb'
111
111
require 'yaml'
112
112
113
+ YAML.singleton_class.prepend(
114
+ Module.new do
115
+ def safe_load(yaml, aliases: false, **kwargs)
116
+ super(yaml, aliases: true, **kwargs)
117
+ end
118
+ end
119
+ )
120
+
113
121
Time.zone = 'UTC'
114
122
115
123
MIQ_OK = 0
Original file line number Diff line number Diff line change @@ -47,6 +47,38 @@ def root
47
47
end
48
48
end
49
49
50
+ context "with a script that tries to YAML.load with aliases" do
51
+ let ( :script ) do
52
+ <<-RUBY
53
+ YAML.load("---\n a: &a\n b: true \n \n development:\n <<: *a\n c: false\n \n ")
54
+ RUBY
55
+ end
56
+
57
+ it "logs and returns the correct exit status" do
58
+ allow ( $miq_ae_logger) . to receive ( :info ) . and_call_original
59
+ expect ( $miq_ae_logger) . to receive ( :info ) . with ( "Method exited with rc=MIQ_OK" , :resource_id => 123 ) . at_least ( :once )
60
+ expect ( $miq_ae_logger) . to_not receive ( :error )
61
+
62
+ expect ( subject ) . to eq ( 0 )
63
+ end
64
+ end
65
+
66
+ context "with a script that tries to YAML.safe_load with aliases" do
67
+ let ( :script ) do
68
+ <<-RUBY
69
+ YAML.safe_load("---\n a: &a\n b: true \n \n development:\n <<: *a\n c: false\n \n ")
70
+ RUBY
71
+ end
72
+
73
+ it "logs and returns the correct exit status" do
74
+ allow ( $miq_ae_logger) . to receive ( :info ) . and_call_original
75
+ expect ( $miq_ae_logger) . to receive ( :info ) . with ( "Method exited with rc=MIQ_OK" , :resource_id => 123 ) . at_least ( :once )
76
+ expect ( $miq_ae_logger) . to_not receive ( :error )
77
+
78
+ expect ( subject ) . to eq ( 0 )
79
+ end
80
+ end
81
+
50
82
context "with a script that raises" do
51
83
let ( :script ) do
52
84
<<-RUBY
You can’t perform that action at this time.
0 commit comments