Skip to content

Commit 9e9e4ac

Browse files
committed
oci-copy: support SPDX
Add SBOM_TYPE param to allow choosing the SBOM format to generate. Defaults to cyclonedx for now. Signed-off-by: Adam Cmiel <[email protected]>
1 parent 8e99de3 commit 9e9e4ac

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

task/oci-copy-oci-ta/0.1/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Given a file in the user's source directory, copy content from arbitrary urls in
99
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|does-not-exist|false|
1010
|IMAGE|Reference of the image we will push||true|
1111
|OCI_COPY_FILE|Path to the oci copy file.|./oci-copy.yaml|false|
12+
|SBOM_TYPE|Select the SBOM format to generate. Valid values: spdx, cyclonedx.|cyclonedx|false|
1213
|SOURCE_ARTIFACT|The Trusted Artifact URI pointing to the artifact with the application source code.||true|
1314

1415
## Results

task/oci-copy-oci-ta/0.1/oci-copy-oci-ta.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ spec:
3737
description: Path to the oci copy file.
3838
type: string
3939
default: ./oci-copy.yaml
40+
- name: SBOM_TYPE
41+
description: 'Select the SBOM format to generate. Valid values: spdx,
42+
cyclonedx.'
43+
type: string
44+
default: cyclonedx
4045
- name: SOURCE_ARTIFACT
4146
description: The Trusted Artifact URI pointing to the artifact with
4247
the application source code.
@@ -61,6 +66,8 @@ spec:
6166
value: $(params.IMAGE)
6267
- name: OCI_COPY_FILE
6368
value: $(params.OCI_COPY_FILE)
69+
- name: SBOM_TYPE
70+
value: $(params.SBOM_TYPE)
6471
volumeMounts:
6572
- mountPath: /var/workdir
6673
name: workdir
@@ -304,27 +311,29 @@ spec:
304311
IMAGE_DIGEST=$(cat "$(results.IMAGE_DIGEST.path)")
305312
oci_copy_file_path="$(pwd)/source/$OCI_COPY_FILE"
306313
307-
python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" -o sbom-cyclonedx.json
314+
python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" \
315+
--sbom-type "$SBOM_TYPE" \
316+
-o sbom.json
308317
309318
python3 /scripts/add_image_reference.py \
310319
--image-url "$IMAGE_URL" \
311320
--image-digest "$IMAGE_DIGEST" \
312-
--input-file sbom-cyclonedx.json \
313-
--output-file /tmp/sbom-cyclonedx.tmp.json
321+
--input-file sbom.json \
322+
--output-file /tmp/sbom.tmp.json
314323
315-
mv /tmp/sbom-cyclonedx.tmp.json sbom-cyclonedx.json
324+
mv /tmp/sbom.tmp.json sbom.json
316325
- name: upload-sbom
317326
image: quay.io/konflux-ci/appstudio-utils:48c311af02858e2422d6229600e9959e496ddef1@sha256:91ddd999271f65d8ec8487b10f3dd378f81aa894e11b9af4d10639fd52bba7e8
318327
workingDir: /var/workdir
319328
script: |
320-
cosign attach sbom --sbom sbom-cyclonedx.json --type cyclonedx "$(cat "$(results.IMAGE_REF.path)")"
329+
cosign attach sbom --sbom sbom.json --type "$SBOM_TYPE" "$(cat "$(results.IMAGE_REF.path)")"
321330
- name: report-sbom-url
322331
image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
323332
workingDir: /var/workdir
324333
script: |
325334
#!/bin/bash
326335
REPO=${IMAGE%:*}
327336
echo "Found that ${REPO} is the repository for ${IMAGE}"
328-
SBOM_DIGEST=$(sha256sum sbom-cyclonedx.json | awk '{ print $1 }')
337+
SBOM_DIGEST=$(sha256sum sbom.json | awk '{ print $1 }')
329338
echo "Found that ${SBOM_DIGEST} is the SBOM digest"
330339
echo -n "${REPO}@sha256:${SBOM_DIGEST}" | tee $(results.SBOM_BLOB_URL.path)

task/oci-copy/0.1/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Note: the bearer token secret, if specified, will be sent to **all servers liste
1515
|OCI_COPY_FILE|Path to the oci copy file.|./oci-copy.yaml|false|
1616
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|does-not-exist|false|
1717
|AWS_SECRET_NAME|Name of a secret which will be made available to the build to construct Authorization headers for requests to Amazon S3 using v2 auth https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html. If specified, this will take precedence over BEARER_TOKEN_SECRET_NAME. The secret must contain two keys: `aws_access_key_id` and `aws_secret_access_key`. In the future, this will be reimplemented to use v4 auth: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html.|does-not-exist|false|
18+
|SBOM_TYPE|Select the SBOM format to generate. Valid values: spdx, cyclonedx.|cyclonedx|false|
1819

1920
## Results
2021
|name|description|

task/oci-copy/0.1/oci-copy.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ spec:
3434
https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html.
3535
type: string
3636
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+
3742
results:
3843
- description: Digest of the artifact just pushed
3944
name: IMAGE_DIGEST
@@ -49,6 +54,8 @@ spec:
4954
value: $(params.OCI_COPY_FILE)
5055
- name: IMAGE
5156
value: $(params.IMAGE)
57+
- name: SBOM_TYPE
58+
value: $(params.SBOM_TYPE)
5259
steps:
5360
- name: prepare
5461
image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
@@ -283,28 +290,30 @@ spec:
283290
IMAGE_DIGEST=$(cat "$(results.IMAGE_DIGEST.path)")
284291
oci_copy_file_path="$(pwd)/source/$OCI_COPY_FILE"
285292
286-
python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" -o sbom-cyclonedx.json
293+
python3 /scripts/sbom_for_oci_copy_task.py "$oci_copy_file_path" \
294+
--sbom-type "$SBOM_TYPE" \
295+
-o sbom.json
287296
288297
python3 /scripts/add_image_reference.py \
289298
--image-url "$IMAGE_URL" \
290299
--image-digest "$IMAGE_DIGEST" \
291-
--input-file sbom-cyclonedx.json \
292-
--output-file /tmp/sbom-cyclonedx.tmp.json
300+
--input-file sbom.json \
301+
--output-file /tmp/sbom.tmp.json
293302
294-
mv /tmp/sbom-cyclonedx.tmp.json sbom-cyclonedx.json
303+
mv /tmp/sbom.tmp.json sbom.json
295304
workingDir: $(workspaces.source.path)
296305
- name: upload-sbom
297306
image: quay.io/konflux-ci/appstudio-utils:48c311af02858e2422d6229600e9959e496ddef1@sha256:91ddd999271f65d8ec8487b10f3dd378f81aa894e11b9af4d10639fd52bba7e8
298307
workingDir: $(workspaces.source.path)
299308
script: |
300-
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)")"
301310
- name: report-sbom-url
302311
image: quay.io/konflux-ci/yq:latest@sha256:93bb15cff64b708263055a5814b24a0b450d8724b86a7e5206396f25d81fcc21
303312
script: |
304313
#!/bin/bash
305314
REPO=${IMAGE%:*}
306315
echo "Found that ${REPO} is the repository for ${IMAGE}"
307-
SBOM_DIGEST=$(sha256sum sbom-cyclonedx.json | awk '{ print $1 }')
316+
SBOM_DIGEST=$(sha256sum sbom.json | awk '{ print $1 }')
308317
echo "Found that ${SBOM_DIGEST} is the SBOM digest"
309318
echo -n "${REPO}@sha256:${SBOM_DIGEST}" | tee $(results.SBOM_BLOB_URL.path)
310319
workingDir: $(workspaces.source.path)

0 commit comments

Comments
 (0)