Skip to content

Commit 3096b0a

Browse files
authored
Merge pull request #13710 from Jino-T/qualys-fix
Qualys parser add CVEs to Vulnerability Ids for xml files
2 parents 9d83ea6 + b5a7f9e commit 3096b0a

2 files changed

Lines changed: 33 additions & 10 deletions

File tree

dojo/tools/qualys/parser.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,16 @@ def parse_finding(host, tree):
311311
split_cvss(cvss2, temp)
312312
# DefectDojo does not support cvssv2
313313
temp["CVSS_vector"] = None
314-
315314
# CVE and LINKS
316-
temp_cve_details = vuln_item.iterfind("CVE_ID_LIST/CVE_ID")
317-
if temp_cve_details:
318-
cl = {
319-
cve_detail.findtext("ID"): cve_detail.findtext("URL")
320-
for cve_detail in temp_cve_details
321-
}
322-
temp["cve"] = "\n".join(list(cl.keys()))
323-
temp["links"] = "\n".join(list(cl.values()))
315+
temp_cve_details = [(cve.findtext("ID"), cve.findtext("URL")) for cve in vuln_item.iterfind("CVE_ID_LIST/CVE_ID")]
316+
temp["cve_list"] = [cve_id for cve_id, _ in temp_cve_details if cve_id]
317+
temp["links"] = [url for _, url in temp_cve_details if url]
324318

325319
# Generate severity from number in XML's 'SEVERITY' field, if not present default to 'Informational'
326320
sev = get_severity(vuln_item.findtext("SEVERITY"))
327321
finding = None
328322
if temp_cve_details:
329-
refs = "\n".join(list(cl.values()))
323+
refs = temp.get("links", "")
330324
finding = Finding(
331325
title="QID-" + gid[4:] + " | " + temp["vuln_name"],
332326
mitigation=temp["solution"],
@@ -363,6 +357,7 @@ def parse_finding(host, tree):
363357
finding.verified = True
364358
finding.unsaved_endpoints = []
365359
finding.unsaved_endpoints.append(ep)
360+
finding.unsaved_vulnerability_ids = temp.get("cve_list", [])
366361
ret_rows.append(finding)
367362
return ret_rows
368363

unittests/tools/test_qualys_parser.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,38 @@ def test_parse_file_with_cvss_values_and_scores(self):
151151
for finding in findings:
152152
if finding.unsaved_endpoints[0].host == "demo14.s02.sjc01.qualys.com" and finding.title == "QID-370876 | AMD Processors Multiple Security Vulnerabilities (RYZENFALL/MASTERKEY/CHIMERA-FW/FALLOUT)":
153153
finding_cvssv3_score = finding
154+
self.assertEqual(
155+
finding.unsaved_vulnerability_ids,
156+
[
157+
"CVE-2018-8930",
158+
"CVE-2018-8931",
159+
"CVE-2018-8932",
160+
"CVE-2018-8933",
161+
"CVE-2018-8934",
162+
"CVE-2018-8935",
163+
"CVE-2018-8936",
164+
],
165+
)
154166
if finding.unsaved_endpoints[0].host == "demo13.s02.sjc01.qualys.com" and finding.title == "QID-370876 | AMD Processors Multiple Security Vulnerabilities (RYZENFALL/MASTERKEY/CHIMERA-FW/FALLOUT)":
155167
finding_no_cvssv3_at_detection = finding
168+
self.assertEqual(
169+
finding.unsaved_vulnerability_ids,
170+
[
171+
"CVE-2018-8930",
172+
"CVE-2018-8931",
173+
"CVE-2018-8932",
174+
"CVE-2018-8933",
175+
"CVE-2018-8934",
176+
"CVE-2018-8935",
177+
"CVE-2018-8936",
178+
],
179+
)
156180
if finding.unsaved_endpoints[0].host == "demo14.s02.sjc01.qualys.com" and finding.title == 'QID-121695 | NTP "monlist" Feature Denial of Service Vulnerability':
157181
finding_no_cvssv3 = finding
182+
self.assertEqual(
183+
finding.unsaved_vulnerability_ids,
184+
["CVE-2013-5211"],
185+
)
158186
# The CVSS Vector is not used from the Knowledgebase
159187
self.assertEqual(
160188
# CVSS_FINAL is defined without a cvssv3 vector

0 commit comments

Comments
 (0)