Skip to content

Commit

Permalink
Update nautobot_device_lifecycle_mgmt/jobs/cve_tracking.py
Browse files Browse the repository at this point in the history
Using Przemek's suggestion for processing CVEs

Co-authored-by: Przemek Rogala <[email protected]>
  • Loading branch information
bminnix and progala authored Nov 29, 2024
1 parent e003333 commit 60bc3ce
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions nautobot_device_lifecycle_mgmt/jobs/cve_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,20 @@ def process_cves(self, cve_list, dlc_cves, software_id):
dict: Dictionary of CVEs in either new or existing categories
"""
processed_cve_info = {"new": {}, "existing": {}}
if cve_list:
for cve in cve_list:
cve_name = cve["id"]
if cve_name.startswith("CVE"):
if cve_name not in dlc_cves:
processed_cve_info["new"].update({cve_name: self.prep_cve_for_dlc(cve)})
else:
processed_cve_info["existing"].update({cve_name: self.prep_cve_for_dlc(cve)})
self.logger.info(
"Prepared %s CVE for creation." % len(processed_cve_info["new"]),
extra={"object": SoftwareVersion.objects.get(id=software_id), "grouping": "CVE Creation"},
)
if not cve_list:
return processed_cve_info
for cve in cve_list:
cve_name = cve["id"]
if not cve_name.startswith("CVE"):
continue
if cve_name not in dlc_cves:
processed_cve_info["new"].update({cve_name: self.prep_cve_for_dlc(cve)})
else:
processed_cve_info["existing"].update({cve_name: self.prep_cve_for_dlc(cve)})
self.logger.info(
"Prepared %s CVE for creation." % len(processed_cve_info["new"]),
extra={"object": SoftwareVersion.objects.get(id=software_id), "grouping": "CVE Creation"},
)

return processed_cve_info

Expand Down

0 comments on commit 60bc3ce

Please sign in to comment.