summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-11-16 11:58:58 -0800
committerPete Higgins <pete@peterhiggins.org>2020-12-01 16:12:04 -0800
commit9f98233dec89a93adda0eb364950484631464a36 (patch)
tree82f2a404f51b8a07e9663370f5d0bb9dbf35eba9
parenta287626b0d3c01cc8713279a643fac373abca64e (diff)
downloadchef-9f98233dec89a93adda0eb364950484631464a36.tar.gz
Simplify waiver handling by deferring to Inspec.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/audit/runner.rb11
-rw-r--r--spec/unit/audit/runner_spec.rb18
2 files changed, 1 insertions, 28 deletions
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index 75a8f9a7ca..9dbf6b2a70 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -61,15 +61,6 @@ class Chef
end
def inspec_opts
- waivers = Array(audit_attributes["waiver_file"]).select do |file|
- if File.exist?(file)
- true
- else
- logger.error "The specified InSpec waiver file #{file} is missing, skipping it..."
- false
- end
- end
-
{
backend_cache: audit_attributes["inspec_backend_cache"],
inputs: audit_attributes["attributes"],
@@ -79,7 +70,7 @@ class Chef
reporter: ["json-automate"],
reporter_backtrace_inclusion: audit_attributes["result_include_backtrace"],
reporter_message_truncation: audit_attributes["result_message_limit"],
- waiver_file: waivers,
+ waiver_file: Array(audit_attributes["waiver_file"]),
}
end
diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb
index 76326dfbe0..ee2da2a812 100644
--- a/spec/unit/audit/runner_spec.rb
+++ b/spec/unit/audit/runner_spec.rb
@@ -55,22 +55,4 @@ describe Chef::Audit::Runner do
expect(runner).not_to be_enabled
end
end
-
- describe "#inspec_opts" do
- it "accepts a string as a waiver file" do
- node.default["audit"][:waiver_file] = __FILE__
-
- expect(logger).not_to receive(:error)
-
- expect(runner.inspec_opts[:waiver_file]).to eq([__FILE__])
- end
-
- it "filters out non-existant waiver files" do
- node.default["audit"][:waiver_file] = [__FILE__, "some_other_file"]
-
- expect(logger).to receive(:error).with(/some_other_file is missing/)
-
- expect(runner.inspec_opts[:waiver_file]).to eq([__FILE__])
- end
- end
end