mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Fix for #4977 by adding a cleanup function for CLI inputs
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
824018efa3
commit
d9f2cdb171
1 changed files with 14 additions and 1 deletions
|
@ -166,8 +166,9 @@ module Inspec
|
|||
end
|
||||
end
|
||||
input_name, input_value = pair.split("=")
|
||||
input_value = clean_up_cli_input_value(input_value)
|
||||
evt = Inspec::Input::Event.new(
|
||||
value: input_value.chomp(","), # Trim trailing comma if any
|
||||
value: input_value,
|
||||
provider: :cli,
|
||||
priority: 50
|
||||
)
|
||||
|
@ -175,6 +176,18 @@ module Inspec
|
|||
end
|
||||
end
|
||||
|
||||
# Remove trailing commas, resolve type.
|
||||
def clean_up_cli_input_value(given_value)
|
||||
value = given_value.chomp(",") # Trim trailing comma if any
|
||||
if value =~ /^-?\d+$/
|
||||
value = value.to_i
|
||||
elsif value =~ /^-?\d+\.\d+$/
|
||||
value = value.to_f
|
||||
end
|
||||
value
|
||||
end
|
||||
|
||||
|
||||
def bind_inputs_from_runner_api(profile_name, input_hash)
|
||||
# TODO: move this into a core plugin
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue