Skip to content

Commit

Permalink
stop inserting envelope hash for intoto:0.0.2 types into index (#1171) (
Browse files Browse the repository at this point in the history
#1172)

Signed-off-by: Bob Callaway <bcallaway@google.com>

Signed-off-by: Bob Callaway <bcallaway@google.com>
  • Loading branch information
bobcallaway authored Nov 7, 2022
1 parent ee4a959 commit 9013a76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 4 additions & 2 deletions pkg/types/intoto/v0.0.2/entry.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 9013a76

Please sign in to comment.