@@ -274,37 +274,24 @@ spec:
274
274
name : varlibcontainers
275
275
workingDir : $(workspaces.source.path)
276
276
- name : sbom-generate
277
- image : quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
277
+ image : quay.io/acmiel-test/sbom-utility-scripts:spdx-support
278
278
script : |
279
279
#!/bin/bash
280
- cat >sbom-cyclonedx.json <<EOL
281
- {
282
- "\$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
283
- "bomFormat": "CycloneDX",
284
- "specVersion": "1.5",
285
- "version": 1,
286
- "components": []
287
- "metadata": {
288
- "component": {
289
- "type": "file",
290
- "name": "${IMAGE%:*}@$(cat "$(results.IMAGE_DIGEST.path)")"
291
- }
292
- }
293
- }
294
- EOL
280
+ set -euo pipefail
295
281
296
- for varfile in "$(workspaces.source.path)"/vars/*; do
297
- echo "Reading $varfile"
298
- # shellcheck source=/dev/null
299
- source $varfile
282
+ IMAGE_URL=$(cat "$(results.IMAGE_URL.path)")
283
+ IMAGE_DIGEST=$(cat "$(results.IMAGE_DIGEST.path)")
284
+ oci_copy_file_path="$(pwd)/source/$OCI_COPY_FILE"
300
285
301
- ENCODED_URL=$(echo "${OCI_SOURCE}" | python3 -c 'import sys; import urllib.parse; print(urllib.parse.quote(sys.stdin.read().strip(), safe=":/"))')
302
- ENCODED_FILENAME=$(echo "${OCI_FILENAME}" | python3 -c 'import sys; import urllib.parse; print(urllib.parse.quote(sys.stdin.read().strip(), safe=":/"))')
303
- purl="pkg:generic/${ENCODED_FILENAME}?download_url=${ENCODED_URL}&checksum=sha256:${OCI_ARTIFACT_DIGEST}"
286
+ python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" -o sbom-cyclonedx.json
304
287
305
- echo "Recording purl $purl"
306
- yq -oj -i '.components += [ {"purl": "'$purl'", "type": "file", "name": "'$OCI_FILENAME'", "hashes": [{"alg": "SHA-256", "content": "'$OCI_ARTIFACT_DIGEST'"}], "externalReferences": [{"type": "distribution", "url": "'$OCI_SOURCE'"}]} ]' sbom-cyclonedx.json
307
- done
288
+ python3 /scripts/add_image_reference.py \
289
+ --image-url "$IMAGE_URL" \
290
+ --image-digest "$IMAGE_DIGEST" \
291
+ --input-file sbom-cyclonedx.json \
292
+ --output-file /tmp/sbom-cyclonedx.tmp.json
293
+
294
+ mv /tmp/sbom-cyclonedx.tmp.json sbom-cyclonedx.json
308
295
workingDir : $(workspaces.source.path)
309
296
- name : upload-sbom
310
297
image : quay.io/konflux-ci/appstudio-utils:48c311af02858e2422d6229600e9959e496ddef1@sha256:91ddd999271f65d8ec8487b10f3dd378f81aa894e11b9af4d10639fd52bba7e8
0 commit comments