From 9cbbc477626c433fe78614de9474f8446b7e2389 Mon Sep 17 00:00:00 2001 From: Fabien Lehoussel Date: Wed, 16 Jul 2025 11:33:47 +0200 Subject: [PATCH] utils/generate-cyclonedx: add project name and version options Add options to customize the project name and version in the generated SBOM metadata and set buildroot generate-cyclonedx as a tool in the metadata section. Signed-off-by: Fabien Lehoussel Signed-off-by: Peter Korsgaard --- utils/generate-cyclonedx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/utils/generate-cyclonedx b/utils/generate-cyclonedx index d662f02527..34e5672a43 100755 --- a/utils/generate-cyclonedx +++ b/utils/generate-cyclonedx @@ -279,6 +279,10 @@ def main(): default=sys.stdout) parser.add_argument("--virtual", default=False, action='store_true', help="This option includes virtual packages to the CycloneDX output") + parser.add_argument("--project-name", type=str, default="buildroot", + help="Specify the project name to use in the SBOM metadata (default:'buildroot')") + parser.add_argument("--project-version", type=str, default=f"{BR2_VERSION_FULL}", + help="Specify the project version to use in the SBOM metadata (default: builroot version)") args = parser.parse_args() @@ -299,11 +303,27 @@ def main(): "specVersion": f"{CYCLONEDX_VERSION}", "metadata": { "component": { - "bom-ref": "buildroot", - "name": "buildroot", + "bom-ref": args.project_name, + "name": args.project_name, + "version": args.project_version, "type": "firmware", - "version": f"{BR2_VERSION_FULL}", }, + "tools": { + "components": [ + { + "type": "application", + "name": "Buildroot generate-cyclonedx", + "version": f"{BR2_VERSION_FULL}", + "licenses": [ + { + "license": { + "id": "GPL-2.0" + } + } + ] + } + ], + } }, "components": [ cyclonedx_component(name, comp) for name, comp in filtered_show_info_dict.items()