From: Stefano Tondo <stondo@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>,
Alexander Kanavin <alex.kanavin@gmail.com>,
Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>,
Paul Barker <paul@pbarker.dev>,
Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>,
Peter Marko <peter.marko@siemens.com>,
stefano.tondo.ext@siemens.com
Subject: [PATCH v4 3/4] spdx30: Add the PURLs of the source downloads to the output packages
Date: Wed, 25 Nov 2026 19:36:12 +0100 [thread overview]
Message-ID: <20261125183613.1335718-4-stondo@gmail.com> (raw)
In-Reply-To: <20261125183613.1335718-1-stondo@gmail.com>
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.
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. Leave out the downloads that a function in
SPDX_DEPENDENCY_SCOPE_FUNCS shows are not built into the target, for
example crates that only run at build time. The software_packageUrl
of the package stays the first PURL in SPDX_PACKAGE_URLS.
Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
meta/lib/oe/spdx30_tasks.py | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index 588be68e58..d613b4dad1 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -482,6 +482,9 @@ def add_dependency_scopes(d, objset, build, source_files):
The build gets a scoped dependsOn relationship to each download with a
scope. A download that is fetched but not used on the target gets an
annotation instead.
+
+ Returns the downloads that are not built into the target: downloads
+ that are not used on it, and downloads with a scope other than runtime.
"""
downloads = {}
for dl in source_files:
@@ -500,10 +503,13 @@ def add_dependency_scopes(d, objset, build, source_files):
)
by_scope = {}
+ not_in_target = set()
for purl, scope in scopes.items():
if scope is not None and scope not in oe.spdx30.LifecycleScopeType.NAMED_INDIVIDUALS:
bb.fatal("SPDX_DEPENDENCY_SCOPE_FUNCS: %s is not a lifecycle scope" % scope)
for dl in downloads.get(purl, []):
+ if scope != "runtime":
+ not_in_target.add(dl)
if scope is None:
objset.new_annotation(
dl,
@@ -522,6 +528,8 @@ def add_dependency_scopes(d, objset, build, source_files):
sorted(oe.sbom30.get_element_link_id(dl) for dl in dls),
)
+ return not_in_target
+
def add_download_files(d, objset):
inputs = set()
@@ -1025,7 +1033,18 @@ def create_spdx(d):
source_files = add_download_files(d, build_objset)
build_inputs |= source_files
- add_dependency_scopes(d, build_objset, build, 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. Only
+ # the downloads known not to be built into the target are left out.
+ not_in_target = add_dependency_scopes(d, build_objset, build, source_files)
+ dependency_purls = sorted(
+ {
+ dl.software_packageUrl
+ for dl in source_files
+ if getattr(dl, "software_packageUrl", None) and dl not in not_in_target
+ }
+ )
recipe_spdx_license = add_license_expression(
d, build_objset, d.getVar("LICENSE"), license_data, [recipe_objset]
@@ -1138,7 +1157,7 @@ def create_spdx(d):
d.getVar("SPDX_PACKAGE_URLS:%s" % package)
or d.getVar("SPDX_PACKAGE_URLS")
or ""
- ).split()
+ ).split() + dependency_purls
set_purls(spdx_package, purls)
--
2.56.1
next prev parent reply other threads:[~2026-11-25 18:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:36 [PATCH v4 0/4] spdx30: identity and purls of dependency downloads Stefano Tondo
2026-11-25 18:36 ` [PATCH v4 1/4] spdx30: Take name, version and PURL of downloads from the fetcher Stefano Tondo
2026-11-25 18:36 ` [PATCH v4 2/4] spdx30: Record the lifecycle scope of dependencies Stefano Tondo
2026-11-26 13:24 ` Paul Barker
2026-11-26 23:07 ` Stefano Tondo
2026-11-25 18:36 ` Stefano Tondo [this message]
2026-11-25 18:36 ` [PATCH v4 4/4] oeqa/selftest: spdx: Test crate identity, scope and output PURLs Stefano Tondo
2026-11-26 13:27 ` Paul Barker
2026-11-26 23:07 ` Stefano Tondo
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=20261125183613.1335718-4-stondo@gmail.com \
--to=stondo@gmail.com \
--cc=JPEWhacker@gmail.com \
--cc=alex.kanavin@gmail.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=paul@pbarker.dev \
--cc=peter.marko@siemens.com \
--cc=stefan.herbrechtsmeier@weidmueller.com \
--cc=stefano.tondo.ext@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