| 276 | } |
| 277 | |
| 278 | func (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 | |
| 311 | func newCustomVerifier(trustedRoot *root.TrustedRoot) (*verify.Verifier, error) { |
| 312 | // All we know about this trust root is its configuration so make some |