Skip to content

Commit

Permalink
fix: properly handle sharded uuids returned from rekor (slsa-framewor…
Browse files Browse the repository at this point in the history
…k#141)

Signed-off-by: Asra Ali <[email protected]>

Co-authored-by: laurentsimon <[email protected]>
  • Loading branch information
asraa and laurentsimon authored Jul 11, 2022
1 parent f76196e commit 4dc20c2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/sigstore/rekor/pkg/generated/client/index"
"github.com/sigstore/rekor/pkg/generated/client/tlog"
"github.com/sigstore/rekor/pkg/generated/models"
"github.com/sigstore/rekor/pkg/sharding"
"github.com/sigstore/rekor/pkg/types"
intotod "github.com/sigstore/rekor/pkg/types/intoto/v0.0.1"
"github.com/sigstore/rekor/pkg/util"
Expand Down Expand Up @@ -254,9 +255,9 @@ func verifyRootHash(ctx context.Context, rekorClient *client.Rekor, proof *model
return nil
}

func verifyTlogEntryByUUID(ctx context.Context, rekorClient *client.Rekor, uuid string) (*models.LogEntryAnon, error) {
func verifyTlogEntryByUUID(ctx context.Context, rekorClient *client.Rekor, entryUUID string) (*models.LogEntryAnon, error) {
params := entries.NewGetLogEntryByUUIDParamsWithContext(ctx)
params.EntryUUID = uuid
params.EntryUUID = entryUUID

lep, err := rekorClient.Entries.GetLogEntryByUUID(params)
if err != nil {
Expand All @@ -266,7 +267,20 @@ func verifyTlogEntryByUUID(ctx context.Context, rekorClient *client.Rekor, uuid
if len(lep.Payload) != 1 {
return nil, errors.New("UUID value can not be extracted")
}
e := lep.Payload[params.EntryUUID]

uuid, err := sharding.GetUUIDFromIDString(params.EntryUUID)
if err != nil {
return nil, err
}

var e models.LogEntryAnon
for k, entry := range lep.Payload {
if k != uuid {
return nil, errors.New("expected matching UUID")
}
e = entry
}

return verifyTlogEntry(ctx, rekorClient, params.EntryUUID, e)
}

Expand Down

0 comments on commit 4dc20c2

Please sign in to comment.