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

stop inserting envelope hash for intoto:0.0.2 types into index (#1171) #1172

Merged
merged 2 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions pkg/types/intoto/v0.0.2/entry.go
Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions pkg/types/intoto/v0.0.2/entry_test.go
Expand Up @@ -32,7 +32,6 @@ import (
"math/big"
"reflect"
"sort"
"strings"
"testing"

"github.com/go-openapi/runtime"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down