mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Merge pull request #5989 from inspec/vasundhara/fix-compliance-profile-upload
CFINSPEC-181: Fix unable to upload inspec compliance profile using to…
This commit is contained in:
commit
984ebc4075
3 changed files with 13 additions and 9 deletions
|
@ -95,6 +95,8 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
desc "check PATH", "verify all tests at the specified PATH"
|
||||
option :format, type: :string,
|
||||
desc: "The output format to use doc (default), json. If valid format is not provided then it will use the default."
|
||||
option :with_cookstyle, type: :boolean,
|
||||
desc: "Enable or disable cookstyle checks.", default: false
|
||||
profile_options
|
||||
def check(path) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
||||
o = config
|
||||
|
|
|
@ -105,6 +105,7 @@ module Inspec
|
|||
@check_mode = options[:check_mode] || false
|
||||
@parent_profile = options[:parent_profile]
|
||||
@legacy_profile_path = options[:profiles_path] || false
|
||||
@check_cookstyle = options[:with_cookstyle]
|
||||
Metadata.finalize(@source_reader.metadata, @profile_id, options)
|
||||
|
||||
# if a backend has already been created, clone it so each profile has its own unique backend object
|
||||
|
@ -655,12 +656,13 @@ module Inspec
|
|||
end
|
||||
|
||||
# Running cookstyle to check for code offenses
|
||||
cookstyle_linting_check.each do |lint_output|
|
||||
data = lint_output.split(":")
|
||||
msg = "#{data[-2]}:#{data[-1]}"
|
||||
offense.call(data[0], data[1], data[2], nil, msg)
|
||||
if @check_cookstyle
|
||||
cookstyle_linting_check.each do |lint_output|
|
||||
data = lint_output.split(":")
|
||||
msg = "#{data[-2]}:#{data[-1]}"
|
||||
offense.call(data[0], data[1], data[2], nil, msg)
|
||||
end
|
||||
end
|
||||
|
||||
# profile is valid if we could not find any error & offenses
|
||||
result[:summary][:valid] = result[:errors].empty? && result[:offenses].empty?
|
||||
|
||||
|
|
|
@ -118,16 +118,16 @@ describe "inspec check" do
|
|||
end
|
||||
|
||||
describe "inspec check also check for cookstyle offenses" do
|
||||
it "finds no offenses in a complete profile" do
|
||||
it "finds no offenses in a complete profile when --with-cookstyle option is provided" do
|
||||
skip if windows? # see #5723
|
||||
out = inspec("check #{profile_path}/complete-profile")
|
||||
out = inspec("check #{profile_path}/complete-profile --with-cookstyle")
|
||||
_(out.stdout).must_match(/No errors, warnings, or offenses/)
|
||||
assert_exit_code 0, out
|
||||
end
|
||||
|
||||
it "fails and returns offenses in a profile" do
|
||||
it "fails and returns offenses in a profile when --with-cookstyle option is provided" do
|
||||
skip if windows? # see #5723
|
||||
out = inspec("check #{profile_path}/inputs/metadata-basic")
|
||||
out = inspec("check #{profile_path}/inputs/metadata-basic --with-cookstyle")
|
||||
_(out.stdout).must_match(/1 offenses/)
|
||||
assert_exit_code 1, out
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue