From 06f16a465af568789e946c1cb11c6d4935a3ccf8 Mon Sep 17 00:00:00 2001 From: Mad Pete Guy Date: Thu, 22 Feb 2024 01:23:54 +0100 Subject: [PATCH] Fixed error where no Description exists. --- imgdata/scripts/trivy-json-to-junitxml.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/imgdata/scripts/trivy-json-to-junitxml.py b/imgdata/scripts/trivy-json-to-junitxml.py index e8358f6..c2d2bc3 100644 --- a/imgdata/scripts/trivy-json-to-junitxml.py +++ b/imgdata/scripts/trivy-json-to-junitxml.py @@ -85,10 +85,9 @@ def main(argv): name = "[{0}] {1}".format(json_vuln['Severity'], json_vuln['VulnerabilityID']) classname = "{0}-{1}".format(json_vuln['PkgName'], json_vuln['InstalledVersion']) tc = xml_testcase(ts, name, classname) - title = '' - if 'Title' in json_vuln: - title = json_vuln['Title'] - xml_failure(tc, title, json_vuln['Description']) + title = 'Title' in json_vuln and json_vuln['Title'] or '' + description = 'Description' in json_vuln and json_vuln['Description'] or '' + xml_failure(tc, title, description) print(f"Save {xml_path}") (Path.cwd() / os.path.dirname(xml_path)).mkdir(parents=True, exist_ok=True) xml_file = open(xml_path, "w", encoding="utf-8")