Skip to content

Commit

Permalink
Update parsing because of schema change
Browse files Browse the repository at this point in the history
  • Loading branch information
PushkarJ committed Nov 19, 2021
1 parent 446c8e2 commit 2738aed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions models/trivy_json_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def parse(scan_results_directory)
next
end
begin
results = JSON.parse(result_json)
report = JSON.parse(result_json)
rescue JSON::ParserError => e
STDERR.puts "Error #{e} while parsing #{relative_filename}"
end
Expand All @@ -30,7 +30,8 @@ def parse(scan_results_directory)
#may not work if there is a : in the imagePath or Tag. ;)
imagePath, imageTag = filename.sub("-trivy.json", "").sub(".trivy.json", "").sub("__", "/").split(":")

if (!results.empty?)
if (!report.empty?)
results = report["Results"] || []
results.each do |result|
target_vuln_data = result["Vulnerabilities"] || []
target_vuln_data.each do |vuln_data|
Expand Down

0 comments on commit 2738aed

Please sign in to comment.