From 9013a761ca5c6f5ba16143c265aeb64f17bde9cd Mon Sep 17 00:00:00 2001 From: Bob Callaway Date: Mon, 7 Nov 2022 13:21:30 -0500 Subject: [PATCH] stop inserting envelope hash for intoto:0.0.2 types into index (#1171) (#1172) Signed-off-by: Bob Callaway Signed-off-by: Bob Callaway --- pkg/types/intoto/v0.0.2/entry.go | 6 ++++-- pkg/types/intoto/v0.0.2/entry_test.go | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/types/intoto/v0.0.2/entry.go b/pkg/types/intoto/v0.0.2/entry.go index 6b7a62a45..ae8d278ac 100644 --- a/pkg/types/intoto/v0.0.2/entry.go +++ b/pkg/types/intoto/v0.0.2/entry.go @@ -96,8 +96,10 @@ func (v V002Entry) IndexKeys() ([]string, error) { payloadKey := strings.ToLower(fmt.Sprintf("%s:%s", *v.IntotoObj.Content.PayloadHash.Algorithm, *v.IntotoObj.Content.PayloadHash.Value)) result = append(result, payloadKey) - hashkey := strings.ToLower(fmt.Sprintf("%s:%s", *v.IntotoObj.Content.Hash.Algorithm, *v.IntotoObj.Content.Hash.Value)) - result = append(result, hashkey) + // since we can't deterministically calculate this server-side (due to public keys being added inline, and also canonicalization being potentially different), + // we'll just skip adding this index key + // hashkey := strings.ToLower(fmt.Sprintf("%s:%s", *v.IntotoObj.Content.Hash.Algorithm, *v.IntotoObj.Content.Hash.Value)) + // result = append(result, hashkey) switch *v.IntotoObj.Content.Envelope.PayloadType { case in_toto.PayloadType: diff --git a/pkg/types/intoto/v0.0.2/entry_test.go b/pkg/types/intoto/v0.0.2/entry_test.go index 66bd21a23..8b432d71d 100644 --- a/pkg/types/intoto/v0.0.2/entry_test.go +++ b/pkg/types/intoto/v0.0.2/entry_test.go @@ -32,7 +32,6 @@ import ( "math/big" "reflect" "sort" - "strings" "testing" "github.com/go-openapi/runtime" @@ -294,8 +293,6 @@ func TestV002Entry_Unmarshal(t *testing.T) { t.Errorf("V002Entry.AttestationKey() = %v, want %v", v.AttestationKey(), "sha256:"+hex.EncodeToString(h[:])) } - hashkey := strings.ToLower(fmt.Sprintf("%s:%s", *tt.it.Content.Hash.Algorithm, *tt.it.Content.Hash.Value)) - want = append(want, hashkey) got, _ := v.IndexKeys() sort.Strings(got) sort.Strings(want) @@ -456,8 +453,6 @@ func TestV002Entry_IndexKeys(t *testing.T) { want = append(want, "sha256:"+hex.EncodeToString(payloadHash[:])) - hashkey := strings.ToLower("sha256:" + *v.IntotoObj.Content.Hash.Value) - want = append(want, hashkey) want = append(want, tt.want...) got, _ := v.IndexKeys() sort.Strings(got)