67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/inspec/cli.rb', line 67
def json(target)
require "json"
o = config
diagnose(o)
o["log_location"] = $stderr
configure_logger(o)
o[:backend] = Inspec::Backend.create(Inspec::Config.mock)
o[:check_mode] = true
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
profile = Inspec::Profile.for_target(target, o)
info = profile.info
info[:generator] = {
name: "inspec",
version: Inspec::VERSION,
}
dst = o[:output].to_s
if dst.empty?
puts JSON.dump(info)
else
if File.exist? dst
puts "----> updating #{dst}"
else
puts "----> creating #{dst}"
end
fdst = File.expand_path(dst)
File.write(fdst, JSON.dump(info))
end
rescue StandardError => e
pretty_handle_exception(e)
end
|