From 83519e4e9258fb1732e66f2c001ebce7bb4106be Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Tue, 10 Sep 2024 07:54:45 -0600 Subject: [PATCH] check for sigstore-go validation errs Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/verification/attestation.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/attestation/verification/attestation.go b/pkg/cmd/attestation/verification/attestation.go index d6e7d9e15..14936e9f1 100644 --- a/pkg/cmd/attestation/verification/attestation.go +++ b/pkg/cmd/attestation/verification/attestation.go @@ -94,12 +94,15 @@ func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) { decoder := json.NewDecoder(bytes.NewReader(fileContent)) for decoder.More() { - var bundle bundle.Bundle - bundle.Bundle = new(protobundle.Bundle) - if err := decoder.Decode(&bundle); err != nil { - return nil, fmt.Errorf("failed to unmarshal bundle from JSON: %v", err) + var b bundle.Bundle + b.Bundle = new(protobundle.Bundle) + if err := decoder.Decode(&b); err != nil { + if errors.Is(err, bundle.ErrValidation) { + return nil, err + } + return nil, fmt.Errorf("failed to unmarshal bundle from JSON") } - a := api.Attestation{Bundle: &bundle} + a := api.Attestation{Bundle: &b} attestations = append(attestations, &a) }