Skip to contentSkip to conversation

sbom-cve-check-update-db: Fix do_populate_lic failure

PATCH In review Ross Burton 2 participants 8 messages Apr 7 – Apr 13

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/7 sbom-cve-check-update-db: Fix do_populate_lic failure

From: Benjamin Robin <[email protected]>

The do_populate_lic task was failing because it runs after do_patch, but the indirect dependency on do_unpack was lost when the do_patch task was deleted.

It is safe, and even preferable, to retain the do_patch task, as this allows users to apply patches to their CVE databases.

Follow-up to commit 8ef22ad9e302f86b2da4fa81541a464e95b9ef3c ("sbom-cve-check: Add class for post-build CVE analysis").

---
 meta/classes-recipe/sbom-cve-check.bbclass                    | 4 ++--
 .../sbom-cve-check/sbom-cve-check-update-db.inc               | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
meta/classes-recipe/sbom-cve-check.bbclass +2 -2
index 6c62a5119d..4abc427c58 100644
@@ -106,8 +106,8 @@ do_sbom_cve_check[sstate-inputdirs] = "${SBOM_CVE_CHECK_DEPLOYDIR}"
 do_sbom_cve_check[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 do_sbom_cve_check[depends] += " \
     python3-sbom-cve-check-native:do_populate_sysroot \
-    sbom-cve-check-update-cvelist-native:do_unpack \
-    sbom-cve-check-update-nvd-native:do_unpack \
+    sbom-cve-check-update-cvelist-native:do_patch \
+    sbom-cve-check-update-nvd-native:do_patch \
 "
 
 python do_sbom_cve_check_setscene() {
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-db.inc +0 -1
index 4e9cef96e8..a318e2c40e 100644
@@ -9,7 +9,6 @@ require sbom-cve-check-config.inc
 SBOM_CVE_CHECK_DB_NAME[doc] = "Database name, which is the Git repository directory name. \
     The git repository will be stored in ${SBOM_CVE_CHECK_DEPLOY_DB_DIR)/"
 
-deltask do_patch
 deltask do_configure
 deltask do_compile
 deltask do_install
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/7 sbom-cve-check-update-db: Fix unpack removing other databases

From: Benjamin Robin <[email protected]>

Previously, UNPACKDIR was set to ${SBOM_CVE_CHECK_DEPLOY_DB_DIR}, which points to the ./databases/ directory and may contain multiple databases. Since do_unpack cleans the ${UNPACKDIR} directory, UNPACKDIR must only contain a single database.

To address this, set UNPACKDIR to ${SBOM_CVE_CHECK_DEPLOY_DB_DIR}/${SBOM_CVE_CHECK_DB_NAME} and configure destsuffix to an empty string. However, it is currently not possible to set BB_GIT_DEFAULT_DESTSUFFIX to an empty string, so destsuffix is configured through the SRC_URI instead.

---
 .../sbom-cve-check/sbom-cve-check-update-cvelist-native.bb    | 2 +-
 .../sbom-cve-check/sbom-cve-check-update-db.inc               | 3 +--
 .../sbom-cve-check/sbom-cve-check-update-nvd-native.bb        | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-cvelist-native.bb +1 -1
index ce204db6c5..3387122165 100644
@@ -3,7 +3,7 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
 HOMEPAGE = "https://github.com/CVEProject/cvelistV5"
-SRC_URI = "git://github.com/CVEProject/cvelistV5.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/CVEProject/cvelistV5.git;branch=main;protocol=https;destsuffix="
 SBOM_CVE_CHECK_DB_NAME = "cvelist"
 
 # 2026-03-19_baseline
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-db.inc +1 -2
index a318e2c40e..7ada67363d 100644
@@ -15,6 +15,5 @@ deltask do_install
 deltask do_populate_sysroot
 
 # Directly unpack the fetched CVE database to the deploy directory.
-UNPACKDIR = "${SBOM_CVE_CHECK_DEPLOY_DB_DIR}"
+UNPACKDIR = "${SBOM_CVE_CHECK_DEPLOY_DB_DIR}/${SBOM_CVE_CHECK_DB_NAME}"
 S = "${UNPACKDIR}"
-BB_GIT_DEFAULT_DESTSUFFIX = "${SBOM_CVE_CHECK_DB_NAME}"
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-nvd-native.bb +2 -2
index 30c7868b2a..c868ba09c1 100644
@@ -1,9 +1,9 @@
 SUMMARY = "Updates the NVD CVE database"
 LICENSE = "cve-tou"
-LIC_FILES_CHKSUM = "file://${SBOM_CVE_CHECK_DB_NAME}/LICENSES/cve-tou.md;md5=bc5bbf146f01e20ece63d83c8916d8fb"
+LIC_FILES_CHKSUM = "file://LICENSES/cve-tou.md;md5=bc5bbf146f01e20ece63d83c8916d8fb"
 
 HOMEPAGE = "https://github.com/fkie-cad/nvd-json-data-feeds"
-SRC_URI = "git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix="
 SBOM_CVE_CHECK_DB_NAME = "nvd-fkie"
 
 # v2026.03.19-010002
Signature · 1 line
2.43.0
#2 lore raw

Re: [OE-core] [PATCH v2 2/7] sbom-cve-check-update-db: Fix unpack removing other databases

Hi,

Have encountered below error when execute "bitbake -cfetch sbom-cve-check-update-cvelist-native", could you help to take a look?
ERROR: sbom-cve-check-update-cvelist-native-1.0-r0 do_fetch: Bitbake Fetcher Error: MalformedUrl('git://github.com/CVEProject/cvelistV5.git;branch=main;protocol=https;destsuffix')

Thanks,

Quoted 78 lines · Ross Burton via lists.openembedded.org

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

From: Benjamin Robin <[email protected]>

Previously, UNPACKDIR was set to ${SBOM_CVE_CHECK_DEPLOY_DB_DIR}, which points to the ./databases/ directory and may contain multiple databases. Since do_unpack cleans the ${UNPACKDIR} directory, UNPACKDIR must only contain a single database.

To address this, set UNPACKDIR to ${SBOM_CVE_CHECK_DEPLOY_DB_DIR}/${SBOM_CVE_CHECK_DB_NAME} and configure destsuffix to an empty string. However, it is currently not possible to set BB_GIT_DEFAULT_DESTSUFFIX to an empty string, so destsuffix is configured through the SRC_URI instead.

---
  .../sbom-cve-check/sbom-cve-check-update-cvelist-native.bb    | 2 +-
  .../sbom-cve-check/sbom-cve-check-update-db.inc               | 3 +--
  .../sbom-cve-check/sbom-cve-check-update-nvd-native.bb        | 4 ++--
  3 files changed, 4 insertions(+), 5 deletions(-)
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-cvelist-native.bb +1 -1
index ce204db6c5..3387122165 100644
@@ -3,7 +3,7 @@ LICENSE = "MIT"
  LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
  HOMEPAGE = "https://github.com/CVEProject/cvelistV5"
-SRC_URI = "git://github.com/CVEProject/cvelistV5.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/CVEProject/cvelistV5.git;branch=main;protocol=https;destsuffix="
  SBOM_CVE_CHECK_DB_NAME = "cvelist"
 
  # 2026-03-19_baseline
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-db.inc +1 -2
index a318e2c40e..7ada67363d 100644
@@ -15,6 +15,5 @@ deltask do_install
  deltask do_populate_sysroot
 
  # Directly unpack the fetched CVE database to the deploy directory.
-UNPACKDIR = "${SBOM_CVE_CHECK_DEPLOY_DB_DIR}"
+UNPACKDIR = "${SBOM_CVE_CHECK_DEPLOY_DB_DIR}/${SBOM_CVE_CHECK_DB_NAME}"
  S = "${UNPACKDIR}"
-BB_GIT_DEFAULT_DESTSUFFIX = "${SBOM_CVE_CHECK_DB_NAME}"
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-nvd-native.bb +2 -3
index 30c7868b2a..c868ba09c1 100644
@@ -1,9 +1,9 @@
  SUMMARY = "Updates the NVD CVE database"
  LICENSE = "cve-tou"
-LIC_FILES_CHKSUM = "file://${SBOM_CVE_CHECK_DB_NAME}/LICENSES/cve-tou.md;md5=bc5bbf146f01e20ece63d83c8916d8fb"
+LIC_FILES_CHKSUM = "file://LICENSES/cve-tou.md;md5=bc5bbf146f01e20ece63d83c8916d8fb"
 
  HOMEPAGE = "https://github.com/fkie-cad/nvd-json-data-feeds"
-SRC_URI = "git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix="
  SBOM_CVE_CHECK_DB_NAME = "nvd-fkie"
 
  # v2026.03.19-010002
--

2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#234781): https://lists.openembedded.org/g/openembedded-core/message/234781
Mute This Topic: https://lists.openembedded.org/mt/118715629/3618448
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

PATCH v2 3/7 sbom-cve-check-config.inc: move to meta/conf/

In reply to Ross Burton

This file is used by classes and recipes, so it's best to put it into conf/ instead of alongside the recipe.

---
 meta/classes-recipe/sbom-cve-check.bbclass                      | 2 +-
 .../sbom-cve-check => conf}/sbom-cve-check-config.inc           | 0
 .../sbom-cve-check/sbom-cve-check-update-db.inc                 | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename meta/{recipes-devtools/sbom-cve-check => conf}/sbom-cve-check-config.inc (100%)
meta/classes-recipe/sbom-cve-check.bbclass +1 -1
index 4abc427c58..0534833ebe 100644
@@ -6,7 +6,7 @@
 # Or it is possible to add this line in local.conf:
 # OE_FRAGMENTS += "core/yocto/sbom-cve-check"
 
-require recipes-devtools/sbom-cve-check/sbom-cve-check-config.inc
+require conf/sbom-cve-check-config.inc
 
 SBOM_CVE_CHECK_DEPLOYDIR = "${WORKDIR}/sbom-cve-check/image-deploy"
 
meta/conf/sbom-cve-check-config.inc renamed from meta/recipes-devtools/sbom-cve-check/sbom-cve-check-config.inc +0 -0
similarity index 100%
rename from meta/recipes-devtools/sbom-cve-check/sbom-cve-check-config.inc
rename to meta/conf/sbom-cve-check-config.inc
meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-db.inc +1 -1
index 7ada67363d..fbdc561e8c 100644
@@ -4,7 +4,7 @@ INHIBIT_DEFAULT_DEPS = "1"
 EXCLUDE_FROM_WORLD = "1"
 
 inherit native
-require sbom-cve-check-config.inc
+require conf/sbom-cve-check-config.inc
 
 SBOM_CVE_CHECK_DB_NAME[doc] = "Database name, which is the Git repository directory name. \
     The git repository will be stored in ${SBOM_CVE_CHECK_DEPLOY_DB_DIR)/"
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/7 classes/sbom-cve-check: refactor do_sbom_cve_check

In reply to Ross Burton

Extract the bulk of the logic to a separate function, so the task just has to pass a few variables.

---
 meta/classes-recipe/sbom-cve-check.bbclass | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)
meta/classes-recipe/sbom-cve-check.bbclass +16 -11
index 0534833ebe..a24d34b896 100644
@@ -43,28 +43,23 @@ SBOM_CVE_CHECK_EXPORT_SUMMARY[doc] = "Export configuration to generate a human-r
 SBOM_CVE_CHECK_EXPORT_SUMMARY[type] ?= "summary"
 SBOM_CVE_CHECK_EXPORT_SUMMARY[ext] ?= ".cve.txt"
 
-python do_sbom_cve_check() {
-    """
-    Task: Run sbom-cve-check analysis on SBOM.
-    """
+
+def run_sbom_cve_check(d, sbom_path, export_base_name, export_link_name=None):
     import os
     import bb
     from oe.cve_check import update_symlinks
 
     if not bb.data.inherits_class("create-spdx-3.0", d):
-        bb.fatal("Cannot execute sbom-cve-check missing create-spdx-3.0 inherit.")
+        bb.fatal("Cannot execute sbom-cve-check: missing create-spdx-3.0 inherit.")
 
-    sbom_path = d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.spdx.json")
     dl_db_dir = d.getVar("SBOM_CVE_CHECK_DEPLOY_DB_DIR")
-    deploy_dir = d.getVar("SBOM_CVE_CHECK_DEPLOYDIR")
-    img_link_name = d.getVar("IMAGE_LINK_NAME")
-    img_name = d.getVar("IMAGE_NAME")
+    out_deploy_dir = d.getVar("SBOM_CVE_CHECK_DEPLOYDIR")
 
     export_files = []
     for export_var in d.getVar("SBOM_CVE_CHECK_EXPORT_VARS").split():
         export_ext = d.getVarFlag(export_var, "ext")
-        export_path = f"{deploy_dir}/{img_name}{export_ext}"
-        export_link = f"{deploy_dir}/{img_link_name}{export_ext}"
+        export_path = f"{out_deploy_dir}/{export_base_name}{export_ext}"
+        export_link = f"{out_deploy_dir}/{export_link_name}{export_ext}" if export_link_name else None
         export_type = d.getVarFlag(export_var, "type")
         export_files.append((export_type, export_path, export_link))
 
@@ -96,6 +91,16 @@ python do_sbom_cve_check() {
         bb.note(f"sbom-cve-check exported: {export_file}")
         if export_link:
             update_symlinks(export_file, export_link)
+
+
+python do_sbom_cve_check() {
+    """
+    Task: Run sbom-cve-check analysis on SBOM.
+    """
+    sbom_path = d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.spdx.json")
+    image_name = d.getVar("IMAGE_NAME")
+    link_name = d.getVar("IMAGE_LINK_NAME")
+    run_sbom_cve_check(d, sbom_path, image_name, link_name)
 }
 
 addtask do_sbom_cve_check after do_create_image_sbom_spdx before do_build
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/7 classes/sbom-cve-check: extract the database dependencies to a variable

In reply to Ross Burton

This tidies up the dependencies, allowing for future tasks that will need the same dependencies.

---
 meta/classes-recipe/sbom-cve-check.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/classes-recipe/sbom-cve-check.bbclass +5 -2
index a24d34b896..c861a7965f 100644
@@ -43,6 +43,10 @@ SBOM_CVE_CHECK_EXPORT_SUMMARY[doc] = "Export configuration to generate a human-r
 SBOM_CVE_CHECK_EXPORT_SUMMARY[type] ?= "summary"
 SBOM_CVE_CHECK_EXPORT_SUMMARY[ext] ?= ".cve.txt"
 
+SBOM_CVE_CHECK_UPDATE_DB_DEPENDENCIES ?= " \
+    sbom-cve-check-update-cvelist-native:do_patch \
+    sbom-cve-check-update-nvd-native:do_patch \
+"
 
 def run_sbom_cve_check(d, sbom_path, export_base_name, export_link_name=None):
     import os
@@ -111,8 +115,7 @@ do_sbom_cve_check[sstate-inputdirs] = "${SBOM_CVE_CHECK_DEPLOYDIR}"
 do_sbom_cve_check[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 do_sbom_cve_check[depends] += " \
     python3-sbom-cve-check-native:do_populate_sysroot \
-    sbom-cve-check-update-cvelist-native:do_patch \
-    sbom-cve-check-update-nvd-native:do_patch \
+    ${SBOM_CVE_CHECK_UPDATE_DB_DEPENDENCIES} \
 "
 
 python do_sbom_cve_check_setscene() {
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 6/7 classes/sbom-cve-check: extract common functionality to a -common.bbclass

In reply to Ross Burton

Extract the common configuration variables and run_sbom_cve_check() that actually invokes sbom-cve-check to a separate class, so that other classes that are not tied to image generation can use the same logic.

No code changes, just movement.

---
 meta/classes-recipe/sbom-cve-check.bbclass | 93 +--------------------
 meta/classes/sbom-cve-check-common.bbclass | 95 ++++++++++++++++++++++
 2 files changed, 98 insertions(+), 90 deletions(-)
 create mode 100644 meta/classes/sbom-cve-check-common.bbclass
meta/classes-recipe/sbom-cve-check.bbclass +3 -90
index c861a7965f..fe145a2212 100644
@@ -1,101 +1,14 @@
 # SPDX-License-Identifier: MIT
 
+# Perform CVE analysis on image SBOMs using sbom-cve-check.
+#
 # It is recommended to enable this class through the sbom-cve-check fragment:
 # bitbake-config-build enable-fragment core/yocto/sbom-cve-check
 #
 # Or it is possible to add this line in local.conf:
 # OE_FRAGMENTS += "core/yocto/sbom-cve-check"
 
-require conf/sbom-cve-check-config.inc
-
-SBOM_CVE_CHECK_DEPLOYDIR = "${WORKDIR}/sbom-cve-check/image-deploy"
-
-SBOM_CVE_CHECK_EXTRA_ARGS[doc] = "Allow to specify extra arguments to sbom-cve-check. \
-    For example to add export flags for filtering (e.g., only export vulnerable CVEs). \
-"
-SBOM_CVE_CHECK_EXTRA_ARGS ??= ""
-
-SBOM_CVE_CHECK_EXPORT_VARS[doc] = "List of variables that declare export files to generate. \
-    Each variable must have a 'type' and an 'ext' flag set. \
-    The 'type' flag contains the value that is passed to the --export-type command flags. \
-    The 'ext' flag contains the filename extension (suffix). The output filename is going \
-    to be ${IMAGE_NAME}${ext} \
-"
-SBOM_CVE_CHECK_EXPORT_VARS ?= "SBOM_CVE_CHECK_EXPORT_SPDX3 SBOM_CVE_CHECK_EXPORT_CVECHECK"
-
-SBOM_CVE_CHECK_EXPORT_SPDX3[doc] = "Export configuration to generate an SPDX3 SBOM file, \
-    with the following name: ${IMAGE_NAME}.sbom-cve-check.spdx.json \
-"
-SBOM_CVE_CHECK_EXPORT_SPDX3[type] ?= "spdx3"
-SBOM_CVE_CHECK_EXPORT_SPDX3[ext] ?= ".sbom-cve-check.spdx.json"
-
-SBOM_CVE_CHECK_EXPORT_CVECHECK[doc] = "Export configuration to generate a JSON manifest \
-    in the same format as the cve-check class, with the following name: \
-    ${IMAGE_NAME}.sbom-cve-check.json \
-"
-SBOM_CVE_CHECK_EXPORT_CVECHECK[type] ?= "yocto-cve-check-manifest"
-SBOM_CVE_CHECK_EXPORT_CVECHECK[ext] ?= ".sbom-cve-check.yocto.json"
-
-SBOM_CVE_CHECK_EXPORT_SUMMARY[doc] = "Export configuration to generate a human-readable \
-    summary report, with the following name: \
-    ${IMAGE_NAME}.cve.txt \
-"
-SBOM_CVE_CHECK_EXPORT_SUMMARY[type] ?= "summary"
-SBOM_CVE_CHECK_EXPORT_SUMMARY[ext] ?= ".cve.txt"
-
-SBOM_CVE_CHECK_UPDATE_DB_DEPENDENCIES ?= " \
-    sbom-cve-check-update-cvelist-native:do_patch \
-    sbom-cve-check-update-nvd-native:do_patch \
-"
-
-def run_sbom_cve_check(d, sbom_path, export_base_name, export_link_name=None):
-    import os
-    import bb
-    from oe.cve_check import update_symlinks
-
-    if not bb.data.inherits_class("create-spdx-3.0", d):
-        bb.fatal("Cannot execute sbom-cve-check: missing create-spdx-3.0 inherit.")
-
-    dl_db_dir = d.getVar("SBOM_CVE_CHECK_DEPLOY_DB_DIR")
-    out_deploy_dir = d.getVar("SBOM_CVE_CHECK_DEPLOYDIR")
-
-    export_files = []
-    for export_var in d.getVar("SBOM_CVE_CHECK_EXPORT_VARS").split():
-        export_ext = d.getVarFlag(export_var, "ext")
-        export_path = f"{out_deploy_dir}/{export_base_name}{export_ext}"
-        export_link = f"{out_deploy_dir}/{export_link_name}{export_ext}" if export_link_name else None
-        export_type = d.getVarFlag(export_var, "type")
-        export_files.append((export_type, export_path, export_link))
-
-    cmd_env = os.environ.copy()
-    cmd_env["SBOM_CVE_CHECK_DATABASES_DIR"] = dl_db_dir
-
-    cmd_args = [
-        d.expand("${STAGING_BINDIR_NATIVE}/sbom-cve-check"),
-        "--sbom-path",
-        sbom_path,
-        "--disable-auto-updates"
-    ]
-
-    for export_type, export_file, export_link in export_files:
-        cmd_args.extend(
-            ["--export-type", export_type, "--export-path", export_file]
-        )
-
-    cmd_args.extend(d.getVar("SBOM_CVE_CHECK_EXTRA_ARGS").split())
-
-    try:
-        bb.note("Running: {}".format(" ".join(cmd_args)))
-        bb.process.run(cmd_args, env=cmd_env)
-    except bb.process.ExecutionError as e:
-        bb.error(f"sbom-cve-check failed: {e}")
-        return
-
-    for export_type, export_file, export_link in export_files:
-        bb.note(f"sbom-cve-check exported: {export_file}")
-        if export_link:
-            update_symlinks(export_file, export_link)
-
+inherit sbom-cve-check-common
 
 python do_sbom_cve_check() {
     """
meta/classes/sbom-cve-check-common.bbclass new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
2.43.0
#7 lore raw

PATCH v2 7/7 classes/sbom-cve-check-recipe: add recipe-scanning class

In reply to Ross Burton

Add a second sbom-cve-check class that scans the recipe-SBOM, unlike sbom-cve-check.bbclass which scans specifically an image's SBOM.

In most cases, image-derived SBOM scanning is preferred as this is able to analyse the actual content of the image, e.g. reporting just the kernel issues that have actually been compiled into the image (for linux-yocto 6.18.19, this reduces the CVE count from 108 to 52).

However, for metrics or other specific purposes it might be useful to scan a recipe-SPDX, so add a class that can do this.

---
 meta/classes/sbom-cve-check-recipe.bbclass | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 meta/classes/sbom-cve-check-recipe.bbclass
meta/classes/sbom-cve-check-recipe.bbclass new file +35 -0
new file mode 100644
index 0000000000..904ce57f5c
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: MIT
+
+# Perform CVE analysis on recipe SBOMs using sbom-cve-check.
+#
+# This will analyse the entire SBOM for the recipe, so the recipe itself and
+# all of the dependencies. It is expected that for most purposes
+# sbom-cve-check.bbclass is preferred as that will analyse what is deployed
+# in an image.
+
+inherit sbom-cve-check-common
+
+python do_sbom_cve_check_recipe() {
+    """
+    Task: Run sbom-cve-check analysis on a recipe SBOM.
+    """
+    sbom_path = d.expand("${DEPLOY_DIR_IMAGE}/${SPDX_RECIPE_SBOM_NAME}.spdx.json")
+    recipe = d.getVar("SPDX_RECIPE_SBOM_NAME")
+    run_sbom_cve_check(d, sbom_path, recipe)
+}
+
+addtask do_sbom_cve_check_recipe after do_create_recipe_sbom
+
+SSTATETASKS += "do_sbom_cve_check_recipe"
+do_sbom_cve_check_recipe[cleandirs] = "${SBOM_CVE_CHECK_DEPLOYDIR}"
+do_sbom_cve_check_recipe[sstate-inputdirs] = "${SBOM_CVE_CHECK_DEPLOYDIR}"
+do_sbom_cve_check_recipe[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
+do_sbom_cve_check_recipe[depends] += " \
+    python3-sbom-cve-check-native:do_populate_sysroot \
+    ${SBOM_CVE_CHECK_UPDATE_DB_DEPENDENCIES} \
+"
+
+python do_sbom_cve_check_recipe_setscene() {
+    sstate_setscene(d)
+}
+addtask do_sbom_cve_check_recipe_setscene
Signature · 1 line
2.43.0