mirror of
https://github.com/inspec/inspec
synced 2024-11-30 16:39:20 +00:00
Convert minutes to seconds for consistent interface
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
9cc9090225
commit
6d7f5a240b
3 changed files with 9 additions and 16 deletions
|
@ -166,9 +166,9 @@ module Inspec
|
||||||
desc: "After normal execution order, results are sorted by control ID, or by file (default), or randomly. None uses legacy unsorted mode."
|
desc: "After normal execution order, results are sorted by control ID, or by file (default), or randomly. None uses legacy unsorted mode."
|
||||||
option :filter_empty_profiles, type: :boolean, default: false,
|
option :filter_empty_profiles, type: :boolean, default: false,
|
||||||
desc: "Filter empty profiles (profiles without controls) from the report."
|
desc: "Filter empty profiles (profiles without controls) from the report."
|
||||||
option :command_timeout, type: :numeric, default: 60,
|
option :command_timeout, type: :numeric, default: 3600,
|
||||||
desc: "Maximum minutes to allow commands to run during execution. Default 60.",
|
desc: "Maximum seconds to allow commands to run during execution. Default 3600.",
|
||||||
long_desc: "Maximum minutes to allow commands to run during execution. Default 60. A timed out command is considered an error."
|
long_desc: "Maximum seconds to allow commands to run during execution. Default 3600. A timed out command is considered an error."
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.help(*args)
|
def self.help(*args)
|
||||||
|
|
|
@ -321,9 +321,9 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
||||||
desc: "A space-delimited list of local folders containing profiles whose libraries and resources will be loaded into the new shell"
|
desc: "A space-delimited list of local folders containing profiles whose libraries and resources will be loaded into the new shell"
|
||||||
option :distinct_exit, type: :boolean, default: true,
|
option :distinct_exit, type: :boolean, default: true,
|
||||||
desc: "Exit with code 100 if any tests fail, and 101 if any are skipped but none failed (default). If disabled, exit 0 on skips and 1 for failures."
|
desc: "Exit with code 100 if any tests fail, and 101 if any are skipped but none failed (default). If disabled, exit 0 on skips and 1 for failures."
|
||||||
option :command_timeout, type: :numeric, default: 60,
|
option :command_timeout, type: :numeric, default: 3600,
|
||||||
desc: "Maximum minutes to allow a command to run. Default 60.",
|
desc: "Maximum seconds to allow a command to run. Default 3600.",
|
||||||
long_desc: "Maximum minutes to allow commands to run. Default 60. A timed out command is considered an error."
|
long_desc: "Maximum seconds to allow commands to run. Default 3600. A timed out command is considered an error."
|
||||||
option :inspect, type: :boolean, default: false, desc: "Use verbose/debugging output for resources."
|
option :inspect, type: :boolean, default: false, desc: "Use verbose/debugging output for resources."
|
||||||
def shell_func
|
def shell_func
|
||||||
o = config
|
o = config
|
||||||
|
|
|
@ -32,14 +32,7 @@ module Inspec::Resources
|
||||||
|
|
||||||
@command = cmd
|
@command = cmd
|
||||||
|
|
||||||
@timeout = options[:timeout]&.to_i || Inspec::Config.cached.final_options['command_timeout']&.to_i
|
@timeout = options[:timeout]&.to_i || Inspec::Config.cached.final_options['command_timeout']&.to_i || 3600
|
||||||
if @timeout
|
|
||||||
# train uses seconds but inspec advertises minutes
|
|
||||||
@timeout = @timeout * 60
|
|
||||||
else
|
|
||||||
warn "InSpec config is missing value for command_timeout. Defaulting to 60m"
|
|
||||||
@timeout = 3600
|
|
||||||
end
|
|
||||||
|
|
||||||
if options[:redact_regex]
|
if options[:redact_regex]
|
||||||
unless options[:redact_regex].is_a?(Regexp)
|
unless options[:redact_regex].is_a?(Regexp)
|
||||||
|
@ -57,7 +50,7 @@ module Inspec::Resources
|
||||||
inspec.backend.run_command(@command, timeout: @timeout)
|
inspec.backend.run_command(@command, timeout: @timeout)
|
||||||
rescue Train::CommandTimeoutReached
|
rescue Train::CommandTimeoutReached
|
||||||
raise Inspec::Exceptions::ResourceFailed,
|
raise Inspec::Exceptions::ResourceFailed,
|
||||||
"Command `#{@command}` timed out after #{@timeout / 60} minute(s)"
|
"Command `#{@command}` timed out after #{@timeout} seconds"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue