From 3814e82f9b858daa7bf35449a68060241487c0aa Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Tue, 10 Sep 2024 10:32:46 -0600 Subject: [PATCH] check err in GetLocalAttestations Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/verification/attestation.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/attestation/verification/attestation.go b/pkg/cmd/attestation/verification/attestation.go index 14936e9f1..50542a6b3 100644 --- a/pkg/cmd/attestation/verification/attestation.go +++ b/pkg/cmd/attestation/verification/attestation.go @@ -56,6 +56,8 @@ func GetLocalAttestations(path string) ([]*api.Attestation, error) { var pathErr *os.PathError if errors.As(err, &pathErr) { return nil, fmt.Errorf("bundle could not be loaded from JSON file at %s", path) + } else if errors.Is(err, bundle.ErrValidation) { + return nil, err } return nil, fmt.Errorf("bundle content could not be parsed") } @@ -66,6 +68,8 @@ func GetLocalAttestations(path string) ([]*api.Attestation, error) { var pathErr *os.PathError if errors.As(err, &pathErr) { return nil, fmt.Errorf("bundles could not be loaded from JSON lines file at %s", path) + } else if errors.Is(err, bundle.ErrValidation) { + return nil, err } return nil, fmt.Errorf("bundle content could not be parsed") } @@ -97,10 +101,7 @@ func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) { 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") + return nil, err } a := api.Attestation{Bundle: &b} attestations = append(attestations, &a)