mirror of
https://github.com/inspec/inspec
synced 2025-02-18 15:08:44 +00:00
bugfix: ignore supports when generating a profile's json representation
without this, `inspec json PATH` does never contain rules != {}, because of the usage of the mock backend
This commit is contained in:
parent
125b6a5db4
commit
ee62499fc0
2 changed files with 6 additions and 4 deletions
|
@ -52,8 +52,10 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength
|
||||||
def json(path)
|
def json(path)
|
||||||
diagnose
|
diagnose
|
||||||
|
|
||||||
profile = Inspec::Profile.from_path(path, opts)
|
o = opts.dup
|
||||||
dst = opts[:output].to_s
|
o[:ignore_supports] = true
|
||||||
|
profile = Inspec::Profile.from_path(path, o)
|
||||||
|
dst = o[:output].to_s
|
||||||
if dst.empty?
|
if dst.empty?
|
||||||
puts JSON.pretty_generate(profile.info)
|
puts JSON.pretty_generate(profile.info)
|
||||||
else
|
else
|
||||||
|
@ -73,7 +75,7 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength
|
||||||
|
|
||||||
o = opts.dup
|
o = opts.dup
|
||||||
o[:logger] = Logger.new(STDOUT)
|
o[:logger] = Logger.new(STDOUT)
|
||||||
o[:ignore_supports] = true # we check for integrety only
|
o[:ignore_supports] = true # we check for integrity only
|
||||||
profile = Inspec::Profile.from_path(path, o)
|
profile = Inspec::Profile.from_path(path, o)
|
||||||
exit 1 unless profile.check
|
exit 1 unless profile.check
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ module Inspec
|
||||||
Inspec::Metadata.from_ref(x[:ref], x[:content], @profile_id, @conf[:logger])
|
Inspec::Metadata.from_ref(x[:ref], x[:content], @profile_id, @conf[:logger])
|
||||||
end
|
end
|
||||||
metas.each do |meta|
|
metas.each do |meta|
|
||||||
return [] if !ignore_supports && !meta.supports_transport?(@backend)
|
return [] unless ignore_supports || meta.supports_transport?(@backend)
|
||||||
end
|
end
|
||||||
assets
|
assets
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue