diff mbox series

[yocto-autobuilder-helper] cve-report: Add summary counts of CVEs by recipe

Message ID 20240123143510.613306-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [yocto-autobuilder-helper] cve-report: Add summary counts of CVEs by recipe | expand

Commit Message

Richard Purdie Jan. 23, 2024, 2:35 p.m. UTC
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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/cve-report.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/scripts/cve-report.py b/scripts/cve-report.py
index 7a95668..203ea6d 100755
--- a/scripts/cve-report.py
+++ b/scripts/cve-report.py
@@ -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))