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:
Stephan Renatus 2016-01-11 09:01:54 +01:00
parent 125b6a5db4
commit ee62499fc0
2 changed files with 6 additions and 4 deletions

View file

@ -52,8 +52,10 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength
def json(path)
diagnose
profile = Inspec::Profile.from_path(path, opts)
dst = opts[:output].to_s
o = opts.dup
o[:ignore_supports] = true
profile = Inspec::Profile.from_path(path, o)
dst = o[:output].to_s
if dst.empty?
puts JSON.pretty_generate(profile.info)
else
@ -73,7 +75,7 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength
o = opts.dup
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)
exit 1 unless profile.check
end

View file

@ -54,7 +54,7 @@ module Inspec
Inspec::Metadata.from_ref(x[:ref], x[:content], @profile_id, @conf[:logger])
end
metas.each do |meta|
return [] if !ignore_supports && !meta.supports_transport?(@backend)
return [] unless ignore_supports || meta.supports_transport?(@backend)
end
assets
end