Skip to content

Commit a5dc8e7

Browse files
committed
sigstore: opt to verify attestation manifest for specific platform
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent c9ffda6 commit a5dc8e7

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

__tests__/sigstore/sigstore.test.itg.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {Build} from '../../src/buildx/build';
2323
import {Install as CosignInstall} from '../../src/cosign/install';
2424
import {Docker} from '../../src/docker/docker';
2525
import {Exec} from '../../src/exec';
26+
import {OCI} from '../../src/oci/oci';
2627
import {Sigstore} from '../../src/sigstore/sigstore';
2728

2829
const fixturesDir = path.join(__dirname, '..', '.fixtures');
@@ -114,6 +115,20 @@ maybe('verifyImageAttestations', () => {
114115
},
115116
60000
116117
);
118+
119+
it('default platform', async () => {
120+
const sigstore = new Sigstore();
121+
const verifyResults = await sigstore.verifyImageAttestations('moby/buildkit:master@sha256:84014da3581b2ff2c14cb4f60029cf9caa272b79e58f2e89c651ea6966d7a505', {
122+
certificateIdentityRegexp: `^https://github.com/docker/github-builder-experimental/.github/workflows/bake.yml.*$`,
123+
platform: OCI.defaultPlatform()
124+
});
125+
expect(Object.keys(verifyResults).length).toEqual(1);
126+
for (const [attestationRef, res] of Object.entries(verifyResults)) {
127+
expect(attestationRef).toBeDefined();
128+
expect(res.cosignArgs).toBeDefined();
129+
expect(res.signatureManifestDigest).toBeDefined();
130+
}
131+
});
117132
});
118133

119134
maybeIdToken('signProvenanceBlobs', () => {

src/sigstore/sigstore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ export class Sigstore {
133133
for (const [attestationRef, signedRes] of Object.entries(signedManifestsResult)) {
134134
await core.group(`Verifying signature of ${attestationRef}`, async () => {
135135
const verifyResult = await this.verifyImageAttestation(attestationRef, {
136-
noTransparencyLog: opts.noTransparencyLog || !signedRes.tlogID,
137136
certificateIdentityRegexp: opts.certificateIdentityRegexp,
137+
noTransparencyLog: opts.noTransparencyLog || !signedRes.tlogID,
138138
retryOnManifestUnknown: opts.retryOnManifestUnknown
139139
});
140140
core.info(`Signature manifest verified: https://oci.dag.dev/?image=${signedRes.imageName}@${verifyResult.signatureManifestDigest}`);
@@ -147,7 +147,7 @@ export class Sigstore {
147147
public async verifyImageAttestations(image: string, opts: VerifySignedManifestsOpts): Promise<Record<string, VerifySignedManifestsResult>> {
148148
const result: Record<string, VerifySignedManifestsResult> = {};
149149

150-
const attestationDigests = await this.imageTools.attestationDigests(image);
150+
const attestationDigests = await this.imageTools.attestationDigests(image, opts.platform);
151151
if (attestationDigests.length === 0) {
152152
throw new Error(`No attestation manifests found for ${image}`);
153153
}

src/types/sigstore/sigstore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import type {SerializedBundle} from '@sigstore/bundle';
1818

1919
import {Subject} from '../intoto/intoto';
20+
import {Platform} from '../oci/descriptor';
2021

2122
export const FULCIO_URL = 'https://fulcio.sigstore.dev';
2223
export const REKOR_URL = 'https://rekor.sigstore.dev';
@@ -47,6 +48,7 @@ export interface SignAttestationManifestsResult extends ParsedBundle {
4748

4849
export interface VerifySignedManifestsOpts {
4950
certificateIdentityRegexp: string;
51+
platform?: Platform;
5052
noTransparencyLog?: boolean;
5153
retryOnManifestUnknown?: boolean;
5254
}

0 commit comments

Comments
 (0)