Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/5] support/scripts/cve-check: fix vulnerability timestamp to RFC 3339
@ 2026-05-29 15:06 Thomas Perale via buildroot
  2026-05-29 15:06 ` [Buildroot] [PATCH v2 2/5] support/scripts/cve-check: add indication how to run Thomas Perale via buildroot
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Thomas Perale via buildroot @ 2026-05-29 15:06 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Perale, Thomas Petazzoni

Normalize vulnerability timestamps to RFC 3339 format with explicit UTC
timezone suffix for CycloneDX 1.6 compliance.
This fixes validation errors in sbom-utility and makes the generated
SBOM with vulnerabilities compatible with DependencyTrack VEX parsers.

The NVD JSON data feeds provide timestamps in ISO 8601 format without timezone
information (e.g., "1999-01-01T05:00:00.000"), but CycloneDX 1.6 requires
RFC 3339 format with explicit timezone designation (e.g.,
"1999-01-01T05:00:00.000Z").

Add nvd_datetime_to_rfc3339() helper function to convert timestamps before
serialization.

Validation results:

Before fix:
  $ sbom-utility validate -i cve/cve_report_current.json
  [INFO] BOM valid against JSON schema: 'false'
  [INFO] (234) schema errors detected.

  Error example:
  {
    "type": "format",
    "field": "vulnerabilities.0.updated",
    "context": "(root).vulnerabilities.0.updated",
    "description": "Does not match format 'date-time'",
    "value": "2025-04-03T01:03:51.193"
  }

After fix:
  $ sbom-utility validate -i cve/cve_report_update.json
  [INFO] BOM valid against JSON schema: 'true'

Tested-with: sbom-utility v0.18.1
Co-authored-by: Fabien Lehoussel <fabien.lehoussel@smile.fr>
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
v1 --> v2: add this patch at the base with comments from https://lore.kernel.org/r/<20260227091541.41760-1-thomas.perale@mind.be>
---
 support/scripts/cve-check | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/support/scripts/cve-check b/support/scripts/cve-check
index bcd970bad8..5047523ade 100755
--- a/support/scripts/cve-check
+++ b/support/scripts/cve-check
@@ -12,10 +12,10 @@
 from collections import defaultdict
 from pathlib import Path
 from typing import TypedDict
+from datetime import datetime, timezone
 import argparse
 import sys
 import json
-
 import cve as cvecheck
 
 
@@ -35,6 +35,24 @@ locally.
 brpath = Path(__file__).parent.parent.parent
 
 
+def datetime_to_rfc3339(dt_string):
+    """Normalize datetime string to RFC 3339 format with Z suffix.
+
+    NVD dates are already in ISO format, just need to add the Z suffix.
+
+    Input:  "1999-01-01T05:00:00.000"
+    Output: "1999-01-01T05:00:00.000Z"
+    """
+    dt = datetime.fromisoformat(dt_string.replace('Z', '+00:00'))
+
+    if dt.tzinfo is None:
+        dt = dt.replace(tzinfo=timezone.utc)
+    else:
+        dt = dt.astimezone(timezone.utc)
+
+    return dt.isoformat().replace('+00:00', 'Z')
+
+
 def cve_api_get_lang_from_list(values, lang="en") -> (str | None):
     for x in values:
         if x.get("lang") == lang:
@@ -134,10 +152,10 @@ def nvd_cve_to_cdx_vulnerability(nvd_cve):
             "url": f"https://nvd.nist.gov/vuln/detail/{nvd_cve['id']}"
         },
         **({
-            "published": nvd_cve["published"],
+            "published": datetime_to_rfc3339(nvd_cve["published"]),
         } if "published" in nvd_cve else {}),
         **({
-            "updated": nvd_cve["lastModified"],
+            "updated": datetime_to_rfc3339(nvd_cve["lastModified"]),
         } if "lastModified" in nvd_cve else {}),
         **({
             "cwes": nvd_cve_weaknesses_to_cdx(nvd_cve["weaknesses"]),
-- 
2.54.0

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [Buildroot] [PATCH v2 5/5] package/pkg-generic.mk: replicate IGNORE_CVES to host packages
@ 2026-05-29 15:07 Thomas Perale via buildroot
  0 siblings, 0 replies; 15+ messages in thread
From: Thomas Perale via buildroot @ 2026-05-29 15:07 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Perale, Thomas Petazzoni

For host packages, this commit adds the same `ignore_cves` list as their
target counterpart and make it available from the `show-info` output.

When generating a CycloneDX SBOM with `make show-info-all |
utils/generate-cyclonedx` and running an analysis over it with
`support/script/cve-check`, multiple vulnerabilities
entries would be created with different analysis for packages that have
both a host and target variant that include IGNORE_CVES entries.

This is the case for the grub2 package that include ignored
vulnerabilities that patch both the target and host package but aren't
declared as ignored for the host package. This resulted in
vulnerabilities marked as 'exploitable' for the host variant while it
is patched.

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
 package/pkg-generic.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index dd440e4062..e5e0d49a16 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -745,6 +745,13 @@ ifeq ($$($(2)_CPE_ID_VALID),YES)
  $(2)_CPE_ID = $$($(2)_CPE_ID_PREFIX):$$($(2)_CPE_ID_VENDOR):$$($(2)_CPE_ID_PRODUCT):$$($(2)_CPE_ID_VERSION):$$($(2)_CPE_ID_UPDATE):*:*:*:*:*:*
 endif # ifeq ($$($(2)_CPE_ID_VALID),YES)
 
+# replicate the target '_IGNORE_CVES' to the host variant
+ifndef $(2)_IGNORE_CVES
+ ifdef $(3)_IGNORE_CVES
+  $(2)_IGNORE_CVES = $$($(3)_IGNORE_CVES)
+ endif
+endif
+
 # When a target package is a toolchain dependency set this variable to
 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
 # dependency.
-- 
2.54.0

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-06-05 12:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 15:06 [Buildroot] [PATCH v2 1/5] support/scripts/cve-check: fix vulnerability timestamp to RFC 3339 Thomas Perale via buildroot
2026-05-29 15:06 ` [Buildroot] [PATCH v2 2/5] support/scripts/cve-check: add indication how to run Thomas Perale via buildroot
2026-05-29 15:36   ` Thomas Petazzoni via buildroot
2026-06-05 12:51   ` Thomas Perale via buildroot
2026-05-29 15:06 ` [Buildroot] [PATCH v2 3/5] support/scripts/cve-check: remove 'bom-ref' for vulnerabilities Thomas Perale via buildroot
2026-05-29 15:39   ` Thomas Petazzoni via buildroot
2026-05-29 15:06 ` [Buildroot] [PATCH v2 4/5] support/scripts/cve-check: fix vulnerabilities with different analysis Thomas Perale via buildroot
2026-05-29 15:39   ` Thomas Petazzoni via buildroot
2026-06-05 12:51   ` Thomas Perale via buildroot
2026-05-29 15:06 ` [Buildroot] [PATCH v2 5/5] package/pkg-generic.mk: replicate IGNORE_CVES to host packages Thomas Perale via buildroot
2026-05-29 15:39   ` Thomas Petazzoni via buildroot
2026-06-05 12:51   ` Thomas Perale via buildroot
2026-05-29 15:33 ` [Buildroot] [PATCH v2 1/5] support/scripts/cve-check: fix vulnerability timestamp to RFC 3339 Thomas Petazzoni via buildroot
2026-06-05 12:51 ` Thomas Perale via buildroot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-29 15:07 [Buildroot] [PATCH v2 5/5] package/pkg-generic.mk: replicate IGNORE_CVES to host packages Thomas Perale via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox