@@ -199,14 +199,33 @@ runs:
199199 # same merged, deduplicated inventory.
200200 syft convert sbom.merged.json --output spdx-json=sbom.spdx.raw.json
201201
202- # Normalise deprecated SPDX license identifiers that strict validators and
203- # some consumers reject. syft still emits the deprecated standalone form
204- # "GPL-2.0-with-classpath-exception"; rewrite it to the valid WITH
205- # expression. Extend the `fix` chain if further deprecated ids show up.
206- jq '
202+ # Post-process the converted SPDX SBOM:
203+ # 1. Normalise deprecated SPDX license identifiers that strict
204+ # validators reject. syft still emits the deprecated standalone form
205+ # "GPL-2.0-with-classpath-exception"; rewrite it to the valid WITH
206+ # expression. Extend the `fix` chain if further deprecated ids show up.
207+ # 2. Restore top-level metadata that the CycloneDX -> SPDX conversion
208+ # drops: credit Stackable as an SBOM creator, and set the name,
209+ # version, originator, supplier and purl of the root container
210+ # package.
211+ jq --arg source_name "$SOURCE_NAME" --arg version "$IMAGE_MANIFEST_TAG" --arg purl "$PURL" '
207212 def fix: gsub("GPL-2.0-with-classpath-exception"; "GPL-2.0-only WITH Classpath-exception-2.0");
208213 (.. | .licenseDeclared? // empty) |= (if type == "string" then fix else . end)
209214 | (.. | .licenseConcluded? // empty) |= (if type == "string" then fix else . end)
215+ | .creationInfo.creators += ["Organization: Stackable GmbH"]
216+ | (first(.relationships[]? | select(.relationshipType == "DESCRIBES") | .relatedSpdxElement)) as $root
217+ | .packages |= map(
218+ if .SPDXID == $root then
219+ .name = $source_name
220+ | .versionInfo = $version
221+ | .supplier = "Organization: Stackable GmbH"
222+ | .originator = "Organization: Stackable GmbH"
223+ | .externalRefs = ((.externalRefs // []) + [{
224+ "referenceCategory": "PACKAGE-MANAGER",
225+ "referenceType": "purl",
226+ "referenceLocator": $purl
227+ }])
228+ else . end)
210229 ' sbom.spdx.raw.json > sbom.spdx.json
211230
212231 # Attest the SPDX SBOM to the image
0 commit comments