MCPcopy Create free account
hub / github.com/cli/cli / Verify

Method Verify

pkg/cmd/attestation/verification/sigstore.go:278–309  ·  view source on GitHub ↗
(attestations []*api.Attestation, policy verify.PolicyBuilder)

Source from the content-addressed store, hash-verified

276}
277
278func (v *LiveSigstoreVerifier) Verify(attestations []*api.Attestation, policy verify.PolicyBuilder) ([]*AttestationProcessingResult, error) {
279 if len(attestations) == 0 {
280 return nil, ErrNoAttestationsVerified
281 }
282
283 results := make([]*AttestationProcessingResult, len(attestations))
284 var verifyCount int
285 var lastError error
286 totalAttestations := len(attestations)
287 for i, a := range attestations {
288 v.Logger.VerbosePrintf("Verifying attestation %d/%d against the configured Sigstore trust roots\n", i+1, totalAttestations)
289
290 apr, err := v.verify(a, policy)
291 if err != nil {
292 lastError = err
293 // move onto the next attestation in the for loop if verification fails
294 continue
295 }
296 // otherwise, add the result to the results slice and increment verifyCount
297 results[verifyCount] = apr
298 verifyCount++
299 }
300
301 if verifyCount == 0 {
302 return nil, lastError
303 }
304
305 // truncate the results slice to only include verified attestations
306 results = results[:verifyCount]
307
308 return results, nil
309}
310
311func newCustomVerifier(trustedRoot *root.TrustedRoot) (*verify.Verifier, error) {
312 // All we know about this trust root is its configuration so make some

Callers 2

VerifyAttestationMethod · 0.95
TestLiveSigstoreVerifierFunction · 0.95

Calls 2

verifyMethod · 0.95
VerbosePrintfMethod · 0.80

Tested by 1

TestLiveSigstoreVerifierFunction · 0.76