Debian Codegraph @

launcher/image/test/test_discover_signatures.yaml

raw
1 substitutions:
2 '_IMAGE_NAME': ''
3 '_IMAGE_PROJECT': ''
4 '_CLEANUP': 'true'
5 '_VM_NAME_PREFIX': 'discover-signatures'
6 '_ZONE': 'us-west1-a'
7 '_WORKLOAD_IMAGE': 'us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/basic-test:latest'
8 '_SIGNATURE_REPO': 'us-docker.pkg.dev/confidential-space-images-dev/cs-cosign-tests/hardened'
9
10 steps:
11 - name: 'gcr.io/projectsigstore/cosign:v2.2.0'
12 id: SignContainer
13 entrypoint: 'sh'
14 env:
15 - 'BUILD_ID=$BUILD_ID'
16 args:
17 - -c
18 - |
19 # Unpadded base64 encoding on the CloudKMS public key
20 pub=$(cosign public-key --key gcpkms://projects/confidential-space-images-dev/locations/global/keyRings/cosign-test/cryptoKeys/ecdsa/cryptoKeyVersions/1 | openssl base64)
21 pub=$(echo $pub | tr -d '[:space:]' | sed 's/[=]*$//')
22 # Use cosign sign
23 export COSIGN_REPOSITORY=${_SIGNATURE_REPO}
24 cosign sign --key gcpkms://projects/confidential-space-images-dev/locations/global/keyRings/cosign-test/cryptoKeys/ecdsa/cryptoKeyVersions/1 ${_WORKLOAD_IMAGE} -a dev.cosignproject.cosign/sigalg=ECDSA_P256_SHA256 -a dev.cosignproject.cosign/pub=$pub
25 - name: 'gcr.io/cloud-builders/gcloud'
26 id: CreateVM
27 entrypoint: 'bash'
28 env:
29 - 'BUILD_ID=$BUILD_ID'
30 args: ['create_vm.sh','-i', '${_IMAGE_NAME}',
31 '-p', '${_IMAGE_PROJECT}',
32 '-m', 'tee-image-reference=${_WORKLOAD_IMAGE},tee-container-log-redirect=true,tee-signed-image-repos=${_SIGNATURE_REPO},tee-env-ALLOWED_OVERRIDE=overridden,tee-cmd=["newCmd"]',
33 '-n', '${_VM_NAME_PREFIX}-${BUILD_ID}',
34 '-z', '${_ZONE}',
35 ]
36 - name: 'gcr.io/cloud-builders/gcloud'
37 id: BasicDiscoverSignaturesTest
38 entrypoint: 'bash'
39 args: ['scripts/test_launcher_workload_discover_signatures.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}', 'Found container image signatures', '1']
40 - name: 'gcr.io/cloud-builders/gcloud'
41 id: CleanUp
42 entrypoint: 'bash'
43 env:
44 - 'CLEANUP=$_CLEANUP'
45 args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}']
46 - name: 'gcr.io/cloud-builders/gcloud'
47 id: DeleteContainerSignatures
48 env:
49 - 'BUILD_ID=$BUILD_ID'
50 entrypoint: 'bash'
51 args:
52 - -c
53 - |
54 echo "Deleting container signatures..."
55 digest=$(gcloud artifacts docker images describe ${_WORKLOAD_IMAGE} --format 'value(image_summary.digest)')
56 tag=${digest/":"/"-"}.sig
57 # Delete container signature by its tag
58 gcloud artifacts docker images delete -q ${_SIGNATURE_REPO}:${tag}
59 # Must come after cleanup.
60 - name: 'gcr.io/cloud-builders/gcloud'
61 id: CheckFailure
62 entrypoint: 'bash'
63 env:
64 - 'BUILD_ID=$BUILD_ID'
65 args: ['check_failure.sh']
66
67 options:
68 pool:
69 name: 'projects/confidential-space-images-dev/locations/us-west1/workerPools/cs-image-build-vpc'