@@ -34,7 +34,7 @@ import {MEDIATYPE_PAYLOAD as INTOTO_MEDIATYPE_PAYLOAD, Subject} from '../types/i |
34 | 34 | import {FULCIO_URL, REKOR_URL, SEARCH_URL, TSASERVER_URL} from '../types/sigstore/sigstore'; |
35 | 35 |
|
36 | 36 | export interface SignAttestationManifestsOpts { |
37 | | - imageName: string; |
| 37 | + imageNames: Array<string>; |
38 | 38 | imageDigest: string; |
39 | 39 | noTransparencyLog?: boolean; |
40 | 40 | } |
@@ -101,12 +101,13 @@ export class Sigstore { |
101 | 101 | core.info(`Using Sigstore signing endpoint: ${endpoints.fulcioURL}`); |
102 | 102 | const noTransparencyLog = Sigstore.noTransparencyLog(opts.noTransparencyLog); |
103 | 103 |
|
104 | | - const attestationDigests = await this.imageTools.attestationDigests(`${opts.imageName}@${opts.imageDigest}`); |
105 | | - for (const attestationDigest of attestationDigests) { |
106 | | - const attestationRef = `${opts.imageName}@${attestationDigest}`; |
107 | | - await core.group(`Signing attestation manifest ${attestationRef}`, async () => { |
108 | | - // prettier-ignore |
109 | | - const cosignArgs = [ |
| 104 | + for (const imageName of opts.imageNames) { |
| 105 | + const attestationDigests = await this.imageTools.attestationDigests(`${imageName}@${opts.imageDigest}`); |
| 106 | + for (const attestationDigest of attestationDigests) { |
| 107 | + const attestationRef = `${imageName}@${attestationDigest}`; |
| 108 | + await core.group(`Signing attestation manifest ${attestationRef}`, async () => { |
| 109 | + // prettier-ignore |
| 110 | + const cosignArgs = [ |
110 | 111 | '--verbose', |
111 | 112 | 'sign', |
112 | 113 | '--yes', |
@@ -115,38 +116,39 @@ export class Sigstore { |
115 | 116 | '--new-bundle-format', |
116 | 117 | '--use-signing-config' |
117 | 118 | ]; |
118 | | - if (noTransparencyLog) { |
119 | | - cosignArgs.push('--tlog-upload=false'); |
120 | | - } |
121 | | - core.info(`[command]cosign ${[...cosignArgs, attestationRef].join(' ')}`); |
122 | | - const execRes = await Exec.getExecOutput('cosign', [...cosignArgs, attestationRef], { |
123 | | - ignoreReturnCode: true, |
124 | | - silent: true, |
125 | | - env: Object.assign({}, process.env, { |
126 | | - COSIGN_EXPERIMENTAL: '1' |
127 | | - }) as { |
128 | | - [key: string]: string; |
| 119 | + if (noTransparencyLog) { |
| 120 | + cosignArgs.push('--tlog-upload=false'); |
129 | 121 | } |
130 | | - }); |
131 | | - const signResult = Cosign.parseCommandOutput(execRes.stderr.trim()); |
132 | | - if (execRes.exitCode != 0) { |
133 | | - if (signResult.errors && signResult.errors.length > 0) { |
134 | | - const errorMessages = signResult.errors.map(e => `- [${e.code}] ${e.message} : ${e.detail}`).join('\n'); |
135 | | - throw new Error(`Cosign sign command failed with errors:\n${errorMessages}`); |
136 | | - } else { |
137 | | - throw new Error(`Cosign sign command failed with exit code ${execRes.exitCode}`); |
| 122 | + core.info(`[command]cosign ${[...cosignArgs, attestationRef].join(' ')}`); |
| 123 | + const execRes = await Exec.getExecOutput('cosign', [...cosignArgs, attestationRef], { |
| 124 | + ignoreReturnCode: true, |
| 125 | + silent: true, |
| 126 | + env: Object.assign({}, process.env, { |
| 127 | + COSIGN_EXPERIMENTAL: '1' |
| 128 | + }) as { |
| 129 | + [key: string]: string; |
| 130 | + } |
| 131 | + }); |
| 132 | + const signResult = Cosign.parseCommandOutput(execRes.stderr.trim()); |
| 133 | + if (execRes.exitCode != 0) { |
| 134 | + if (signResult.errors && signResult.errors.length > 0) { |
| 135 | + const errorMessages = signResult.errors.map(e => `- [${e.code}] ${e.message} : ${e.detail}`).join('\n'); |
| 136 | + throw new Error(`Cosign sign command failed with errors:\n${errorMessages}`); |
| 137 | + } else { |
| 138 | + throw new Error(`Cosign sign command failed with exit code ${execRes.exitCode}`); |
| 139 | + } |
138 | 140 | } |
139 | | - } |
140 | | - const attest = Sigstore.toAttestation(bundleFromJSON(signResult.bundle)); |
141 | | - if (attest.tlogID) { |
142 | | - core.info(`Uploaded to Rekor transparency log: ${SEARCH_URL}?logIndex=${attest.tlogID}`); |
143 | | - } |
144 | | - core.info(`Signature manifest pushed: https://oci.dag.dev/?referrers=${attestationRef}`); |
145 | | - result[attestationRef] = { |
146 | | - ...attest, |
147 | | - imageName: opts.imageName |
148 | | - }; |
149 | | - }); |
| 141 | + const attest = Sigstore.toAttestation(bundleFromJSON(signResult.bundle)); |
| 142 | + if (attest.tlogID) { |
| 143 | + core.info(`Uploaded to Rekor transparency log: ${SEARCH_URL}?logIndex=${attest.tlogID}`); |
| 144 | + } |
| 145 | + core.info(`Signature manifest pushed: https://oci.dag.dev/?referrers=${attestationRef}`); |
| 146 | + result[attestationRef] = { |
| 147 | + ...attest, |
| 148 | + imageName: imageName |
| 149 | + }; |
| 150 | + }); |
| 151 | + } |
150 | 152 | } |
151 | 153 | } catch (err) { |
152 | 154 | throw new Error(`Signing BuildKit attestation manifests failed: ${(err as Error).message}`); |
|