From patchwork Thu Nov 26 23:07:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Tondo X-Patchwork-Id: 105805 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.7282.1795734458857199956 for ; Thu, 26 Nov 2026 15:07:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=D4+cPjNO; spf=pass (domain: gmail.com, ip: 209.85.128.50, mailfrom: stondo@gmail.com) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4bb61185057so48373675e9.1 for ; Thu, 26 Nov 2026 15:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795734457; x=1796339257; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6HldrghvJlpN9mTMY86AyoE3qFpe/gYwg6+yoM3Mv+Y=; b=D4+cPjNOXbma0loLNAJgP7kf5dIQGDG15kRRT1EaVFJpu/c4rTNLkmwN97ZGrcEXFL sqAZ6XytkbsG3KdHkvTI/4ZDy75KwxV+n6q0G8CZ1Heg1iRmed5CgTb/iBVvBjqjJpr0 OmOvVY/JfwuQDQ9qw2VM/IbsZXHFxJczgpeZLT2SOm+UwREZqUO2KPcgPfUplk7yr2Gk UYy4BMX//6mbyJynrlG5qYQb9uacvg6K5XZJXGYeezGxfLCKlSfWndir+GZTRi9jbFyz ma/6ZHh20PJimYxYgDtM7Oyn2E09RxUvhMR1NghGnKdTmRrmuHXm0Yhh3b/Lkj3hfpDM SSOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795734457; x=1796339257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6HldrghvJlpN9mTMY86AyoE3qFpe/gYwg6+yoM3Mv+Y=; b=nxOzAjnmJPm93KT3b5RsaZ5+APDIGRd2zk/85UXNEp2HTgMx1ay4gFo2lUAd2LNX+I gdFyz1i5UPF4QnFq9lTguQlakS7yqDFWQ3dmJf0Zg9hrHOURGuZDG1gzdmxi3sCU4cXF dFvXToOg1ThCjIOKAN2BS+2ElyKdqbVT3+uarb8lmNP9zuzA51GO9udXfMPzV6HB9hJj HbyIrX/WxZKd0bXcQlYsghAYKoGxSQGX8alx5kTxPx5t6zPcuzOdMG5ayK7qyGNrSomr yrkgzSyHnr41CvLaVIdJMbH7Ti29OJGa5bb3idawVB5bpis4MU1lmLRrlkoWXtwG2ksB qX+Q== X-Gm-Message-State: APuU4Z8oXwtoOIpUJcvdqbVGyWyaFbiKaQOhzR7WXv50i2CIDzXUbm6u krD1nHD05QJ80iKR4WFu3DvmAGTXfoYEmcYmEXrbSVR1YPXPW/jK6IigECFSSeSO X-Gm-Gg: AZFdTZcsjfrIY/KuWu6pdei1iH1uhbZZ3yyjDPqBik7wu66XqjE2bB/KRpknD/zMVyL urFpHKkqr09SD3Sn4Q/g12Mn2FJ7liekzUwKd24c6fE2JjaW9m+5uWqKTcBdJq6wn6adcrv9HgO sc7A7a/m0Q/mKWXU9+oQko3uikv2WEYLfsi6u2YNF9dbhhy+EjOFCsHLnu/0yLWVCZHot4qsSV6 6aQ3o11tMWnVlOoav62WAhVXq+bhI904961wupXXcy6qN4C5VMVkhZr7YVDuUjfy1Yo/Q+I42ty fSNuKYujNIaqW/DROJQ4IzIgmFKNZu17Hvxj0vdIEfskoVD5BGO8MSqWpZkPZMQb9isyYkPWGwz GTY+cZqZMJd1OcpED6INJBrlkMHduSM6G7Ant9dJXnrSPDZF2qZCkrkY0UMF02hdDL5smkNDUGW I/Liswzt0i2p05efsI19kPbk9DFrRa3Mx9B0Ay3a3k3/FQHj0O4YD1kc88fbm8Ly0h3Dxq9sBH/ fC/CydWBEU7QbHuiEfpcDjE1JynCBIbPt036vMN1v6sXe5MFrZo6av0YzTt18SEgf0lM14K/Tgw P54L6CwYiuA= X-Received: by 2002:a05:600c:a51:b0:4bb:5f43:23bb with SMTP id 5b1f17b1804b1-4bb88828173mr444325245e9.33.1795734457073; Thu, 26 Nov 2026 15:07:37 -0800 (PST) Return-Path: Received: from fedora ([165.225.94.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9846sm748625525e9.11.2026.11.26.15.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:07:35 -0800 (PST) From: Stefano Tondo To: openembedded-core@lists.openembedded.org Cc: JPEWhacker@gmail.com, alex.kanavin@gmail.com, stefan.herbrechtsmeier@weidmueller.com, paul@pbarker.dev, mathieu.dubois-briand@bootlin.com, peter.marko@siemens.com, stefano.tondo.ext@siemens.com Subject: [PATCH v5 1/3] spdx30: Take name, version and PURL of downloads from the fetcher Date: Fri, 27 Nov 2026 00:07:30 +0100 Message-ID: <20261126230732.2708012-2-stondo@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126230732.2708012-1-stondo@gmail.com> References: <20261126230732.2708012-1-stondo@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 26 Nov 2026 23:07:39 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251335 From: Stefano Tondo 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 Reviewed-by: Joshua Watt --- 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 From patchwork Thu Nov 26 23:07:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Tondo X-Patchwork-Id: 105806 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.7283.1795734459906365112 for ; Thu, 26 Nov 2026 15:07:40 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=KScqWfop; spf=pass (domain: gmail.com, ip: 209.85.128.50, mailfrom: stondo@gmail.com) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4bb6ba3b244so76962675e9.3 for ; Thu, 26 Nov 2026 15:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795734458; x=1796339258; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xonWD7Snn0hWh2vwO+f5ySqU3j4QSwz4J3oNMt7n+rU=; b=KScqWfopIReKPPWlPdoOjqt2vSx4kXC7V+/GZ7IySuRDM3qyJawtx7S8NqfCNGv+8E JClv77VYL7KlrrbK0C7XbHqqhO8e/E0vXn6DHNDX5C6vIKn6EJPF5pUCnUf3RCbgf2IR h99ASH562hCrVFwwjQOxRTKPSF0ZbRt7KliYYcLYTfG2V1vHRP8h9T2nZ2Lx/ks1rsmS krZip1MtOkX35vresyWzOnaRIgsw/0bjtTmu2KYaBEGFvSnWqWQ0Pc8gdvLFp4wt5EX9 bKcQL3sDTfMXDOE2DtpiDkRg7V3FED1gAH9S4vrpAy0bAZ+IKTuiCau0VQreSx6edlp0 J6WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795734458; x=1796339258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xonWD7Snn0hWh2vwO+f5ySqU3j4QSwz4J3oNMt7n+rU=; b=KnLa9LgNao+b+QNEjCke4QYB6jnhJgip2RtyZhTI9tGTjQXPvGXFD8LRBjpjbM00Yv S5Pw60bTNdD9mETCeV1t0QKa0964R0bsHI/zbKGU5OvwbqOZ4hsfslYMbmKP7CIvL3Li jWhWuIATx6UM35g5vEHXq7GKOs+rgUFy6kf3nLKdvK7LjHJWNxeODysPJ+oUj/6B52hj HdcgKwJooyRhXtIky+P3Nf4MwQnMyT0rj1fYbpD6vdq4Fk7CmnraQt3dG31MXHApIFH8 pKciWRgE2pmLYwwMh3LJ6MdJUs0Lv9jDWEnZKQnQcAeEtovgONFXtiSfIpYCFsdj6vMz C6bg== X-Gm-Message-State: APuU4Z/b+IqtBi+9olRUMFqht+EwxvCwtqPVoZd80rLbpHybCMq9riEr paoFUDsY8U8XFaON5fZmx4Xt2WMz5uXkWIZXQRnqWDkKnpOSZRbZPIHP5y6J4W+V X-Gm-Gg: AZFdTZfV43eIdFJY3Qg2orguo9QQ4lycpPTUds1Osv804lfjHL4LOlo8VIB3HjuPxBe 15rgdguTSk+Wj4RBlKtv3+VE1/0WpdSM2m2mhQBOWrpMljSeNUXwUcex7WD5Gm3SH5oz/Eg6CtI Gbxb1qzyhioyvEXqr0NxK8gwPk9GJ/TF7zn9WmdcaGeMDyECr9lDtP0GKpNklTZD37QrATOF/sc mtGDe9KEmd9I854y2Oc178djdVwzf5k5RITPVVx6kS/L5kIcmjMm0qak6arRW+v7mJ+TpVraAoI oFYsEMfvddUjZHqJ7RA4lELL8c8CU0V3X4KpT+mj/SoelPqR0jAQyctJSjvow4u4V8t4RmzJOi3 MwbZQwcSlInOrAa3olD9mx/6iYb3WhQMlPEHB7cX2B4neZBbBSWsvgSJY5NCF7jM1Y6HG2iBRkl jcaqw+5vpRtcFjtFMcfXQqw0bM0EClOIUDeZwacfJk2q8iGRzVf2NH81bPNLlo2EHggN2dxfFSP MG6q3WK/IdYfFWsugHlRjZ3dxaD5erKDlqWg50DGdh8mV82pk04D6Jbl72ekxdbhBGzKILYEQ+e Jfh1hVpkux4= X-Received: by 2002:a05:600c:b8a:b0:4bb:7007:4a5a with SMTP id 5b1f17b1804b1-4bb88817772mr465342735e9.23.1795734458093; Thu, 26 Nov 2026 15:07:38 -0800 (PST) Return-Path: Received: from fedora ([165.225.94.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9846sm748625525e9.11.2026.11.26.15.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:07:37 -0800 (PST) From: Stefano Tondo To: openembedded-core@lists.openembedded.org Cc: JPEWhacker@gmail.com, alex.kanavin@gmail.com, stefan.herbrechtsmeier@weidmueller.com, paul@pbarker.dev, mathieu.dubois-briand@bootlin.com, peter.marko@siemens.com, stefano.tondo.ext@siemens.com Subject: [PATCH v5 2/3] spdx30: Add the PURLs of the source downloads to the output packages Date: Fri, 27 Nov 2026 00:07:31 +0100 Message-ID: <20261126230732.2708012-3-stondo@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126230732.2708012-1-stondo@gmail.com> References: <20261126230732.2708012-1-stondo@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 26 Nov 2026 23:07:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251336 From: Stefano Tondo 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 --- 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)], From patchwork Thu Nov 26 23:07:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Tondo X-Patchwork-Id: 105807 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.7103.1795734462170518560 for ; Thu, 26 Nov 2026 15:07:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=yTRWnwLo; spf=pass (domain: gmail.com, ip: 209.85.128.46, mailfrom: stondo@gmail.com) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4bb64c99d2fso69491695e9.3 for ; Thu, 26 Nov 2026 15:07:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795734460; x=1796339260; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uIQYNFg414Ab9Crcc812Ai6xnzWiVIAukwG64D/Zt6M=; b=yTRWnwLohAvT0nJ1A/Pv7MHaP+PK9uRtHfrumxz8C8NLUTl+oHJhaIs8MXzkdftqm4 yVKF2wveO9D6xXuwe1cyGFwh15amEZfpRrMPNqyFyjvyaXuV0rNP7NSiaPS6QuqSArQp fRTQ9xF3n1Xpd8OjoglQbst1htOwll06PNTrwk90Lvzkh+QGahM3F+BOJdXbDFaXsKxz EPY3Sq/AVhC8OvN7ReiBb2MxLrkX0VFDaCbPoV5zDVUKayjnXrv+ZKJmC8sRBAUOLO38 AMiSp5CrpoaEELASUfgAxdLEInwHMtd4jte/ArglPYs052aQttJOlusViSRxPjEqJhc3 y2yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795734460; x=1796339260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=uIQYNFg414Ab9Crcc812Ai6xnzWiVIAukwG64D/Zt6M=; b=TN8RvLnu/dZGWj9H6K/9kirLcMOMReKg90JXRhjgwkvDfyZfZs0ylSl24jrMji34IQ 1YsxoCHGbA82n6TF+HErNHlJMA8qJjRTdcESfxZOeKTuhQa1vF2CehWHAHb8mBpv7Hc+ ucb6zwGYAYR4s0U83tq+/h4o0EJBh2bZo1+1XKxkbIIQpmt2YpT85nnNZfxLJAbpjn5k N/lXEw4uDBz8eGYPLfq4V1klVj4csWKqtBE2QnMsma4KCjbw3OG2AJjzKpr83XdP83CC GYJqQaSFTEfzx9pK2sDE1XW15kjPBRWcUiASE2KdB/HzeZ1SbEUuNdIWPvZ46/trztP1 Xo/A== X-Gm-Message-State: APuU4Z/BCOq5HmF+Jfsqs6pPuOnitvhKzV0kzfZcSgUeMfvUkBknjT9b O2TIZcqVvf50c/MI/lJSukND3CnMp/9MIN5Ac1T7iz534/im9B2m6ANnnaqHPO38 X-Gm-Gg: AZFdTZfVRptHjvSd7FuTTEobERX/6u5f3PbjvHFParp6//VV+pPOTR5lWcolP6/lneo ehY8FX9y8Q3NFWNdrIVAAIXX0ymVOn49FQbtmACWXsHP9bvyDxxtr3CcBPqM/4h571yt5MdCWfS 7ithI91iq/9ucbcEo15vBTyw2H2TbIwMFbsnwZ27sagPc+LDlfGRRU9Y1tFGmdBLmQ5M19Zqa+c Vv+E7zORtbgVxxENUxha9N1gGMS14ndU7htaG/850KFIgzQNM0jKterCSivkn91NRqCiIngsGSp lyb7cRBa0WqffzQyBlcQKxB+kFszgGEYxcNuxTI+lnanJscAt8mRYIp1dV2JqNpzB/DU2Zi2vjR sZfx54CphEvQfXeWfdTrMeFGpORi9doP7+pgnpinM0WQjrWbQyPffGOZfQ7HfU8Jlp9kY1aNQQo fFjFZvndmgqKRDIBrNAY1MW181iEinhH4qq2FusXc7/srPTbTDAXFECBshLSQ0eMFRJl0Hve0At rJJ633LMBb9U1E6g8TbKkYNGvTsQV1sK000b3x7U68mILZxoMEEJwoJvwVN9+Dhcdj7D0SvYV6h 539ejev/F0c= X-Received: by 2002:a05:600c:64c9:b0:4bb:8701:bb14 with SMTP id 5b1f17b1804b1-4bb88804d1cmr482843625e9.5.1795734460295; Thu, 26 Nov 2026 15:07:40 -0800 (PST) Return-Path: Received: from fedora ([165.225.94.251]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9846sm748625525e9.11.2026.11.26.15.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:07:38 -0800 (PST) From: Stefano Tondo To: openembedded-core@lists.openembedded.org Cc: JPEWhacker@gmail.com, alex.kanavin@gmail.com, stefan.herbrechtsmeier@weidmueller.com, paul@pbarker.dev, mathieu.dubois-briand@bootlin.com, peter.marko@siemens.com, stefano.tondo.ext@siemens.com Subject: [PATCH v5 3/3] oeqa/selftest: spdx: Test crate identity and output PURLs Date: Fri, 27 Nov 2026 00:07:32 +0100 Message-ID: <20261126230732.2708012-4-stondo@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126230732.2708012-1-stondo@gmail.com> References: <20261126230732.2708012-1-stondo@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 26 Nov 2026 23:07:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251337 From: Stefano Tondo 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 --- 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)