Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix handling of verify-attestation types for URIs #2159

Merged
merged 3 commits into from Aug 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions pkg/policy/attestation.go
Expand Up @@ -39,8 +39,9 @@ import (
// match the attestation.
func AttestationToPayloadJSON(ctx context.Context, predicateType string, verifiedAttestation oci.Signature) ([]byte, error) {
// Check the predicate up front, no point in wasting time if it's invalid.
predicateURI, ok := options.PredicateTypeMap[predicateType]
if !ok {
predicateURI, err := options.ParsePredicateType(predicateType)

if err != nil {
return nil, fmt.Errorf("invalid predicate type: %s", predicateType)
}

Expand Down Expand Up @@ -132,7 +133,11 @@ func AttestationToPayloadJSON(ctx context.Context, predicateType string, verifie
return nil, fmt.Errorf("marshaling CosignVulnStatement: %w", err)
}
default:
return nil, fmt.Errorf("unsupported predicate type: %s", predicateType)
// Valid URI type reaches here.
payload, err = json.Marshal(statement)
if err != nil {
return nil, fmt.Errorf("generating Statement: %w", err)
}
}
return payload, nil
}