Skip to content

Commit b5a7f9e

Browse files
committed
Refactor CVE extraction in parse_finding to use list comprehensions for improved readability
1 parent c8b521a commit b5a7f9e

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

dojo/tools/qualys/parser.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,24 +311,10 @@ 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 = list(vuln_item.iterfind("CVE_ID_LIST/CVE_ID"))
317-
if temp_cve_details:
318-
cve_list = []
319-
link_list = []
320-
for cve_detail in temp_cve_details:
321-
cve_id = cve_detail.findtext("ID")
322-
cve_url = cve_detail.findtext("URL")
323-
if cve_id:
324-
cve_list.append(cve_id)
325-
if cve_url:
326-
link_list.append(cve_url)
327-
328-
temp["cve_list"] = cve_list # list of CVE strings
329-
temp["links"] = "\n".join(link_list)
330-
else:
331-
temp["cve_list"] = []
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]
332318

333319
# Generate severity from number in XML's 'SEVERITY' field, if not present default to 'Informational'
334320
sev = get_severity(vuln_item.findtext("SEVERITY"))

0 commit comments

Comments
 (0)