Skip to content

Commit

Permalink
Merge pull request #558 from kbrock/tainted_int
Browse files Browse the repository at this point in the history
Avoid Fixnum
  • Loading branch information
Fryguy authored Oct 21, 2024
2 parents 8a9f945 + dccd5ad commit 5aff915
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def attribute_value_to_xml(value, xml)
case value.class.to_s
when 'MiqAePassword' then xml.Password(OPAQUE_PASSWORD)
when 'String' then xml.String(value)
when 'Fixnum' then xml.Fixnum(value)
when 'Fixnum', 'Integer' then xml.Integer(value)
when 'Symbol' then xml.Symbol(value.to_s)
when 'TrueClass', 'FalseClass' then xml.Boolean(value.to_s)
when /MiqAeMethodService::(.*)/ then xml.tag!($1.gsub(/::/, '-'), :object_id => value.object_id, :id => value.id)
Expand Down Expand Up @@ -490,7 +490,7 @@ def self.convert_value_based_on_datatype(value, datatype)
return false if datatype == 'FalseClass'
return Time.parse(value).getlocal if 'time'.casecmp?(datatype)
return value.to_sym if 'symbol'.casecmp?(datatype)
return value.to_i if 'integer'.casecmp?(datatype) || datatype == 'Fixnum'
return value.to_i if 'integer'.casecmp?(datatype) || 'fixnum'.casecmp?(datatype)
return value.to_f if 'float'.casecmp?(datatype)
return value.gsub(/[\[\]]/, '').strip.split(/\s*,\s*/) if datatype == 'array' && value.class == String
return decrypt_password(value) if datatype == 'password'
Expand Down
1 change: 1 addition & 0 deletions manageiq-automation_engine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "rubyzip", "~>2.0.0"
spec.add_dependency "drb"

spec.add_development_dependency "manageiq-style"
spec.add_development_dependency "simplecov", ">= 0.21.2"
Expand Down
2 changes: 1 addition & 1 deletion spec/miq_ae_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def value_match(value, xml_value)

context "integer" do
it "returns value to_i" do
%w[Integer integer Fixnum].each { |type| expect(described_class.convert_value_based_on_datatype("45", type)).to eq(45) }
%w[Integer integer].each { |type| expect(described_class.convert_value_based_on_datatype("45", type)).to eq(45) }
end
end

Expand Down

0 comments on commit 5aff915

Please sign in to comment.