Skip to content

Commit

Permalink
attestation: validate attestations before unbundling as well
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Dec 16, 2022
1 parent 3fab94f commit 24807f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion exporter/attestation/unbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
// Unbundle iterates over all provided result attestations and un-bundles any
// bundled attestations by loading them from the provided refs map.
func Unbundle(ctx context.Context, s session.Group, bundled []exporter.Attestation) ([]exporter.Attestation, error) {
if err := Validate(bundled); err != nil {
return nil, err
}

eg, ctx := errgroup.WithContext(ctx)
unbundled := make([][]exporter.Attestation, len(bundled))

Expand Down Expand Up @@ -138,7 +142,7 @@ func Validate(atts []exporter.Attestation) error {
}

func validate(att exporter.Attestation) error {
if att.Path == "" {
if att.Kind != gatewaypb.AttestationKindBundle && att.Path == "" {
return errors.New("attestation does not have set path")
}
if att.Ref == nil && att.ContentFunc == nil {
Expand Down

0 comments on commit 24807f5

Please sign in to comment.