Skip to content

Commit 36834a2

Browse files
authored
Merge pull request #3158 from simonbaird/keyless-support-in-release-task
Add keyless support to verify-conforma-konflux-ta release pipeline task also
2 parents 1d37a50 + aa96d8f commit 36834a2

5 files changed

Lines changed: 169 additions & 81 deletions

File tree

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,17 @@ focus-acceptance: build ## Run acceptance tests with @focus tag
144144
# The `|| true` here is so the @focus tag still gets removed after a failure.
145145
feature_%: ## Run acceptance tests for a single feature file, e.g. make feature_validate_image
146146
@echo "Testing feature '$*'"
147+
@#
147148
@sed -i '1i@focus' features/$*.feature
148149
@$(MAKE) focus-acceptance || true
150+
@#
151+
@# Remove @focus tag
149152
@sed -i '1d' features/$*.feature
153+
@#
154+
@# With UPDATE_SNAPS=true all the other snap files will be deleted. Let's put them back.
155+
@if [ -n "$$UPDATE_SNAPS" ]; then \
156+
git ls-files --deleted -- 'features/__snapshots__/*.snap' | xargs -r git checkout --; \
157+
fi
150158

151159
# (Replace spaces with underscores in the scenario name.)
152160
scenario_%: build ## Run acceptance tests for a single scenario, e.g. make scenario_inline_policy

docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ You can also specify a policy configuration using a git url, e.g.
2121

2222
+
2323
*Default*: `enterprise-contract-service/default`
24-
*PUBLIC_KEY* (`string`):: Public key used to verify signatures. Must be a valid k8s cosign reference, e.g. k8s://my-space/my-secret where my-secret contains the expected cosign.pub attribute.
24+
*PUBLIC_KEY* (`string`):: Public key used to verify traditional long-lived signatures. Must be a valid k8s cosign reference, e.g. k8s://my-space/my-secret where my-secret contains the expected cosign.pub attribute. Required for traditional signing key verification. Will be ignored if either of CERTIFICATE_IDENTITY or CERTIFICATE_OIDC_ISSUER are provided.
2525
*REKOR_HOST* (`string`):: Rekor host for transparency log lookups
26+
*CERTIFICATE_IDENTITY* (`string`):: Expected identity in the signing certificate for keyless verification. This should be the email or URI that was used when signing. You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
27+
*CERTIFICATE_OIDC_ISSUER* (`string`):: Expected OIDC issuer in the signing certificate for keyless verification. This should match the issuer that provided the identity token used for signing. You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
2628
*IGNORE_REKOR* (`string`):: Skip Rekor transparency log checks during validation.
2729
+
2830
*Default*: `false`

docs/modules/ROOT/pages/verify-enterprise-contract.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ You can also specify a policy configuration using a git url, e.g.
3232

3333
+
3434
*Default*: `enterprise-contract-service/default`
35-
*PUBLIC_KEY* (`string`):: Public key used to verify signatures. Must be a valid k8s cosign reference, e.g. k8s://my-space/my-secret where my-secret contains the expected cosign.pub attribute.
35+
*PUBLIC_KEY* (`string`):: Public key used to verify traditional long-lived signatures. Must be a valid k8s cosign reference, e.g. k8s://my-space/my-secret where my-secret contains the expected cosign.pub attribute. Required for traditional signing key verification. Will be ignored if either of CERTIFICATE_IDENTITY or CERTIFICATE_OIDC_ISSUER are provided.
3636
*REKOR_HOST* (`string`):: Rekor host for transparency log lookups
37-
*CERTIFICATE_IDENTITY* (`string`):: Expected identity in the signing certificate for keyless verification. This should be the email or URI that was used when signing.
38-
*CERTIFICATE_OIDC_ISSUER* (`string`):: Expected OIDC issuer in the signing certificate for keyless verification. This should match the issuer that provided the identity token used for signing.
37+
*CERTIFICATE_IDENTITY* (`string`):: Expected identity in the signing certificate for keyless verification. This should be the email or URI that was used when signing. You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
38+
*CERTIFICATE_OIDC_ISSUER* (`string`):: Expected OIDC issuer in the signing certificate for keyless verification. This should match the issuer that provided the identity token used for signing. You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
3939
*IGNORE_REKOR* (`string`):: Skip Rekor transparency log checks during validation.
4040
+
4141
*Default*: `false`

tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml

Lines changed: 118 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,37 @@ spec:
5252
- name: PUBLIC_KEY
5353
type: string
5454
description: >-
55-
Public key used to verify signatures. Must be a valid k8s cosign
56-
reference, e.g. k8s://my-space/my-secret where my-secret contains
57-
the expected cosign.pub attribute.
55+
Public key used to verify traditional long-lived signatures. Must be a
56+
valid k8s cosign reference, e.g. k8s://my-space/my-secret where
57+
my-secret contains the expected cosign.pub attribute. Required for
58+
traditional signing key verification. Will be ignored if either of
59+
CERTIFICATE_IDENTITY or CERTIFICATE_OIDC_ISSUER are provided.
5860
default: ""
5961

6062
- name: REKOR_HOST
6163
type: string
6264
description: Rekor host for transparency log lookups
6365
default: ""
6466

67+
- name: CERTIFICATE_IDENTITY
68+
type: string
69+
description: >-
70+
Expected identity in the signing certificate for keyless verification.
71+
This should be the email or URI that was used when signing.
72+
You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY
73+
for keyless verification. The PUBLIC_KEY param will be ignored if this is
74+
provided.
75+
default: ""
76+
77+
- name: CERTIFICATE_OIDC_ISSUER
78+
type: string
79+
description: >-
80+
Expected OIDC issuer in the signing certificate for keyless verification.
81+
This should match the issuer that provided the identity token used for signing.
82+
You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for
83+
keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
84+
default: ""
85+
6586
- name: IGNORE_REKOR
6687
type: string
6788
description: >-
@@ -288,83 +309,136 @@ spec:
288309
#!/bin/bash
289310
set -euo pipefail
290311
291-
# Build EC arguments array
292-
# POLICY_CONFIGURATION is passed via environment variable to safely handle JSON strings
293-
EC_ARGS=(
312+
cmd_args=(
294313
validate
295314
image
296-
--images /tekton/home/snapshot.json
297-
--policy "${POLICY_CONFIGURATION}"
298-
--public-key "$(params.PUBLIC_KEY)"
299-
--rekor-url "$(params.REKOR_HOST)"
300-
--ignore-rekor=$(params.IGNORE_REKOR)
301-
--workers "$(params.WORKERS)"
302-
--info=$(params.INFO)
303-
--timeout=100h
304-
--strict=false
305-
--show-successes
306-
--effective-time=$(params.EFFECTIVE_TIME)
307-
--extra-rule-data=$(params.EXTRA_RULE_DATA)
315+
--images="${HOMEDIR}/snapshot.json"
316+
--policy="${POLICY_CONFIGURATION}"
308317
)
309318
310-
EC_ARGS+=(
311-
--retry-max-wait "$(params.RETRY_MAX_WAIT)"
312-
--retry-max-retry "$(params.RETRY_MAX_RETRY)"
313-
--retry-duration "$(params.RETRY_DURATION)"
314-
--retry-factor "$(params.RETRY_FACTOR)"
315-
--retry-jitter "$(params.RETRY_JITTER)"
316-
--output "text=$(params.HOMEDIR)/text-report.txt?show-successes=false"
317-
--output "appstudio=$(results.TEST_OUTPUT.path)"
318-
--output "json=$(params.HOMEDIR)/report-json.json"
319+
# To keep bash logic as thin as possible we deliberately don't sanitize
320+
# these params. If something is wrong or missing let Conforma handle it.
321+
if [ -n "${CERTIFICATE_IDENTITY}" ] || [ -n "${CERTIFICATE_OIDC_ISSUER}" ]; then
322+
cmd_args+=(
323+
--certificate-identity="${CERTIFICATE_IDENTITY}"
324+
--certificate-oidc-issuer="${CERTIFICATE_OIDC_ISSUER}"
325+
)
326+
elif [ -n "${PUBLIC_KEY}" ]; then
327+
cmd_args+=(
328+
--public-key="${PUBLIC_KEY}"
329+
)
330+
fi
331+
332+
cmd_args+=(
333+
--rekor-url="${REKOR_HOST}"
334+
--ignore-rekor="${IGNORE_REKOR}"
335+
--workers="${WORKERS}"
336+
--info="${INFO}"
337+
--timeout=0
338+
--strict=false
339+
--show-successes=true
340+
--effective-time="${EFFECTIVE_TIME}"
341+
--extra-rule-data="${EXTRA_RULE_DATA}"
342+
--retry-max-wait="${RETRY_MAX_WAIT}"
343+
--retry-max-retry="${RETRY_MAX_RETRY}"
344+
--retry-duration="${RETRY_DURATION}"
345+
--retry-factor="${RETRY_FACTOR}"
346+
--retry-jitter="${RETRY_JITTER}"
347+
--output="text=${HOMEDIR}/text-report.txt?show-successes=false"
348+
--output="json=${HOMEDIR}/report-json.json"
349+
--output="appstudio=$(results.TEST_OUTPUT.path)"
319350
)
320351
321352
# Add VSA arguments if enabled
322-
if [[ "$(params.ENABLE_VSA)" == "true" ]]; then
323-
EC_ARGS+=(--vsa --attestation-format=$(params.ATTESTATION_FORMAT))
353+
if [[ "${ENABLE_VSA}" == "true" ]]; then
354+
cmd_args+=(
355+
--vsa="true"
356+
--attestation-format="${ATTESTATION_FORMAT}"
357+
)
324358
325-
# Extract local path from VSA_UPLOAD for output directory
326-
# VSA_UPLOAD format is "local@/path/to/dir"
327-
VSA_LOCAL_PATH=$(echo "$(params.VSA_UPLOAD)" | grep -oE '^local@[^ ]+' | sed 's/^local@//' | head -n1 || true)
328359
329-
if [[ "$(params.ATTESTATION_FORMAT)" == "dsse" ]]; then
330-
if [[ -z "$(params.VSA_SIGNING_KEY)" ]]; then
360+
if [[ "${ATTESTATION_FORMAT}" == "dsse" ]]; then
361+
if [[ -z "${VSA_SIGNING_KEY}" ]]; then
331362
echo "ERROR: VSA_SIGNING_KEY required for format=dsse" >&2
332363
exit 1
333364
fi
334-
EC_ARGS+=(--vsa-signing-key "$(params.VSA_SIGNING_KEY)")
335-
EC_ARGS+=(--vsa-upload "$(params.VSA_UPLOAD)")
365+
cmd_args+=(
366+
--vsa-signing-key="${VSA_SIGNING_KEY}"
367+
--vsa-upload="${VSA_UPLOAD}"
368+
)
336369
fi
337370
338371
# ec requires --attestation-output-dir to be under /tmp or cwd.
339372
# Write there first, then copy to the workdir so
340373
# create-trusted-artifact includes them in the archive.
341374
VSA_TMP_DIR="/tmp/vsa-output"
342375
mkdir -p "$VSA_TMP_DIR"
343-
EC_ARGS+=(--attestation-output-dir "$VSA_TMP_DIR")
376+
cmd_args+=(
377+
--attestation-output-dir="$VSA_TMP_DIR"
378+
)
344379
345380
echo -n "true" > $(results.VSA_GENERATED.path)
346381
else
347382
echo -n "false" > $(results.VSA_GENERATED.path)
348383
fi
349384
350-
# Execute EC with constructed arguments
351-
ec "${EC_ARGS[@]}"
385+
# Execute Conforma with constructed arguments
386+
ec "${cmd_args[@]}"
352387
353388
# Copy VSA output from /tmp to workdir for trusted artifact archival
354-
if [[ "$(params.ENABLE_VSA)" == "true" ]]; then
355-
VSA_LOCAL_PATH=$(echo "$(params.VSA_UPLOAD)" | grep -oE '^local@[^ ]+' | sed 's/^local@//' | head -n1 || true)
389+
if [[ "${ENABLE_VSA}" == "true" ]]; then
390+
# Extract local path from VSA_UPLOAD for output directory
391+
# VSA_UPLOAD format is "local@/path/to/dir"
392+
# Fixme: Because of -o pipefail this will fail the whole task when the grep doesn't match
393+
VSA_LOCAL_PATH=$(echo "${VSA_UPLOAD}" | grep -oE '^local@[^ ]+' | sed 's/^local@//' | head -n1 || true)
356394
if [[ -n "$VSA_LOCAL_PATH" && -d "/tmp/vsa-output" ]]; then
357395
mkdir -p "$VSA_LOCAL_PATH"
358396
cp -r /tmp/vsa-output/* "$VSA_LOCAL_PATH"/ 2>/dev/null || true
359397
# Include raw JSON report for downstream SLSA VSA generation
360-
cp "$(params.HOMEDIR)/report-json.json" "$VSA_LOCAL_PATH"/ 2>/dev/null || true
398+
cp "${HOMEDIR}/report-json.json" "$VSA_LOCAL_PATH"/ 2>/dev/null || true
361399
fi
362400
fi
363401
env:
364-
# POLICY_CONFIGURATION is passed via environment variable to safely handle JSON strings
365-
# This avoids shell quoting issues when Tekton substitutes parameter values directly in scripts
366402
- name: POLICY_CONFIGURATION
367403
value: "$(params.POLICY_CONFIGURATION)"
404+
- name: PUBLIC_KEY
405+
value: "$(params.PUBLIC_KEY)"
406+
- name: CERTIFICATE_IDENTITY
407+
value: "$(params.CERTIFICATE_IDENTITY)"
408+
- name: CERTIFICATE_OIDC_ISSUER
409+
value: "$(params.CERTIFICATE_OIDC_ISSUER)"
410+
- name: REKOR_HOST
411+
value: "$(params.REKOR_HOST)"
412+
- name: IGNORE_REKOR
413+
value: "$(params.IGNORE_REKOR)"
414+
- name: WORKERS
415+
value: "$(params.WORKERS)"
416+
- name: INFO
417+
value: "$(params.INFO)"
418+
- name: EFFECTIVE_TIME
419+
value: "$(params.EFFECTIVE_TIME)"
420+
- name: EXTRA_RULE_DATA
421+
value: "$(params.EXTRA_RULE_DATA)"
422+
- name: RETRY_MAX_WAIT
423+
value: "$(params.RETRY_MAX_WAIT)"
424+
- name: RETRY_MAX_RETRY
425+
value: "$(params.RETRY_MAX_RETRY)"
426+
- name: RETRY_DURATION
427+
value: "$(params.RETRY_DURATION)"
428+
- name: RETRY_FACTOR
429+
value: "$(params.RETRY_FACTOR)"
430+
- name: RETRY_JITTER
431+
value: "$(params.RETRY_JITTER)"
432+
- name: ENABLE_VSA
433+
value: "$(params.ENABLE_VSA)"
434+
- name: ATTESTATION_FORMAT
435+
value: "$(params.ATTESTATION_FORMAT)"
436+
- name: VSA_SIGNING_KEY
437+
value: "$(params.VSA_SIGNING_KEY)"
438+
- name: VSA_UPLOAD
439+
value: "$(params.VSA_UPLOAD)"
440+
- name: HOMEDIR
441+
value: "$(params.HOMEDIR)"
368442
- name: SSL_CERT_DIR
369443
# The Tekton Operator automatically sets the SSL_CERT_DIR env to the value below but,
370444
# of course, without the $(param.SSL_CERT_DIR) bit. When a Task Step sets it to a

tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ spec:
5959
- name: PUBLIC_KEY
6060
type: string
6161
description: >-
62-
Public key used to verify signatures. Must be a valid k8s cosign
63-
reference, e.g. k8s://my-space/my-secret where my-secret contains
64-
the expected cosign.pub attribute.
62+
Public key used to verify traditional long-lived signatures. Must be a
63+
valid k8s cosign reference, e.g. k8s://my-space/my-secret where
64+
my-secret contains the expected cosign.pub attribute. Required for
65+
traditional signing key verification. Will be ignored if either of
66+
CERTIFICATE_IDENTITY or CERTIFICATE_OIDC_ISSUER are provided.
6567
default: ""
6668

6769
- name: REKOR_HOST
@@ -74,13 +76,18 @@ spec:
7476
description: >-
7577
Expected identity in the signing certificate for keyless verification.
7678
This should be the email or URI that was used when signing.
79+
You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY
80+
for keyless verification. The PUBLIC_KEY param will be ignored if this is
81+
provided.
7782
default: ""
7883

7984
- name: CERTIFICATE_OIDC_ISSUER
8085
type: string
8186
description: >-
8287
Expected OIDC issuer in the signing certificate for keyless verification.
8388
This should match the issuer that provided the identity token used for signing.
89+
You should provide both CERTIFICATE_OIDC_ISSUER and CERTIFICATE_IDENTITY for
90+
keyless verification. The PUBLIC_KEY param will be ignored if this is provided.
8491
default: ""
8592

8693
- name: IGNORE_REKOR
@@ -255,50 +262,47 @@ spec:
255262
set -euo pipefail
256263
257264
cmd_args=(
258-
"validate"
259-
"image"
260-
"--images" "/tekton/home/snapshot.json"
261-
"--policy" "${POLICY_CONFIGURATION}"
265+
validate
266+
image
267+
--images="${HOMEDIR}/snapshot.json"
268+
--policy="${POLICY_CONFIGURATION}"
262269
)
263270
264271
# To keep bash logic as thin as possible we deliberately don't sanitize
265272
# these params. If something is wrong or missing let Conforma handle it.
266-
if [ -n "${CERTIFICATE_IDENTITY}" ] && [ -n "${CERTIFICATE_OIDC_ISSUER}" ]; then
273+
if [ -n "${CERTIFICATE_IDENTITY}" ] || [ -n "${CERTIFICATE_OIDC_ISSUER}" ]; then
267274
cmd_args+=(
268-
"--certificate-identity" "${CERTIFICATE_IDENTITY}"
269-
"--certificate-oidc-issuer" "${CERTIFICATE_OIDC_ISSUER}"
275+
--certificate-identity="${CERTIFICATE_IDENTITY}"
276+
--certificate-oidc-issuer="${CERTIFICATE_OIDC_ISSUER}"
270277
)
271278
elif [ -n "${PUBLIC_KEY}" ]; then
272279
cmd_args+=(
273-
"--public-key" "${PUBLIC_KEY}"
280+
--public-key="${PUBLIC_KEY}"
274281
)
275282
fi
276283
277284
cmd_args+=(
278-
"--rekor-url" "${REKOR_HOST}"
279-
"--ignore-rekor=${IGNORE_REKOR}"
280-
"--workers" "${WORKERS}"
281-
# NOTE: The syntax below is required to negate boolean parameters
282-
"--info=${INFO}"
283-
# Fresh versions of ec support "--timeout=0" to indicate no timeout, but this would break
284-
# the task if it's used with an older version of ec. In an abundance of caution, let's set
285-
# an arbitrary high value instead of using 0 here. In future we can change it to 0.
286-
# (The reason to not use an explicit timeout for ec is so Tekton can handle the timeouts).
287-
"--timeout=100h"
288-
"--strict=false"
289-
"--show-successes"
290-
"--effective-time=${EFFECTIVE_TIME}"
291-
"--extra-rule-data=${EXTRA_RULE_DATA}"
292-
"--retry-max-wait" "${RETRY_MAX_WAIT}"
293-
"--retry-max-retry" "${RETRY_MAX_RETRY}"
294-
"--retry-duration" "${RETRY_DURATION}"
295-
"--retry-factor" "${RETRY_FACTOR}"
296-
"--retry-jitter" "${RETRY_JITTER}"
297-
"--output" "text=${HOMEDIR}/text-report.txt?show-successes=false"
298-
"--output" "appstudio=$(results.TEST_OUTPUT.path)"
299-
"--output" "json=${HOMEDIR}/report-json.json"
285+
--rekor-url="${REKOR_HOST}"
286+
--ignore-rekor="${IGNORE_REKOR}"
287+
--workers="${WORKERS}"
288+
--info="${INFO}"
289+
--timeout=0
290+
--strict=false
291+
--show-successes=true
292+
--effective-time="${EFFECTIVE_TIME}"
293+
--extra-rule-data="${EXTRA_RULE_DATA}"
294+
--retry-max-wait="${RETRY_MAX_WAIT}"
295+
--retry-max-retry="${RETRY_MAX_RETRY}"
296+
--retry-duration="${RETRY_DURATION}"
297+
--retry-factor="${RETRY_FACTOR}"
298+
--retry-jitter="${RETRY_JITTER}"
299+
--output="text=${HOMEDIR}/text-report.txt?show-successes=false"
300+
--output="json=${HOMEDIR}/report-json.json"
301+
--output="appstudio=$(results.TEST_OUTPUT.path)"
300302
)
301303
304+
305+
# Execute Conforma with constructed arguments
302306
exec ec "${cmd_args[@]}"
303307
env:
304308
- name: POLICY_CONFIGURATION

0 commit comments

Comments
 (0)