Skip to contentSkip to conversation

Fix CPE criteria matching

PATCH Applied Thomas Perale via buildroot 2 participants 11 messages Nov 3, 2025 – Nov 17, 2025

lore
Share & tools
lore
#0 lore raw

cover Fix CPE criteria matching

Hi,

The 'cve.py' library can be further improved to take into account the operators between the cpeMatch nodes (AND, OR).

I ran the cve-check script on an SBOM containing every packages in Buildroot before and after my changes to the 'cve.py' logic and then ran a diff on the SBOM vulnerabilities.
I also did a comparison with the result given by DependencyTrack and it's a really similar output.

This is the list of CVE this remove (it doesn't add any). I havn't checked them all but it mostly removes CVE with criteria without assigned version ('-').

- CVE-1999-0143
- CVE-1999-0289
- CVE-1999-0678
- CVE-1999-0713
- CVE-1999-1237
- CVE-1999-1412
- CVE-2007-0086
- CVE-2007-0450
- CVE-2007-2379
- CVE-2007-2728
- CVE-2007-3149
- CVE-2007-4596
- CVE-2007-5894
- CVE-2007-5902
- CVE-2007-6421
- CVE-2007-6422
- CVE-2007-6423
- CVE-2008-2168
- CVE-2009-0844
- CVE-2010-4176
- CVE-2011-1936
- CVE-2011-3346
- CVE-2011-3618
- CVE-2011-4613
- CVE-2012-0880
- CVE-2013-2018
- CVE-2013-4235
- CVE-2014-2580
- CVE-2014-4859
- CVE-2014-4860
- CVE-2014-8135
- CVE-2014-8136
- CVE-2014-8165
- CVE-2014-9278
- CVE-2014-9750
- CVE-2014-9751
- CVE-2014-9826
- CVE-2015-5313
- CVE-2015-7691
- CVE-2015-7692
- CVE-2015-7701
- CVE-2015-7702
- CVE-2015-7703
- CVE-2015-7704
- CVE-2015-7705
- CVE-2015-7848
- CVE-2015-7849
- CVE-2015-7850
- CVE-2015-7852
- CVE-2015-7853
- CVE-2015-7854
- CVE-2015-7855
- CVE-2015-7973
- CVE-2015-7974
- CVE-2015-8550
- CVE-2015-8553
- CVE-2016-0749
- CVE-2016-2102
- CVE-2016-2150
- CVE-2016-2518
- CVE-2016-3960
- CVE-2016-4953
- CVE-2016-4954
- CVE-2016-4955
- CVE-2016-4956
- CVE-2016-7092
- CVE-2016-7426
- CVE-2016-7434
- CVE-2016-7538
- CVE-2016-9079
- CVE-2017-5436
- CVE-2017-6458
- CVE-2017-7228
- CVE-2018-10893
- CVE-2018-18438
- CVE-2018-5748
- CVE-2018-6764
- CVE-2018-7170
- CVE-2018-7185
- CVE-2018-8897
- CVE-2019-10214
- CVE-2019-11331
- CVE-2019-12067
- CVE-2019-14553
- CVE-2019-14559
- CVE-2019-14562
- CVE-2019-14563
- CVE-2019-14575
- CVE-2019-14586
- CVE-2019-14587
- CVE-2019-8936
- CVE-2020-11868
- CVE-2020-13817
- CVE-2020-23331
- CVE-2020-23332
- CVE-2020-24490
- CVE-2020-25697
- CVE-2020-7694
- CVE-2021-28039
- CVE-2021-28711
- CVE-2021-28712
- CVE-2021-28713
- CVE-2021-45464
- CVE-2022-23036
- CVE-2022-23037
- CVE-2022-23038
- CVE-2022-23039
- CVE-2022-23040
- CVE-2022-23041
- CVE-2022-23042
- CVE-2022-23824
- CVE-2022-23960
- CVE-2022-26358
- CVE-2022-26359
- CVE-2022-26360
- CVE-2022-26361
- CVE-2022-26365
- CVE-2022-29900
- CVE-2022-29901
- CVE-2022-3219
- CVE-2022-33740
- CVE-2022-33741
- CVE-2022-33742
- CVE-2022-33743
- CVE-2022-3553
- CVE-2022-3807
- CVE-2022-40982
- CVE-2022-42309
- CVE-2022-42311
- CVE-2022-42312
- CVE-2022-42313
- CVE-2022-42314
- CVE-2022-42315
- CVE-2022-42316
- CVE-2022-42317
- CVE-2022-42318
- CVE-2022-42320
- CVE-2022-42321
- CVE-2022-42322
- CVE-2022-42323
- CVE-2022-4949
- CVE-2023-0056
- CVE-2023-20588
- CVE-2023-2680
- CVE-2023-34324
- CVE-2023-3750
- CVE-2023-38560
- CVE-2023-39327
- CVE-2023-39328
- CVE-2023-39329
- CVE-2023-4949
- CVE-2023-52356
- CVE-2023-6228
- CVE-2023-6277
- CVE-2023-7216
- CVE-2024-10041
- CVE-2024-1013
- CVE-2024-11586
- CVE-2024-49393
- CVE-2024-49394
- CVE-2024-49395
- CVE-2024-5290
- CVE-2024-6505
- CVE-2024-6519
- CVE-2024-8354
- CVE-2024-8443
- CVE-2024-9029
- CVE-2025-32462
- CVE-2025-32463
- CVE-2025-32989
- CVE-2025-32990
- CVE-2025-3891
- CVE-2025-5987
- CVE-2025-6170
- CVE-2025-7424

Thomas Perale (6):
support/scripts/cve.py: remove print from cve.py library support/scripts/cve.py: fix CPE matching package/pkg-generic.mk: Set <pkg>_CPE_ID_UPDATE to NA by default support/scripts/cve-check: add cve-check script
DEVELOPERS: add Thomas Perale to cve-check & cve.py docs/manual: add information on CycloneDX

 DEVELOPERS                    |   2 +
 docs/manual/common-usage.adoc |  27 +++++++
 package/pkg-generic.mk        |   2 +
 support/scripts/cve-check     | 134 ++++++++++++++++++++++++++++++++++
 support/scripts/cve.py        | 133 +++++++++++++++++++++++++--------
 support/scripts/pkg-stats     |   3 +-
 6 files changed, 271 insertions(+), 30 deletions(-)
 create mode 100755 support/scripts/cve-check
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/6 support/scripts/cve.py: remove print from cve.py library

The support/script/cve.py file is used as a library. Depending on how you use this library you might not want to write content to stdout when calling its function.

This patch move the 'updating' log to the 'pkg-stats' script and write the alert when LooseVersion doesn't have a version to stderr.

---
 support/scripts/cve.py    | 3 +--
 support/scripts/pkg-stats | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)
support/scripts/cve.py +1 -2
index ba41762fa0..5ff67585e2 100755
@@ -69,7 +69,6 @@ class CVE:
 
     @staticmethod
     def download_nvd(nvd_git_dir):
-        print(f"Updating from {NVD_BASE_URL}")
         if os.path.exists(nvd_git_dir):
             subprocess.check_call(
                 ["git", "pull"],
@@ -192,7 +191,7 @@ class CVE:
 
         pkg_version = distutils.version.LooseVersion(version)
         if not hasattr(pkg_version, "version"):
-            print("Cannot parse package '%s' version '%s'" % (name, version))
+            print("Cannot parse package '%s' version '%s'" % (name, version), file=sys.stderr)
             pkg_version = None
 
         # if we don't have a cpeid, build one based on name and version
support/scripts/pkg-stats +1 -0
index a0a46aa8cb..8710dda795 100755
@@ -675,6 +675,7 @@ def check_package_cves(nvd_path, packages):
         else:
             cpe_product_pkgs[pkg.name].append(pkg)
 
+    print(f"Updating NVD database in '{nvd_path}'")
     for cve in cvecheck.CVE.read_nvd_dir(nvd_path):
         check_package_cve_affects(cve, cpe_product_pkgs)
 
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 1/6] support/scripts/cve.py: remove print from cve.py library

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Perale via buildroot <[email protected]> writes:

The support/script/cve.py file is used as a library. Depending on how you use this library you might not want to write content to stdout when calling its function.

This patch move the 'updating' log to the 'pkg-stats' script and write the alert when LooseVersion doesn't have a version to stderr.

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 2/6 support/scripts/cve.py: fix CPE matching

In reply to Thomas Perale via buildroot

Given the following criteria: cpe:2.3:a:oneidentitty:syslog-ng:*:*:*:*:-:*:*:*. The former cpe_matches implementation would match with the following
CPE: cpe:2.3:a:oneidentitty:syslog-ng:4.71:*:*:*:premium:*:*:*.

The 'hyphen' ('-') meaning is "Not Attributed" (NA) a criteria with no attributed software edition shouldn't match with a CPE with an attributed software edition.

This patch also create a distinct 'CPE' object that aggregate the function specifics to CPEs like it's done for 'CVE'.

---
 support/scripts/cve.py    | 130 ++++++++++++++++++++++++++++++--------
 support/scripts/pkg-stats |   2 +-
 2 files changed, 104 insertions(+), 28 deletions(-)
support/scripts/cve.py +103 -27
index 5ff67585e2..25481a6367 100755
@@ -39,22 +39,98 @@ ops = {
 }
 
 
-# Check if two CPE IDs match each other
-def cpe_matches(cpe1, cpe2):
-    cpe1_elems = cpe1.split(":")
-    cpe2_elems = cpe2.split(":")
+class CPE:
+    DISJOINT = 0
+    SUBSET = 1
+    SUPERSET = 2
+    EQUAL = 3
 
-    remains = filter(lambda x: x[0] not in ["*", "-"] and x[1] not in ["*", "-"] and x[0] != x[1],
-                     zip(cpe1_elems, cpe2_elems))
-    return len(list(remains)) == 0
+    ANY = '*'
+    NA = '-'
 
+    @staticmethod
+    def compareAttribute(left, right):
+        """
+        This static method compare two single attributes part of two CPE.
+
+        This is an implementation of table 6-2 of [1].
+
+        Attribute that are empty will be matched to the '*' (ANY) attribute.
+        According to [2] section 6.1.2.1.1 the empty attribute is inherited
+        from CPE22 and now bind to ANY.
 
-def cpe_product(cpe):
-    return cpe.split(':')[4]
+        The hyphen '-' bind to the NA attribute (see [2]).
 
+        [1] https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7696.pdf
+        [2] https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf
+        """
+        if left == '':
+            left = CPE.ANY
+
+        if right == '':
+            right = CPE.ANY
+
+        if left == right:
+            # 1 6 9 - equals
+            return CPE.EQUAL
+        elif left == CPE.ANY:
+            # 2 3 4 - superset
+            return CPE.SUPERSET
+        elif left == CPE.NA and right == CPE.ANY:
+            # 5 - subset
+            return CPE.SUBSET
+        elif left == CPE.NA:
+            # 12 16 - disjoint
+            return CPE.DISJOINT
+        elif right == CPE.ANY:
+            # 13 15 - subset
+            return CPE.SUBSET
+        return CPE.DISJOINT
+
+    def matches(self, target) -> bool:
+        """
+        As an example let's take the example of CVE-2023-... for syslog-ng.
+        One of the node as the following CPE criteria matched with the Buildroot CPE:
+
+        cpe:2.3:a:oneidentitty:syslog-ng:*:*:*:*:-:*:*:*
+        cpe:2.3:a:oneidentitty:syslog-ng:4.71:*:*:*:*:*:*:*
+
+        vendor: EQUAL (3)
+        product: EQUAL (3)
+        version: SUPERSET (2)
+        update: EQUAL (3)
+        edition: EQUAL (3)
+        language: EQUAL (3)
+        sw_edition: SUBSET (1)
+        ...
+
+        This operation results in the two CPE matching.
+        """
+        if not isinstance(target, CPE):
+            target = CPE(target)
 
-def cpe_version(cpe):
-    return cpe.split(':')[5]
+        for selfAttribute, targetAttribute in zip(self.parts, target.parts):
+            if CPE.compareAttribute(selfAttribute, targetAttribute) == CPE.DISJOINT:
+                return False
+
+        return True
+
+    def __str__(self):
+        return self.cpe
+
+    def __init__(self, cpe):
+        self.cpe = cpe
+        self.parts = cpe.split(':')
+        self.vendor = self.parts[3]
+        self.product = self.parts[4]
+        self.version = self.parts[5]
+        self.update = self.parts[6]
+        self.edition = self.parts[7]
+        self.language = self.parts[8]
+        self.sw_edition = self.parts[9]
+        self.target_sw = self.parts[10]
+        self.target_hw = self.parts[11]
+        self.other = self.parts[12]
 
 
 class CVE:
@@ -127,8 +203,9 @@ class CVE:
         for cpe in node.get('cpeMatch', ()):
             if not cpe['vulnerable']:
                 return
-            product = cpe_product(cpe['criteria'])
-            version = cpe_version(cpe['criteria'])
+            cpeId = CPE(cpe['criteria'])
+            product = cpeId.product
+            version = cpeId.version
             # ignore when product is '-', which means N/A
             if product == '-':
                 return
@@ -160,7 +237,7 @@ class CVE:
                     v_end = cpe['versionEndExcluding']
 
             yield {
-                'id': cpe['criteria'],
+                'id': cpeId,
                 'v_start': v_start,
                 'op_start': op_start,
                 'v_end': v_end,
@@ -181,30 +258,29 @@ class CVE:
     @property
     def affected_products(self):
         """The set of CPE products referred by this CVE definition"""
-        return set(cpe_product(p['id']) for p in self.each_cpe())
+        return set(p['id'].product for p in self.each_cpe())
 
     def affects(self, name, version, cpeid=None):
         """
         True if the Buildroot Package object passed as argument is affected
         by this CVE.
         """
-
-        pkg_version = distutils.version.LooseVersion(version)
+        if cpeid is None:
+            # if we don't have a cpeid, build one based on name and version
+            cpeid = CPE("cpe:2.3:*:*:%s:%s:*:*:*:*:*:*:*" % (name, version))
+        elif not isinstance(cpeid, CPE):
+            cpeid = CPE(cpeid)
+
+        # Always prefer the package version of the CPE ID.
+        pkg_version = distutils.version.LooseVersion(cpeid.version)
         if not hasattr(pkg_version, "version"):
             print("Cannot parse package '%s' version '%s'" % (name, version), file=sys.stderr)
             pkg_version = None
 
-        # if we don't have a cpeid, build one based on name and version
-        if not cpeid:
-            cpeid = "cpe:2.3:*:*:%s:%s:*:*:*:*:*:*:*" % (name, version)
-        # if we have a cpeid, use its version instead of the package
-        # version, as they might be different due to
-        # <pkg>_CPE_ID_VERSION
-        else:
-            pkg_version = distutils.version.LooseVersion(cpe_version(cpeid))
-
         for cpe in self.each_cpe():
-            if not cpe_matches(cpe['id'], cpeid):
+            if not cpe['id'].matches(cpeid):
+                # If the node CPE id is not a subset of the target package we
+                # don't check for affect
                 continue
             if not cpe['v_start'] and not cpe['v_end']:
                 return self.CVE_AFFECTS
support/scripts/pkg-stats +1 -1
index 8710dda795..ec46d373d5 100755
@@ -670,7 +670,7 @@ def check_package_cves(nvd_path, packages):
             pkg.status['cve'] = ("na", "no version information available")
             continue
         if pkg.cpeid:
-            cpe_product = cvecheck.cpe_product(pkg.cpeid)
+            cpe_product = cvecheck.CPE(pkg.cpeid).product
             cpe_product_pkgs[cpe_product].append(pkg)
         else:
             cpe_product_pkgs[pkg.name].append(pkg)
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/6] support/scripts/cve.py: fix CPE matching

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Perale via buildroot <[email protected]> writes:

Given the following criteria: cpe:2.3:a:oneidentitty:syslog-ng:*:*:*:*:-:*:*:*. The former cpe_matches implementation would match with the following
CPE: cpe:2.3:a:oneidentitty:syslog-ng:4.71:*:*:*:premium:*:*:*.

Quoted 8 lines

The 'hyphen' ('-') meaning is "Not Attributed" (NA) a criteria with no attributed software edition shouldn't match with a CPE with an attributed software edition.

This patch also create a distinct 'CPE' object that aggregate the function specifics to CPEs like it's done for 'CVE'.

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

PATCH 3/6 package/pkg-generic.mk: Set <pkg>_CPE_ID_UPDATE to NA by default

In reply to Thomas Perale via buildroot

The commit [1] set the default value of '<pkg>_CPE_ID_UPDATE' to not use a wildcard by default. But instead of setting the value to '-' it set it to an empty value instead.

According to document [2] section 6.1.2.1.1 the 'Not Attributed' value bind to an hyphen ('-') and the blank statement bind to the 'Any' ('*').

Because the CPE matching function was incorrect using a blank statement worked to remove the false positives but this is not correct according to the CPE documentation.

[1] 53a8616460 package/pkg-generic.mk: use more sensible default value for <pkg>_CPE_ID_UPDATE
[2] https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf

Fixes 53a8616460e5730abe703ca5a46bae0039d548aa.
---
 package/pkg-generic.mk | 2 ++
 1 file changed, 2 insertions(+)
package/pkg-generic.mk +2 -0
index cf55101265..0a1e29a04e 100644
@@ -727,6 +727,8 @@ ifeq ($$($(2)_CPE_ID_VALID),YES)
  ifndef $(2)_CPE_ID_UPDATE
   ifdef $(3)_CPE_ID_UPDATE
    $(2)_CPE_ID_UPDATE = $$($(3)_CPE_ID_UPDATE)
+  else
+   $(2)_CPE_ID_UPDATE = -
   endif
  endif
 
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 3/6] package/pkg-generic.mk: Set <pkg>_CPE_ID_UPDATE to NA by default

Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Perale via buildroot <[email protected]> writes:

The commit [1] set the default value of '<pkg>_CPE_ID_UPDATE' to not use a wildcard by default. But instead of setting the value to '-' it set it to an empty value instead.

According to document [2] section 6.1.2.1.1 the 'Not Attributed' value bind to an hyphen ('-') and the blank statement bind to the 'Any' ('*').

Because the CPE matching function was incorrect using a blank statement worked to remove the false positives but this is not correct according to the CPE documentation.

Quoted 5 lines

[1] 53a8616460 package/pkg-generic.mk: use more sensible default value for <pkg>_CPE_ID_UPDATE
[2] https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf

Fixes 53a8616460e5730abe703ca5a46bae0039d548aa.

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

PATCH 4/6 support/scripts/cve-check: add cve-check script

In reply to Thomas Perale via buildroot

Enriches the input CycloneDX SBOM with vulnerability information from the NVD database.

The nvd database is cloned using a mirror of it and the content is compared locally. By default the patch 'dl/buildroot-nvd' is used.

Example usage:

$ make show-info | utils/generate-cyclonedx | support/script/cve-check
---
 support/scripts/cve-check | 134 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)
 create mode 100755 support/scripts/cve-check
support/scripts/cve-check new file +134 -0
new file mode 100755
index 0000000000..b4abb9f7d6
@@ -0,0 +1,134 @@
+#!/usr/bin/env python3
+#
+# Enriches the input CycloneDX SBOM with vulnerability information from the NVD
+# database.
+#
+# The nvd database is cloned using a mirror of it and the content is compared
+# locally.
+#
+# Example usage:
+# $ make show-info | utils/generate-cyclonedx | support/script/cve-check --nvd-path dl/buildroot-nvd/
+from collections import defaultdict
+from pathlib import Path
+import argparse
+import sys
+import json
+
+import cve as cvecheck
+
+brpath = Path(__file__).parent.parent.parent
+
+
+def cve_api_get_lang_from_list(values, lang="en"):
+    for x in values:
+        if x.get("lang") == lang:
+            return x.get("value")
+    return None
+
+
+def check_package_cve_affects(cve, cpe_product_pkgs, sbom):
+    vulnerabilities = sbom.setdefault("vulnerabilities", [])
+
+    for product in cve.affected_products:
+        for comp in cpe_product_pkgs.get(product, []):
+            cve_status = cve.affects(comp["name"], comp["version"], comp["cpe"])
+
+            if cve_status != cve.CVE_AFFECTS:
+                continue
+
+            vulnerability = {
+                "bom-ref": cve.identifier,
+                "id": cve.identifier,
+                "description": cve_api_get_lang_from_list(cve.nvd_cve.get("descriptions", [])) or "",
+                "source": {
+                    "name": "NVD",
+                    "url": "https://nvd.nist.gov/"
+                },
+                **({
+                    "published": cve.nvd_cve["published"],
+                } if "published" in cve.nvd_cve else {}),
+                **({
+                    "updated": cve.nvd_cve["lastModified"],
+                } if "lastModified" in cve.nvd_cve else {}),
+            }
+
+            # Search if a vulnerability with the same identifier already exist in the
+            # SBOM vulnerability list.
+            matching_vuln = next(
+                (vuln for vuln in vulnerabilities if vuln.get("id") == cve.identifier),
+                None
+            )
+            if matching_vuln is not None:
+                if matching_vuln.get("analysis") is None:
+                    # We don't update vulnerability that already have an
+                    # 'analysis'.
+                    # Buildroot ignored vulnerabilities will already have
+                    # an analysis and need to remain as such.
+                    vulnerability["analysis"] = {
+                        "state": "exploitable",
+                    }
+
+                affects = matching_vuln.setdefault("affects", [])
+
+                # Update the metadata of the vulnerability with the one
+                # downloaded from the database.
+                matching_vuln.update(vulnerability)
+
+                ref = next((a["ref"] for a in affects if a["ref"] == comp["bom-ref"]), None)
+                if ref is None:
+                    # Add a 'ref' (bom reference) to the component if not
+                    # already present in the 'affects' list.
+                    affects.append({
+                        "ref": comp["bom-ref"]
+                    })
+            else:
+                vulnerability["analysis"] = {
+                    "state": "exploitable",
+                }
+                vulnerability["affects"] = [{
+                    "ref": comp["bom-ref"]
+                }]
+                vulnerabilities.append(vulnerability)
+
+
+def check_package_cves(nvd_path, sbom):
+    nvd_path.mkdir(parents=True, exist_ok=True)
+
+    cpe_product_pkgs = defaultdict(list)
+
+    for comp in sbom.get("components", []):
+        if comp.get("cpe") and comp.get("version"):
+            cpe_product = cvecheck.CPE(comp["cpe"]).product
+            cpe_product_pkgs[cpe_product].append(comp)
+
+    for cve in cvecheck.CVE.read_nvd_dir(nvd_path):
+        check_package_cve_affects(cve, cpe_product_pkgs, sbom)
+
+
+def main():
+    parser = argparse.ArgumentParser(description='''''')
+    parser.add_argument("-i", "--in-file", nargs="?", type=argparse.FileType("r"),
+                        default=(None if sys.stdin.isatty() else sys.stdin))
+    parser.add_argument("-o", "--out-file", nargs="?", type=argparse.FileType("w"),
+                        default=sys.stdout)
+    parser.add_argument('--nvd-path', dest='nvd_path',
+                        default=brpath / 'dl' / 'buildroot-nvd',
+                        help='Path to the local NVD database',
+                        type=lambda p: Path(p).expanduser().resolve())
+
+    args = parser.parse_args()
+
+    if args.in_file is None or args.nvd_path is None:
+        parser.print_help()
+        sys.exit(1)
+
+    sbom = json.load(args.in_file)
+
+    check_package_cves(args.nvd_path, sbom)
+
+    args.out_file.write(json.dumps(sbom, indent=2))
+    args.out_file.write('\n')
+
+
+if __name__ == "__main__":
+    main()
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw

PATCH 5/6 DEVELOPERS: add Thomas Perale to cve-check & cve.py

In reply to Thomas Perale via buildroot
---
 DEVELOPERS | 2 ++
 1 file changed, 2 insertions(+)
DEVELOPERS +2 -0
index 7c2967f41d..a6ecd2b1ff 100644
@@ -3205,6 +3205,8 @@ F:	package/xorcurses/
 N:	Thomas Perale <[email protected]>
 F:	package/go/
 F:	utils/generate-cyclonedx
+F:	support/scripts/cve-check
+F:	support/scripts/cve.py
 
 N:	Thomas Petazzoni <[email protected]>
 F:	arch/Config.in.arm
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#9 lore raw

PATCH 6/6 docs/manual: add information on CycloneDX

In reply to Thomas Perale via buildroot

This patch adds information on how to generate a CycloneDX SBOM in Buildroot. It also mentions how to track CVEs with that given SBOM.

---
 docs/manual/common-usage.adoc | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
docs/manual/common-usage.adoc +27 -0
index 43caa3a9bc..c561944be5 100644
@@ -180,6 +180,33 @@ a newer upstream version for those packages.
 make pkg-stats
 ----
 
+=== Generating CycloneDX SBOM
+
+Based on the output of +show-info+ Buildroot can generate SBOM in the CycloneDX
+format specification. While it doesn't offer any additional informations,
+CycloneDX is a format specification that can be consumed by other projects.
+
+----
+make show-info | utils/generate-cyclonedx
+----
+
+For more information check the help of the +generate-cyclonedx+ script, the
+script call can be tailored to your project.
+
+----
+utils/generate-cyclonedx --help
+----
+
+Similarly to +pkg-stats+, CycloneDX SBOM's can be enriched with vulnerability
+analysis from the NVD database.
+
+----
+make show | utils/generate-cyclonedx > sbom.cdx.json
+cat sbom.cdx.json | support/scripts/cve-check --nvd-path dl/buildroot-nvd/
+----
+
+For more information about CycloneDX see https://cyclonedx.org/[].
+
 === Graphing the dependencies between packages
 
 [[graph-depends]]
Signature · 6 lines
2.51.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#10 lore raw
In reply to Thomas Perale via buildroot
Quoted 4 lines · Thomas Perale via buildroot

Thomas Perale (6):
support/scripts/cve.py: remove print from cve.py library support/scripts/cve.py: fix CPE matching package/pkg-generic.mk: Set <pkg>_CPE_ID_UPDATE to NA by default

Applied these three to 2025.02.x and 2025.08.x, thanks.

Regards,
Arnout

Quoted 2 lines

support/scripts/cve-check: add cve-check script> DEVELOPERS: add Thomas Perale to cve-check & cve.py
docs/manual: add information on CycloneDX

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot