* [PATCH v5 0/3] spdx30: identity and purls of dependency downloads
@ 2026-11-26 23:07 Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher Stefano Tondo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefano Tondo @ 2026-11-26 23:07 UTC (permalink / raw)
To: openembedded-core
Cc: JPEWhacker, alex.kanavin, stefan.herbrechtsmeier, paul,
mathieu.dubois-briand, peter.marko, stefano.tondo.ext
From: Stefano Tondo <stefano.tondo.ext@siemens.com>
Hi,
This series implements the parts of the RFC "spdx30: name, version
and purl for dependency downloads" [1] that we agreed on. It needs
package_identity() from the bitbake series "fetch: package identity
of crate, gomod and npm URLs" [2], which is in bitbake master.
1. The SPDX of a crate, gomod or npm download gets the name, the
version and the purl from the fetcher.
2. Each output package gets the purls of its source downloads as
external identifiers, as Joshua proposed [3]: a statically linked
dependency is part of the binary. The software_packageUrl of the
package does not change.
3. Selftests with hello-rs from meta-selftest.
The output packages get the purls of all source downloads, also of
the ones that are not built into the binary. For python3-bcrypt, the
package gets the purls of all 42 crates, and 17 of them are not built
into the target. v4 left these out with a lifecycle scope for each
dependency. Paul asked for a proposal on the openembedded-architecture
list first [4], so v5 drops that part. I will send the proposal
separately.
Changes in v5:
- Drop v4 patch 2/4 "spdx30: Record the lifecycle scope of
dependencies", as Paul asked [4].
- Patch 2/3: add the purls of all source downloads, with no filter.
Joshua called the filter optional [3].
- Patch 2/3: a download purl does not become the software_packageUrl
of a package when SPDX_PACKAGE_URLS is empty. In v4 it did.
- Patch 3/3: test with hello-rs from meta-selftest. It has a fixed
SRCREV and one crate. v4 used python3-bcrypt and rpm-sequoia from
oe-core, and as Paul noted, their crates can change on upgrades [5].
- Rebased on master.
Changes in v4:
- Patch 2/4: the SPDX code does not read the cargo graph anymore, as
Joshua asked [6]. create_spdx calls the functions in
SPDX_DEPENDENCY_SCOPE_FUNCS. cargo.bbclass adds
oe.rust.cargo_dependency_scopes(), and the walk over the cargo
graph moves to oe/rust.py.
- Patch 2/4: do_cargo_metadata writes the graph with all features.
v3 used the default features. rpm-sequoia builds with the feature
crypto-openssl, so v3 annotated openssl-sys as not built and left
its purl out of the package.
- Patch 2/4: do_cargo_metadata does not fail when cargo cannot give
the graph. In v3 it failed for mozjs-140 in meta-oe, which
configures the crate sources in its own way.
- Patch 3/4: uses the result of the scope functions, so it is not
specific to Cargo anymore.
- Patch 4/4: add a test with rpm-sequoia.
- Patch 1/4: add the Reviewed-by of Joshua.
- Rebased on master.
Changes in v3:
- Patch 1/4: read the PackageIdentity dataclass that
package_identity() returns in v2 of the bitbake series [2], as Paul
proposed [7].
- Rebased on master, which has python3-uv-build 0.13.8.
Changes in v2:
- Patch 2/4: the walk over the cargo graph expands each workspace
member only once. In v1 it did not end for python3-uv-build, where
the member uv-preview is a dev dependency of itself. do_create_spdx
used memory until the OOM killer stopped it. Thanks to Mathieu for
the report [8].
- Patch 2/4: add unit tests for the scopes, with member cycles.
- Rebased on master.
Tests: 18 of the 20 tests of oe-selftest -r spdx.SPDX30Check pass on
master. I did not run test_core_image_minimal_sdk and test_world_sbom.
The two new tests of the output package fail without patch 2/3. The
test with an empty SPDX_PACKAGE_URLS also fails with the v4 code.
[1] https://lore.kernel.org/openembedded-core/20261105122145.543282-1-stondo@gmail.com/
[2] https://lore.kernel.org/bitbake-devel/20261119204856.2930668-1-stondo@gmail.com/
[3] https://lore.kernel.org/openembedded-core/CAJdd5GZTCwr9VE8OmOw7RAki+Xu+kokCgtOHG+9ghE3frWPbqg@mail.gmail.com/
[4] https://lore.kernel.org/openembedded-core/DN56BR66WII7.34FC67CIINIBB@pbarker.dev/
[5] https://lore.kernel.org/openembedded-core/DN56EKP8RI3N.UY4F4DI6PFGI@pbarker.dev/
[6] https://lore.kernel.org/openembedded-core/CAJdd5GaVPXT8Af3qNPWRArPLRMupC875nHSw_jdqBs_563hjkw@mail.gmail.com/
[7] https://lore.kernel.org/bitbake-devel/DMZ3ERL47CEB.3KE9TOG6YIZPD@pbarker.dev/
[8] https://lore.kernel.org/openembedded-core/DMYFTUY2A6RH.1WI2PDCNCPOJY@bootlin.com/
Stefano Tondo (3):
spdx30: Take name, version and PURL of downloads from the fetcher
spdx30: Add the PURLs of the source downloads to the output packages
oeqa/selftest: spdx: Test crate identity and output PURLs
meta/lib/oe/spdx30_tasks.py | 28 ++++++++++++--
meta/lib/oeqa/selftest/cases/spdx.py | 55 ++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 3 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher
2026-11-26 23:07 [PATCH v5 0/3] spdx30: identity and purls of dependency downloads Stefano Tondo
@ 2026-11-26 23:07 ` Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 2/3] spdx30: Add the PURLs of the source downloads to the output packages Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 3/3] oeqa/selftest: spdx: Test crate identity and output PURLs Stefano Tondo
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Tondo @ 2026-11-26 23:07 UTC (permalink / raw)
To: openembedded-core
Cc: JPEWhacker, alex.kanavin, stefan.herbrechtsmeier, paul,
mathieu.dubois-briand, peter.marko, stefano.tondo.ext
From: Stefano Tondo <stefano.tondo.ext@siemens.com>
The fetchers of package registries (crate, gomod, npm) know the name
and the version of each package they download. Today the SPDX of such
a download only has the file name, so an SBOM scanner cannot match
the dependency.
Ask the fetcher with package_identity() and set the name, the version
and the PURL of the download. This needs package_identity() in
bitbake.
Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
Reviewed-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/lib/oe/spdx30_tasks.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index 6eaa74ce3d..eded315819 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -463,6 +463,19 @@ def enrich_source_package(d, dl, fd, file_name, primary_purpose):
)
+def set_package_identity(d, dl, fd):
+ """Set name, version and PURL of a download that names a package.
+
+ Fetchers of package registries (crate, gomod, npm) know which package
+ a URL downloads, see FetchMethod.package_identity() in bitbake.
+ """
+ identity = fd.method.package_identity(fd, d)
+ if identity:
+ dl.name = identity.name
+ dl.software_packageVersion = identity.version
+ dl.software_packageUrl = identity.purl
+
+
def add_download_files(d, objset):
inputs = set()
release_date = get_release_date(d)
@@ -528,6 +541,7 @@ def add_download_files(d, objset):
)
enrich_source_package(d, dl, fd, file_name, primary_purpose)
+ set_package_identity(d, dl, fd)
if release_date is not None:
dl.releaseTime = release_date
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 2/3] spdx30: Add the PURLs of the source downloads to the output packages
2026-11-26 23:07 [PATCH v5 0/3] spdx30: identity and purls of dependency downloads Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher Stefano Tondo
@ 2026-11-26 23:07 ` Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 3/3] oeqa/selftest: spdx: Test crate identity and output PURLs Stefano Tondo
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Tondo @ 2026-11-26 23:07 UTC (permalink / raw)
To: openembedded-core
Cc: JPEWhacker, alex.kanavin, stefan.herbrechtsmeier, paul,
mathieu.dubois-briand, peter.marko, stefano.tondo.ext
From: Stefano Tondo <stefano.tondo.ext@siemens.com>
Statically linked code, for example a Rust crate, is part of the
binary. But the SPDX of the output package only names the recipe, so
a vulnerability scanner that checks the packages of an image does not
find the dependency.
Add the PURLs of the source downloads to the external identifiers of
each output package. The software_packageUrl of the package stays the
first PURL in SPDX_PACKAGE_URLS.
All downloads with a PURL go in, also the ones that are not in the
binary. For example, a Cargo.lock lists crates that only run at build
time and crates for other platforms. So a scanner can report a crate
that the package does not contain. To leave such downloads out, the
SPDX needs a lifecycle scope for each dependency. That is a separate
proposal.
Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
meta/lib/oe/spdx30_tasks.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index eded315819..8f4e3dc4fc 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -597,11 +597,11 @@ def add_custom_annotations(d, objset, obj):
)
-def set_purls(spdx_package, purls):
+def set_purls(spdx_package, purls, dependency_purls=()):
if purls:
spdx_package.software_packageUrl = purls[0]
- for p in sorted(set(purls)):
+ for p in sorted(set(purls) | set(dependency_purls)):
spdx_package.externalIdentifier.append(
oe.spdx30.ExternalIdentifier(
externalIdentifierType=oe.spdx30.ExternalIdentifierType.packageUrl,
@@ -979,6 +979,14 @@ def create_spdx(d):
source_files = add_download_files(d, build_objset)
build_inputs |= source_files
+ # The output packages inherit the PURLs of the downloads they are built
+ # from, as the code of statically linked dependencies is in them.
+ dependency_purls = {
+ dl.software_packageUrl
+ for dl in source_files
+ if getattr(dl, "software_packageUrl", None)
+ }
+
recipe_spdx_license = add_license_expression(
d, build_objset, d.getVar("LICENSE"), license_data, [recipe_objset]
)
@@ -1092,7 +1100,7 @@ def create_spdx(d):
or ""
).split()
- set_purls(spdx_package, purls)
+ set_purls(spdx_package, purls, dependency_purls)
pkg_objset.new_scoped_relationship(
[oe.sbom30.get_element_link_id(build)],
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 3/3] oeqa/selftest: spdx: Test crate identity and output PURLs
2026-11-26 23:07 [PATCH v5 0/3] spdx30: identity and purls of dependency downloads Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 2/3] spdx30: Add the PURLs of the source downloads to the output packages Stefano Tondo
@ 2026-11-26 23:07 ` Stefano Tondo
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Tondo @ 2026-11-26 23:07 UTC (permalink / raw)
To: openembedded-core
Cc: JPEWhacker, alex.kanavin, stefan.herbrechtsmeier, paul,
mathieu.dubois-briand, peter.marko, stefano.tondo.ext
From: Stefano Tondo <stefano.tondo.ext@siemens.com>
hello-rs from meta-selftest has a fixed SRCREV. It fetches its source
and one git dependency from github.com, and one crate, figlet-rs
0.1.5. The new tests check that:
- The crate download has its name, version and PURL.
- The output package gets the PURLs of the three downloads and keeps
its own PURLs.
- A download PURL does not become the PURL of the package when
SPDX_PACKAGE_URLS is empty.
Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
meta/lib/oeqa/selftest/cases/spdx.py | 55 ++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py
index ce9a8af4f6..17484df591 100644
--- a/meta/lib/oeqa/selftest/cases/spdx.py
+++ b/meta/lib/oeqa/selftest/cases/spdx.py
@@ -543,3 +543,58 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
# Document should be fully linked
self.check_objset_missing_ids(objset)
+
+ # hello-rs is a test recipe with a fixed SRCREV. It fetches its source
+ # and one git dependency from github.com, and one crate.
+ HELLO_RS_DOWNLOAD_PURLS = {
+ "pkg:github/akiernan/hello-bin@d3d096eda182644868f8e7458dcfa538ff637db3",
+ "pkg:github/akiernan/hello-lib@59c84574e844617043cf337bc8fa537cf87ad8ae",
+ "pkg:cargo/figlet-rs@0.1.5",
+ }
+
+ def test_crate_package_identity(self):
+ """Test that a crate download has its name, version and PURL."""
+ objset = self.check_recipe_spdx(
+ "hello-rs",
+ "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/builds/build-hello-rs.spdx.json",
+ )
+
+ crates = [
+ (pkg.name, pkg.software_packageVersion, pkg.software_packageUrl)
+ for pkg in objset.foreach_type(oe.spdx30.software_Package)
+ if (pkg.software_downloadLocation or "").startswith("https://static.crates.io/")
+ ]
+ self.assertEqual(crates, [("figlet-rs", "0.1.5", "pkg:cargo/figlet-rs@0.1.5")])
+
+ def get_package_purls(self, extraconf=""):
+ objset = self.check_recipe_spdx(
+ "hello-rs",
+ "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/packages/package-hello-rs.spdx.json",
+ extraconf=extraconf,
+ )
+ package = next(
+ pkg
+ for pkg in objset.foreach_type(oe.spdx30.software_Package)
+ if pkg.name == "hello-rs"
+ )
+ purls = {
+ e.identifier
+ for e in package.externalIdentifier
+ if e.externalIdentifierType == oe.spdx30.ExternalIdentifierType.packageUrl
+ }
+ return package.software_packageUrl, purls
+
+ def test_download_purls_in_output_package(self):
+ """Test that the output package gets the PURLs of its downloads."""
+ package_purl, purls = self.get_package_purls()
+
+ own_purls = get_bb_var("SPDX_PACKAGE_URLS", "hello-rs").split()
+ self.assertEqual(package_purl, own_purls[0])
+ self.assertEqual(purls, set(own_purls) | self.HELLO_RS_DOWNLOAD_PURLS)
+
+ def test_download_purls_without_package_urls(self):
+ """Test that a download PURL does not become the package PURL."""
+ package_purl, purls = self.get_package_purls('SPDX_PACKAGE_URLS:pn-hello-rs = ""\n')
+
+ self.assertIsNone(package_purl)
+ self.assertEqual(purls, self.HELLO_RS_DOWNLOAD_PURLS)
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 23:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 23:07 [PATCH v5 0/3] spdx30: identity and purls of dependency downloads Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 2/3] spdx30: Add the PURLs of the source downloads to the output packages Stefano Tondo
2026-11-26 23:07 ` [PATCH v5 3/3] oeqa/selftest: spdx: Test crate identity and output PURLs Stefano Tondo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox