From ce80cf3cf9d8574acdc9c313f32cf3cabe428f9c Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Thu, 29 Aug 2019 15:41:01 -0700 Subject: [PATCH 1/2] First draft at waiver file processing. 1) Don't know how much filtering or rewriting we want at this level. 2) Don't know where to put the tests. Signed-off-by: Ryan Davis --- lib/inspec/base_cli.rb | 2 ++ lib/inspec/runner.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/inspec/base_cli.rb b/lib/inspec/base_cli.rb index da307b9fc..c4c2d8efb 100644 --- a/lib/inspec/base_cli.rb +++ b/lib/inspec/base_cli.rb @@ -137,6 +137,8 @@ module Inspec desc: "Specify one or more inputs directly on the command line, as --input NAME=VALUE" option :input_file, type: :array, desc: "Load one or more input files, a YAML file with values for the profile to use" + option :waiver_file, type: :array, + desc: "Load one or more waiver files." option :attrs, type: :array, desc: "Legacy name for --input-file - deprecated." option :create_lockfile, type: :boolean, diff --git a/lib/inspec/runner.rb b/lib/inspec/runner.rb index 7de009264..4d0a5e995 100644 --- a/lib/inspec/runner.rb +++ b/lib/inspec/runner.rb @@ -57,6 +57,12 @@ module Inspec RunnerRspec.new(@conf) end + if @conf[:waiver_file] + waivers = @conf.delete(:waiver_file) + @conf[:input_file] ||= [] + @conf[:input_file].concat waivers + end + # About reading inputs: # @conf gets passed around a lot, eventually to # Inspec::InputRegistry.register_external_inputs. From 7a718103c509d0f94e1c96f210fef1c6c3fdcc1f Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Thu, 29 Aug 2019 15:42:09 -0700 Subject: [PATCH 2/2] Minor cleanup in config.rb. The logic involved was unnecessary and had a hard-coded string in it that is now wrong. Signed-off-by: Ryan Davis --- lib/inspec/config.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/inspec/config.rb b/lib/inspec/config.rb index b14673472..3fd463a92 100644 --- a/lib/inspec/config.rb +++ b/lib/inspec/config.rb @@ -221,8 +221,8 @@ module Inspec path = determine_cfg_path(cli_opts) - cfg_io = File.open(path) if path - cfg_io || StringIO.new('{ "version": "1.1" }') + ver = KNOWN_VERSIONS.max + path ? File.open(path) : StringIO.new({ "version" => ver }.to_json) end def check_for_piped_config(cli_opts)