Skip to contentSkip to conversation

cve-report: Add summary counts of CVEs by recipe

PATCH New Richard Purdie 1 participant 1 message Jan 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cve-report: Add summary counts of CVEs by recipe

It is often helpful to know how many CVEs are open against a given recipe. Add a summary table of this to the end of the CVE listing.

---
 scripts/cve-report.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/cve-report.py +14 -0
index 7a95668..203ea6d 100755
@@ -12,6 +12,7 @@ with open(jsonfile) as f:
     cvedata = json.load(f)
 
 cves = dict()
+recipe_counts = {}
 
 for recipe in cvedata['package']:
     if recipe['name'] in ignored_recipes:
@@ -28,3 +29,16 @@ for recipe in cvedata['package']:
 print("Found %d unpatched CVEs" % len(cves))
 for cve in sorted(cves.keys()):
     print("%s: %s https://web.nvd.nist.gov/view/vuln/detail?vulnId=%s *" % (cve, cves[cve], cve))
+
+for cve in cves:
+    recipename = cves[cve]
+    if recipename in recipe_counts:
+        recipe_counts[recipename] += 1
+    else:
+        recipe_counts[recipename] = 1
+
+
+print("\n")
+print("Summary of CVE counts by recipes:\n")
+for recipe, count in sorted(recipe_counts.items(), key=lambda x: x[1], reverse=True):
+    print("  %s: %s" % (recipe, count))
Signature · 1 line
2.40.1