|
34 | 34 | https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html.
|
35 | 35 | type: string
|
36 | 36 | default: "does-not-exist"
|
| 37 | + - name: SBOM_TYPE |
| 38 | + description: "Select the SBOM format to generate. Valid values: spdx, cyclonedx." |
| 39 | + type: string |
| 40 | + default: cyclonedx |
| 41 | + |
37 | 42 | results:
|
38 | 43 | - description: Digest of the artifact just pushed
|
39 | 44 | name: IMAGE_DIGEST
|
|
49 | 54 | value: $(params.OCI_COPY_FILE)
|
50 | 55 | - name: IMAGE
|
51 | 56 | value: $(params.IMAGE)
|
| 57 | + - name: SBOM_TYPE |
| 58 | + value: $(params.SBOM_TYPE) |
52 | 59 | steps:
|
53 | 60 | - name: prepare
|
54 | 61 | image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
|
@@ -274,50 +281,39 @@ spec:
|
274 | 281 | name: varlibcontainers
|
275 | 282 | workingDir: $(workspaces.source.path)
|
276 | 283 | - name: sbom-generate
|
277 |
| - image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21 |
| 284 | + image: quay.io/konflux-ci/sbom-utility-scripts@sha256:1939901046f2ec0afda6d48f32dc82f991d9a4e2b4b4513635b9c79e3d4c2872 |
278 | 285 | script: |
|
279 | 286 | #!/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 |
| 287 | + set -euo pipefail |
295 | 288 |
|
296 |
| - for varfile in "$(workspaces.source.path)"/vars/*; do |
297 |
| - echo "Reading $varfile" |
298 |
| - # shellcheck source=/dev/null |
299 |
| - source $varfile |
| 289 | + IMAGE_URL=$(cat "$(results.IMAGE_URL.path)") |
| 290 | + IMAGE_DIGEST=$(cat "$(results.IMAGE_DIGEST.path)") |
| 291 | + oci_copy_file_path="$(pwd)/source/$OCI_COPY_FILE" |
300 | 292 |
|
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}" |
| 293 | + python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" \ |
| 294 | + --sbom-type "$SBOM_TYPE" \ |
| 295 | + -o sbom.json |
304 | 296 |
|
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 |
| 297 | + python3 /scripts/add_image_reference.py \ |
| 298 | + --image-url "$IMAGE_URL" \ |
| 299 | + --image-digest "$IMAGE_DIGEST" \ |
| 300 | + --input-file sbom.json \ |
| 301 | + --output-file /tmp/sbom.tmp.json |
| 302 | +
|
| 303 | + mv /tmp/sbom.tmp.json sbom.json |
308 | 304 | workingDir: $(workspaces.source.path)
|
309 | 305 | - name: upload-sbom
|
310 | 306 | image: quay.io/konflux-ci/appstudio-utils:48c311af02858e2422d6229600e9959e496ddef1@sha256:91ddd999271f65d8ec8487b10f3dd378f81aa894e11b9af4d10639fd52bba7e8
|
311 | 307 | workingDir: $(workspaces.source.path)
|
312 | 308 | script: |
|
313 |
| - cosign attach sbom --sbom sbom-cyclonedx.json --type cyclonedx "$(cat "$(results.IMAGE_REF.path)")" |
| 309 | + cosign attach sbom --sbom sbom.json --type "$SBOM_TYPE" "$(cat "$(results.IMAGE_REF.path)")" |
314 | 310 | - name: report-sbom-url
|
315 | 311 | image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
|
316 | 312 | script: |
|
317 | 313 | #!/bin/bash
|
318 | 314 | REPO=${IMAGE%:*}
|
319 | 315 | echo "Found that ${REPO} is the repository for ${IMAGE}"
|
320 |
| - SBOM_DIGEST=$(sha256sum sbom-cyclonedx.json | awk '{ print $1 }') |
| 316 | + SBOM_DIGEST=$(sha256sum sbom.json | awk '{ print $1 }') |
321 | 317 | echo "Found that ${SBOM_DIGEST} is the SBOM digest"
|
322 | 318 | echo -n "${REPO}@sha256:${SBOM_DIGEST}" | tee $(results.SBOM_BLOB_URL.path)
|
323 | 319 | workingDir: $(workspaces.source.path)
|
|
0 commit comments