Skip to contentSkip to conversation

cve-check: restore CVE_CHECK_SHOW_WARNINGS functionality

PATCH New Peter Marko 1 participant 2 messages Nov 24, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cve-check: restore CVE_CHECK_SHOW_WARNINGS functionality

From: Peter Marko <[email protected]>

Commit 05ef4f2a7b225c8d230eaca8d333ffb921729d79 removed this functionality by accident. It was implemented in text exporter, while it should have been a global feature independent on exporter type to avoid such accidental deletion.

Cc Marta Rybczynska <[email protected]>
---
 meta/classes/cve-check.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/cve-check.bbclass +5 -0
index 0c92b87f52..33d41b912d 100644
@@ -422,6 +422,11 @@ def check_cves(d, cve_data):
     if not cves_in_recipe:
         bb.note("No CVE records for products in recipe %s" % (pn))
 
+    if d.getVar("CVE_CHECK_SHOW_WARNINGS") == "1":
+        unpatched_cves = [cve for cve in cve_data if cve_data[cve]["abbrev-status"] == "Unpatched"]
+        if unpatched_cves:
+            bb.warn("Found unpatched CVE (%s)" % " ".join(unpatched_cves))
+
     return (cve_data, cves_status)
 
 def get_cve_info(d, cve_data):
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 cve-check: fix cvesInRecord

From: Peter Marko <[email protected]>

Currently flag cvesInRecord is set to false if all CVEs are ignored or patched. This is inconsistent as it shows false if a CVE was fixed via patch and true if this CVE was fixed by upgrade. In both cases the CVE is valid and was fixed.

As I understand this flag, it should say if any CVE exists for particular component's product (regardless of how this CVE is handled) and can be used to validate if a product is correctly set.

Note that skipping ignored CVEs may make sense in some cases, as ignored may mean that NVD DB is wrong, but in many cases it is ignored for other reasons. Further patch can be done to evaluate ignore subtype but that would be against my understanding of this flag as described above.

---
 meta/classes/cve-check.bbclass | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/classes/cve-check.bbclass +7 -6
index 33d41b912d..6e10dd915a 100644
@@ -343,18 +343,19 @@ def check_cves(d, cve_data):
         for cverow in cve_cursor:
             cve = cverow[0]
 
-            if cve_is_ignored(d, cve_data, cve):
-                bb.note("%s-%s ignores %s" % (product, pv, cve))
-                continue
-            elif cve_is_patched(d, cve_data, cve):
-                bb.note("%s has been patched" % (cve))
-                continue
             # Write status once only for each product
             if not cves_in_product:
                 cves_status.append([product, True])
                 cves_in_product = True
                 cves_in_recipe = True
 
+            if cve_is_ignored(d, cve_data, cve):
+                bb.note("%s-%s ignores %s" % (product, pv, cve))
+                continue
+            elif cve_is_patched(d, cve_data, cve):
+                bb.note("%s has been patched" % (cve))
+                continue
+
             vulnerable = False
             ignored = False
 
Signature · 1 line
2.30.2