Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Perale via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: Thomas Perale <thomas.perale@mind.be>,
	Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Subject: [Buildroot] [RFC PATCH 04/14] utils/generate-cyclonedx: support vulnerability details
Date: Wed, 24 Jun 2026 16:06:35 +0200	[thread overview]
Message-ID: <20260624140645.185318-5-thomas.perale@mind.be> (raw)
In-Reply-To: <20260624140645.185318-1-thomas.perale@mind.be>

Translate the OpenVex notation used to describe the vulnerabilities that
aren't patched in Buildroot into the CycloneDX format.

- fixed -> resolved
- not-affected-component-not-present -> false_positive
- not-affected-vulnerable-code-not-present -> not_affected &
  code_not_present
- not-affected-vulnerable-code-not-in-execute-path -> not_affected &
  code_not_reachable
- not-affected-vulnerable-code-cannot-be-controlled-by-adversary -> not_affected &
  protected_by_mitigating_control

See https://cyclonedx.org/docs/1.7/json/#vulnerabilities_items_analysis
for more information

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
 utils/generate-cyclonedx | 83 +++++++++++++++++++++++++++++++++-------
 1 file changed, 69 insertions(+), 14 deletions(-)

diff --git a/utils/generate-cyclonedx b/utils/generate-cyclonedx
index df12ee84c0..c1aa1f980d 100755
--- a/utils/generate-cyclonedx
+++ b/utils/generate-cyclonedx
@@ -403,6 +403,43 @@ def cyclonedx_dependency(ref, depends):
         "dependsOn": sorted(depends),
     }
 
+def openvex_to_cyclonedx_analysis(state) -> dict:
+    """Convert an OpenVex vulnerability state into a CycloneDX analysis.
+
+    Supported:
+      - fixed
+      - not-affected-component-not-present
+      - not-affected-vulnerable-code-not-present
+      - not-affected-vulnerable-code-not-in-execute-path
+      - not-affected-vulnerable-code-cannot-be-controlled-by-adversary
+
+    Args:
+        state (str): OpenVex status string.
+
+    Returns:
+        dict: CycloneDX analysis dict with 'state' and optional 'justification'.
+    """
+    MAPPING = {
+        "fixed": {
+            "state": "resolved",
+        },
+        "not-affected-component-not-present": {
+            "state": "false_positive",
+        },
+        "not-affected-vulnerable-code-not-present": {
+            "state": "not_affected",
+            "justification": "code_not_present",
+        },
+        "not-affected-vulnerable-code-not-in-execute-path": {
+            "state": "not_affected",
+            "justification": "code_not_reachable",
+        },
+        "not-affected-vulnerable-code-cannot-be-controlled-by-adversary": {
+            "state": "not_affected",
+            "justification": "protected_by_mitigating_control",
+        },
+    }
+    return MAPPING.get(state, {"state": "in_triage"})
 
 def cyclonedx_vulnerabilities(show_info_dict):
     """Create a JSON list of vulnerabilities ignored by buildroot and associate
@@ -421,20 +458,38 @@ def cyclonedx_vulnerabilities(show_info_dict):
         for cve in comp.get('ignore_cves', []):
             cves.setdefault(cve, []).append(name)
 
-    return [{
-        "id": cve,
-        "source": {
-            "name": "NVD",
-            "url": "https://nvd.nist.gov/vuln/detail/" + cve
-        },
-        "analysis": {
-            "state": "resolved_with_pedigree" if cve in VULN_WITH_PEDIGREE else "in_triage",
-            "detail": f"The CVE '{cve}' has been marked as ignored by Buildroot"
-        },
-        "affects": [
-            {"ref": bomref} for bomref in components
-        ]
-    } for cve, components in cves.items()]
+    ret = []
+    for cve, components in cves.items():
+        # retrieve first occurance of the "cves_status" for this CVE.
+        cve_status = next(
+            (status for comp_name in components
+             if (status := show_info_dict.get(comp_name, {}).get("cves_status", {}).get(cve, {}))),
+            {}
+        )
+
+        if cve in VULN_WITH_PEDIGREE:
+            state = {"state": "resolved_with_pedigree"}
+        else:
+            state = openvex_to_cyclonedx_analysis(cve_status.get("status"))
+
+        detail = cve_status.get("detail", f"The CVE '{cve}' has been marked as ignored by Buildroot")
+
+        ret.append({
+            "id": cve,
+            "source": {
+                "name": "NVD",
+                "url": "https://nvd.nist.gov/vuln/detail/" + cve
+            },
+            "analysis": {
+                **state,
+                "detail": detail
+            },
+            "affects": [
+                {"ref": bomref} for bomref in components
+            ]
+        })
+
+    return ret
 
 
 def br2_virtual_is_provided_by(ref, show_info_dict) -> list:
-- 
2.54.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2026-06-24 14:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 14:06 [Buildroot] [RFC PATCH 00/14] Add exportable vulnerability informations Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 01/14] docs/manual: add vulnerability status and justification Thomas Perale via buildroot
2026-08-20 20:47   ` Thomas Petazzoni via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 02/14] utils/checkpackagelib/lib_mk.py: check _STATUS value is supported Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 03/14] package/pkg-utils: show-info expose vuln details Thomas Perale via buildroot
2026-08-20 20:54   ` Thomas Petazzoni via buildroot
2026-06-24 14:06 ` Thomas Perale via buildroot [this message]
2026-06-25 18:01   ` [Buildroot] [RFC PATCH 04/14] utils/generate-cyclonedx: support vulnerability details Fiona Klute via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 05/14] package/sox: add vulnerabilities details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 06/14] package/php: add vulnerability details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 07/14] package/mupdf: add vulnerabilities details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 08/14] package/python-pip: add detail to vulnerability Thomas Perale via buildroot
2026-06-25 17:57   ` Fiona Klute via buildroot
2026-06-26  7:25     ` Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 09/14] package/luajit: add details to vulnerabilities Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 10/14] package/libuci: add vulnerability details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 11/14] package/glibc: " Thomas Perale via buildroot
2026-06-24 14:45   ` Romain Naour via buildroot
2026-06-24 15:06     ` Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 12/14] package/freeradius-server: add vulnerabilities details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 13/14] package/flex: add vulnerability details Thomas Perale via buildroot
2026-06-24 14:06 ` [Buildroot] [RFC PATCH 14/14] package/clamav: " Thomas Perale via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260624140645.185318-5-thomas.perale@mind.be \
    --to=buildroot@buildroot.org \
    --cc=ricardo.martincoski@datacom.com.br \
    --cc=thomas.perale@mind.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox