mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Use RunData object instead of Hash
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
402366c219
commit
935bb81e6f
1 changed files with 15 additions and 17 deletions
|
@ -13,33 +13,31 @@ module InspecPlugins::JsonMinReporter
|
|||
def report # rubocop:disable Metrics/AbcSize
|
||||
report = {
|
||||
controls: [],
|
||||
statistics: { duration: run_data[:statistics][:duration] },
|
||||
version: run_data[:version],
|
||||
statistics: { duration: run_data.statistics.duration },
|
||||
version: run_data.version,
|
||||
}
|
||||
|
||||
# collect all test results and add them to the report
|
||||
run_data[:profiles].each do |profile|
|
||||
profile_id = profile[:name]
|
||||
next unless profile[:controls]
|
||||
run_data.profiles.each do |profile|
|
||||
profile_id = profile.name
|
||||
|
||||
profile[:controls].each do |control|
|
||||
control_id = control[:id]
|
||||
next unless control[:results]
|
||||
profile.controls.each do |control|
|
||||
control_id = control.id
|
||||
|
||||
control[:results].each do |result|
|
||||
control.results.each do |result|
|
||||
result_for_report = {
|
||||
id: control_id,
|
||||
profile_id: profile_id,
|
||||
profile_sha256: profile[:sha256],
|
||||
status: result[:status],
|
||||
code_desc: result[:code_desc],
|
||||
profile_sha256: profile.sha256,
|
||||
status: result.status,
|
||||
code_desc: result.code_desc,
|
||||
}
|
||||
|
||||
result_for_report[:skip_message] = result[:skip_message] if result.key?(:skip_message)
|
||||
result_for_report[:resource] = result[:resource] if result.key?(:resource)
|
||||
result_for_report[:message] = result[:message] if result.key?(:message)
|
||||
result_for_report[:exception] = result[:exception] if result.key?(:exception)
|
||||
result_for_report[:backtrace] = result[:backtrace] if result.key?(:backtrace)
|
||||
result_for_report[:skip_message] = result.skip_message if result.non_nil?(:skip_message)
|
||||
result_for_report[:resource] = result.resource if result.non_nil?(:resource)
|
||||
result_for_report[:message] = result.message if result.non_nil?(:message)
|
||||
result_for_report[:exception] = result.exception if result.non_nil?(:exception)
|
||||
result_for_report[:backtrace] = result.backtrace if result.non_nil?(:backtrace)
|
||||
|
||||
report[:controls] << result_for_report
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue