From: "'MOESSBAUER, Felix' via isar-users" <isar-users@googlegroups.com>
To: "isar-users@googlegroups.com" <isar-users@googlegroups.com>
Cc: "Steiger, Christoph" <christoph.steiger@siemens.com>,
"Kiszka, Jan" <jan.kiszka@siemens.com>,
"cedric.hombourger@siemens.com" <cedric.hombourger@siemens.com>,
"Hillier, Gernot" <gernot.hillier@siemens.com>
Subject: Re: [RFC PATCH 1/1] meta: add CycloneDX/SPDX SBOM generation
Date: Fri, 1 Aug 2025 07:53:57 +0000 [thread overview]
Message-ID: <9c17b432a88fe4a1154b90213a872531b5309ed6.camel@siemens.com> (raw)
In-Reply-To: <20250220095944.114203-2-felix.moessbauer@siemens.com>
On Thu, 2025-02-20 at 10:59 +0100, 'Felix Moessbauer' via isar-users
wrote:
> From: Christoph Steiger <christoph.steiger@siemens.com>
>
> Add a new class to allow generation of software bill of materials
> (SBOM). Supported are the two standard SBOM formats CycloneDX and
> SPDX.
> SBOM generation is enabled per default for all images.
>
> Both formats support the minimal usecase of binary packages
> information
> and their dependencies. Unfortunately there is no proper way to
> express
> the relationships of debian source packages and their corresponding
> binary packages in the CDX format, so it is left out there.
>
> The information included in the SBOM is parsed from the dpkg status
> file found in the created image.
>
> Signed-off-by: Christoph Steiger <christoph.steiger@siemens.com>
> ---
> meta/classes/create-sbom.bbclass | 49 ++++
> meta/classes/image.bbclass | 2 +
> meta/lib/sbom.py | 446
> +++++++++++++++++++++++++++++++
> meta/lib/sbom_cdx_types.py | 82 ++++++
> meta/lib/sbom_spdx_types.py | 95 +++++++
> 5 files changed, 674 insertions(+)
> create mode 100644 meta/classes/create-sbom.bbclass
> create mode 100644 meta/lib/sbom.py
> create mode 100644 meta/lib/sbom_cdx_types.py
> create mode 100644 meta/lib/sbom_spdx_types.py
>
> diff --git a/meta/classes/create-sbom.bbclass b/meta/classes/create-
> sbom.bbclass
> new file mode 100644
> index 00000000..8c647699
> --- /dev/null
> +++ b/meta/classes/create-sbom.bbclass
> @@ -0,0 +1,49 @@
> +# This software is a part of ISAR.
> +# Copyright (C) 2025 Siemens AG
> +#
> +# SPDX-License-Identifier: MIT
> +
> +# sbom type to generate, accepted are "cyclonedx" and "spdx"
> +SBOM_TYPE ?= "cyclonedx spdx"
> +
> +# general user variables
> +SBOM_DISTRO_SUPPLIER ?= "ISAR"
> +SBOM_DISTRO_NAME ?= "ISAR-Debian-GNU-Linux"
> +SBOM_DISTRO_VERSION ?= "1.0.0"
> +SBOM_DISTRO_SUMMARY ?= "Linux distribution built with ISAR"
> +SBOM_DOCUMENT_UUID ?= ""
> +
> +# SPDX specific user variables
> +SBOM_SPDX_NAMESPACE_PREFIX ?= "https://spdx.org/spdxdocs"
> +
> +SBOM_DEPLOY_BASE = "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}"
> +
> +SBOM_GEN_VERSION = "0.1.0"
> +
> +# adapted from the isar-cip-core image_uuid.bbclass
> +def generate_document_uuid(d):
> + import uuid
> +
> + base_hash = d.getVar("BB_TASKHASH")
> + if base_hash is None:
> + bb.warn("no BB_TASKHASH available, SBOM UUID is not
> reproducible")
> + return uuid.uuid4()
> + return str(uuid.UUID(base_hash[:32], version=4))
> +
> +python do_create_sbom() {
> + import sbom
> +
> + dpkg_status = d.getVar("IMAGE_ROOTFS") + "/var/lib/dpkg/status"
> + packages = sbom.Package.parse_status_file(dpkg_status)
> +
> + if not d.getVar("SBOM_DOCUMENT_UUID"):
> + d.setVar("SBOM_DOCUMENT_UUID", generate_document_uuid(d))
> +
> + sbom_type = d.getVar("SBOM_TYPE")
> + if "cyclonedx" in sbom_type:
> + sbom.generate(d, packages, sbom.SBOMType.CycloneDX,
> d.getVar("SBOM_DEPLOY_BASE") + ".cyclonedx.json")
> + if "spdx" in sbom_type:
> + sbom.generate(d, packages, sbom.SBOMType.SPDX,
> d.getVar("SBOM_DEPLOY_BASE") + ".spdx.json")
> +}
> +
> +addtask do_create_sbom after do_rootfs before do_build
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 56eca202..e9da6a61 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -81,6 +81,8 @@ inherit image-postproc-extension
> inherit image-locales-extension
> inherit image-account-extension
>
> +inherit create-sbom
Hi,
is there a particular reasons, why we add the SBOM generation to the
image class instead of the rootfs? I'm also wondering if we could model
the SBOM generation as a rootfs feature. By that, we could easily
switch it on / off for relevant rootfs' like the external initrd or a
container rootfs.
In the image class, we could add an additional sbom-merger, that merges
the rootfs SBOMs into one big one that contains all data which finally
ends up in the image.
Felix
> +
> # Extra space for rootfs in MB
> ROOTFS_EXTRA ?= "64"
>
>
--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/9c17b432a88fe4a1154b90213a872531b5309ed6.camel%40siemens.com.
next prev parent reply other threads:[~2025-08-01 7:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 9:59 [RFC PATCH 0/1] SBOM Generation for isar 'Felix Moessbauer' via isar-users
2025-02-20 9:59 ` [RFC PATCH 1/1] meta: add CycloneDX/SPDX SBOM generation 'Felix Moessbauer' via isar-users
2025-02-20 18:58 ` 'Gernot Hillier' via isar-users
2025-03-04 11:54 ` 'Niedermayr, BENEDIKT' via isar-users
2025-03-04 12:12 ` 'Christoph Steiger' via isar-users
2025-06-10 12:03 ` 'Christoph Steiger' via isar-users
2025-07-14 12:16 ` 'Simone Weiß' via isar-users
2025-07-28 15:13 ` 'MOESSBAUER, Felix' via isar-users
2025-07-29 9:08 ` 'Christoph' via isar-users
2025-07-28 15:24 ` 'MOESSBAUER, Felix' via isar-users
2025-07-29 8:49 ` 'Christoph' via isar-users
2025-08-01 7:53 ` 'MOESSBAUER, Felix' via isar-users [this message]
2025-07-31 5:38 ` [RFC PATCH 0/1] SBOM Generation for isar Syeda Shagufta Naaz
2025-07-31 6:50 ` 'Christoph Steiger' via isar-users
2025-07-31 7:24 ` 'Jan Kiszka' via isar-users
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=9c17b432a88fe4a1154b90213a872531b5309ed6.camel@siemens.com \
--to=isar-users@googlegroups.com \
--cc=cedric.hombourger@siemens.com \
--cc=christoph.steiger@siemens.com \
--cc=felix.moessbauer@siemens.com \
--cc=gernot.hillier@siemens.com \
--cc=jan.kiszka@siemens.com \
/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