mirror of
https://github.com/slsa-framework/slsa-verifier.git
synced 2026-05-11 11:06:38 +00:00
fix: properly handle sharded uuids returned from rekor (#141)
Signed-off-by: Asra Ali <asraa@google.com> Co-authored-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
This commit is contained in:
@@ -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"
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user