@@ -135,7 +135,7 @@ export class Sigstore {
135135 const verifyResult = await this . verifyImageAttestation ( attestationRef , {
136136 noTransparencyLog : opts . noTransparencyLog || ! signedRes . tlogID ,
137137 certificateIdentityRegexp : opts . certificateIdentityRegexp ,
138- retries : opts . retries
138+ retryOnManifestUnknown : opts . retryOnManifestUnknown
139139 } ) ;
140140 core . info ( `Signature manifest verified: https://oci.dag.dev/?image=${ signedRes . imageName } @${ verifyResult . signatureManifestDigest } ` ) ;
141141 result [ attestationRef ] = verifyResult ;
@@ -164,8 +164,6 @@ export class Sigstore {
164164 }
165165
166166 public async verifyImageAttestation ( attestationRef : string , opts : VerifySignedManifestsOpts ) : Promise < VerifySignedManifestsResult > {
167- const retries = opts . retries ?? 15 ;
168-
169167 if ( ! ( await this . cosign . isAvailable ( ) ) ) {
170168 throw new Error ( 'Cosign is required to verify signed manifests' ) ;
171169 }
@@ -183,6 +181,27 @@ export class Sigstore {
183181 cosignArgs . push ( '--use-signed-timestamps' , '--insecure-ignore-tlog' ) ;
184182 }
185183
184+ if ( ! opts . retryOnManifestUnknown ) {
185+ core . info ( `[command]cosign ${ [ ...cosignArgs , attestationRef ] . join ( ' ' ) } ` ) ;
186+ const execRes = await Exec . getExecOutput ( 'cosign' , [ '--verbose' , ...cosignArgs , attestationRef ] , {
187+ ignoreReturnCode : true ,
188+ silent : true ,
189+ env : Object . assign ( { } , process . env , {
190+ COSIGN_EXPERIMENTAL : '1'
191+ } ) as { [ key : string ] : string }
192+ } ) ;
193+ if ( execRes . exitCode !== 0 ) {
194+ // prettier-ignore
195+ throw new Error ( `Cosign verify command failed with: ${ execRes . stderr . trim ( ) . split ( / \r ? \n / ) . filter ( line => line . length > 0 ) . pop ( ) ?? 'unknown error' } ` ) ;
196+ }
197+ const verifyResult = Cosign . parseCommandOutput ( execRes . stderr . trim ( ) ) ;
198+ return {
199+ cosignArgs : cosignArgs ,
200+ signatureManifestDigest : verifyResult . signatureManifestDigest !
201+ } ;
202+ }
203+
204+ const retries = 15 ;
186205 let lastError : Error | undefined ;
187206 core . info ( `[command]cosign ${ [ ...cosignArgs , attestationRef ] . join ( ' ' ) } ` ) ;
188207 for ( let attempt = 0 ; attempt < retries ; attempt ++ ) {
0 commit comments