From: Thomas Perale via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: Thomas Perale <thomas.perale@mind.be>
Subject: [Buildroot] [PATCH v5 8/8] utils/generate-cyclonedx: split vulnerabilities per state
Date: Wed, 11 Mar 2026 15:04:57 +0100 [thread overview]
Message-ID: <20260311140457.140041-9-thomas.perale@mind.be> (raw)
In-Reply-To: <20260311140457.140041-1-thomas.perale@mind.be>
If a vulnerability is present in multiple components and only one of
them has a patch that addresses that vulnerability, all components will
currently have that vulnerability marked as `resolved_with_pedigree`.
Right now, this issue does not affect any packages, but in the future it
might affect packages that provide multiple version options (e.g.
gnupg and gnupg2).
There is a small chance this happens in a real-world use case, but it
may occur in the context of maintenance when running
`make show-info-all`.
This commit changes how vulnerabilities fixed by a patch are stored.
Instead of placing all vulnerabilities into a single set, it now keeps an
index of the component for which the patch has been applied.
When generating the vulnerability list, the component reference is
checked instead of only the vulnerability ID. If a vulnerability ID has
multiple states for different references, multiple vulnerability
entries are created with distinct analyses.
Consider the hypothetical case where gnupg ignores a vulnerability
because it was introduced in a later version, while gnupg2 has patched
that vulnerability. This would result in the following JSON:
```json
[
{
"id": "CVE-1234-1234",
"analysis": {
"state": "in_triage",
"detail": "The CVE 'CVE-1234-1234' has been marked as ignored by Buildroot"
},
"affects": [
{"ref": "gnupg"}
]
},
{
"id": "CVE-1234-1234",
"analysis": {
"state": "resolved_with_pedigree",
"detail": "The CVE 'CVE-1234-1234' has been marked as ignored by Buildroot"
},
"affects": [
{"ref": "gnupg2"}
]
}
]
```
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
utils/generate-cyclonedx | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/utils/generate-cyclonedx b/utils/generate-cyclonedx
index 43167d12d0..f4e0e8b539 100755
--- a/utils/generate-cyclonedx
+++ b/utils/generate-cyclonedx
@@ -249,10 +249,10 @@ class CycloneDX:
_spdx_licenses: list = field(default_factory=list)
"""List of supported SPDX license expression. Initialized during the
`__post_init__` step, fetched either online or from local copy"""
- _vuln_with_pedigree: set = field(default_factory=set)
- """Set of vulnerabilities that were addressed by a patch present in
- buildroot tree. This set is used to set the analysis of the ignored CVEs to
- 'resolved_with_pedigree'."""
+ _vuln_with_pedigree: dict = field(default_factory=dict)
+ """Index of vulnerabilities per component ref that were addressed by a
+ patch present in buildroot tree. This index is used to set the analysis of
+ the ignored CVEs to 'resolved_with_pedigree'."""
def __post_init__(self):
self._spdx_licenses = br2_retrieve_spdx_licenses(self.options.cyclonedx_version)
@@ -297,11 +297,12 @@ class CycloneDX:
]
}
- def _component_patches(self, patch_list: list[str]):
+ def _component_patches(self, comp_ref: str, patch_list: list[str]):
"""Translate a list of patches from the show-info JSON to a list of
patches in CycloneDX format.
Args:
+ comp_ref (str): Reference of the component the patches are part of.
patch_list (list): Array of patch relative paths for a given component.
Returns:
@@ -324,7 +325,7 @@ class CycloneDX:
issue = {}
cves = extract_cves_from_header(header)
if cves:
- self._vuln_with_pedigree.update(cves)
+ self._vuln_with_pedigree.setdefault(comp_ref, set()).update(cves)
issue = {
"resolves": [
{
@@ -387,7 +388,7 @@ class CycloneDX:
**({
"cpe": comp["cpe-id"],
} if "cpe-id" in comp else {}),
- **(self._component_patches(comp["patches"]) if comp.get("patches") else {}),
+ **(self._component_patches(name, comp["patches"]) if comp.get("patches") else {}),
"properties": [{
"name": "BR_TYPE",
"value": comp["type"],
@@ -421,22 +422,31 @@ class CycloneDX:
Returns:
list: Solved vulnerabilities list in CycloneDX format.
"""
+ # This will generate an index of affected component per
+ # (<cve-id>, <analysis-state>) tuple.
+ # In the case a CVE have different analysis based on the package they
+ # affects this will enable to create multiple entries with the same
+ # vulnerability id.
cves = {}
for name, comp in self._filtered_show_info_dict.items():
for cve in comp.get('ignore_cves', []):
- cves.setdefault(cve, []).append(name)
+ state = "in_triage"
+ if cve in self._vuln_with_pedigree.get(name, {}):
+ state = "resolved_with_pedigree"
+
+ cves.setdefault((cve, state), []).append(name)
return [{
"id": cve,
"analysis": {
- "state": "resolved_with_pedigree" if cve in self._vuln_with_pedigree else "in_triage",
+ "state": state,
"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()]
+ } for (cve, state), components in cves.items()]
@property
def cyclonedx(self):
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
prev parent reply other threads:[~2026-03-11 14:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 14:04 [Buildroot] [PATCH v5 0/8] Support CycloneDX v1.7 Thomas Perale via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 1/8] utils/generate-cyclonedx: use tuple for version Thomas Perale via buildroot
2026-04-09 12:08 ` Quentin Schulz via buildroot
2026-04-09 20:27 ` Thomas Perale via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 2/8] utils/generate-cyclonedx: move license download in a function Thomas Perale via buildroot
2026-04-09 12:12 ` Quentin Schulz via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 3/8] utils/generate-cyclonedx: move utility function Thomas Perale via buildroot
2026-04-09 12:27 ` Quentin Schulz via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 4/8] utils/generate-cyclonedx: encapsulate CycloneDX generation functions Thomas Perale via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 5/8] utils/generate-cyclonedx: optional bump to v1.7 Thomas Perale via buildroot
2026-04-09 12:40 ` Quentin Schulz via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 6/8] utils/generate-cyclonedx: mark host packages as external Thomas Perale via buildroot
2026-04-09 12:58 ` Quentin Schulz via buildroot
2026-04-09 20:42 ` Thomas Perale via buildroot
2026-04-09 20:43 ` Thomas Perale via buildroot
2026-04-10 9:12 ` Quentin Schulz via buildroot
2026-03-11 14:04 ` [Buildroot] [PATCH v5 7/8] utils/generate-cyclonedx: add 'id' property to resolves Thomas Perale via buildroot
2026-04-09 13:22 ` Quentin Schulz via buildroot
2026-04-09 20:24 ` Thomas Perale via buildroot
2026-03-11 14:04 ` Thomas Perale via buildroot [this message]
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=20260311140457.140041-9-thomas.perale@mind.be \
--to=buildroot@buildroot.org \
--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