@@ -162,6 +162,93 @@ jobs:
162162 with :
163163 script : |
164164 await exec.exec('npm', ['install', '--prefer-offline', '--ignore-scripts', core.getInput('dat-module')]);
165+ -
166+ name : Install Cosign
167+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
168+ env :
169+ INPUT_COSIGN-VERSION : ${{ env.COSIGN_VERSION }}
170+ with :
171+ script : |
172+ const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign');
173+ const { Install } = require('@docker/actions-toolkit/lib/cosign/install');
174+
175+ const inpCosignVersion = core.getInput('cosign-version');
176+
177+ const cosignInstall = new Install();
178+ const cosignBinPath = await cosignInstall.download({
179+ version: core.getInput('cosign-version'),
180+ ghaNoCache: true,
181+ skipState: true,
182+ verifySignature: true
183+ });
184+ const cosignPath = await cosignInstall.install(cosignBinPath);
185+
186+ const cosign = new Cosign();
187+ await cosign.printVersion();
188+ -
189+ name : Set up Docker Buildx
190+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
191+ with :
192+ version : ${{ env.BUILDX_VERSION }}
193+ cache-binary : false
194+ buildkitd-flags : --debug
195+ -
196+ name : Check dependencies signatures
197+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
198+ env :
199+ INPUT_IMAGES : |
200+ ${{ env.BUILDKIT_IMAGE }}
201+ ${{ env.SBOM_IMAGE }}
202+ ${{ env.BINFMT_IMAGE }}
203+ with :
204+ script : |
205+ const { ImageTools } = require('@docker/actions-toolkit/lib/buildx/imagetools');
206+ const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign');
207+
208+ const inpImages = core.getMultilineInput('images');
209+ const imageTools = new ImageTools();
210+
211+ for (const image of inpImages) {
212+ await core.group(`Verifying ${image}`, async () => {
213+ const attestationDigests = await imageTools.attestationDigests(image);
214+ if (attestationDigests.length === 0) {
215+ core.setFailed(`No attestation manifests found for ${image}`);
216+ return;
217+ }
218+ const imageName = image.split(':', 1)[0];
219+ for (const attestationDigest of attestationDigests) {
220+ const attestationRef = `${imageName}@${attestationDigest}`;
221+ const cosignArgs = [
222+ 'verify',
223+ '--experimental-oci11',
224+ '--new-bundle-format',
225+ '--certificate-oidc-issuer', 'https://token.actions.githubusercontent.com',
226+ '--certificate-identity-regexp', `^https://github.com/docker/github-builder-experimental/.github/workflows/build.yml.*$`
227+ ];
228+ core.info(`[command]cosign ${[...cosignArgs, attestationRef].join(' ')}`);
229+ const execRes = await exec.getExecOutput('cosign', ['--verbose', ...cosignArgs, attestationRef], {
230+ ignoreReturnCode: true,
231+ silent: true,
232+ env: Object.assign({}, process.env, {
233+ COSIGN_EXPERIMENTAL: '1'
234+ })
235+ });
236+ const verifyResult = Cosign.parseCommandOutput(execRes.stderr.trim());
237+ if (execRes.exitCode === 0) {
238+ core.info(`Signature manifest verified: https://oci.dag.dev/?image=${signedRes.imageName}@${verifyResult.signatureManifestDigest}`);
239+ } else {
240+ if (verifyResult.errors && verifyResult.errors.length > 0) {
241+ const errorMessages = verifyResult.errors.map(e => `- [${e.code}] ${e.message} : ${e.detail}`).join('\n');
242+ core.setFailed(`Cosign verify command failed with errors:\n${errorMessages}`);
243+ return;
244+ } else {
245+ core.setFailed(`Cosign verify command failed: ${execRes.stderr}`);
246+ return;
247+ }
248+ }
249+ }
250+ });
251+ }
165252 -
166253 name : Expose GitHub Runtime
167254 uses : crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
0 commit comments