Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/attestation/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func ProvenanceFromBundlePayload(sig oci.Signature, dsseJSON []byte) (Attestatio
return nil, fmt.Errorf("malformed bundle attestation: %w", err)
}

if statement.Type != in_toto.StatementInTotoV1 &&
statement.Type != in_toto.StatementInTotoV01 {
return nil, fmt.Errorf("unsupported attestation type: %s", statement.Type)
}

signatures, err := createEntitySignatures(sig, payload)
if err != nil {
return nil, fmt.Errorf("cannot create signed entity: %w", err)
Expand Down
22 changes: 22 additions & 0 deletions internal/attestation/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestProvenanceFromSignature(t *testing.T) {
snaps.MatchJSON(t, string(p.Statement()))
})
}

}

func TestProvenance_Type(t *testing.T) {
Expand Down Expand Up @@ -284,6 +285,27 @@ func TestProvenanceFromBundlePayload(t *testing.T) {
base64.StdEncoding.EncodeToString([]byte(`not-json`))),
expectErr: "malformed bundle attestation",
},
{
name: "unsupported attestation type",
setup: func(l *mockSignature) {},
dsseJSON: fmt.Sprintf(`{"payloadType":"application/vnd.in-toto+json","signatures": [%s], "payload": "%s"}`,
sig1, encode(`{
"_type": "https://bogus.example.io/Statement/v9.9",
"predicateType": "https://cool-type.example.io/Amazing/v2.0",
"predicate": {}
}`)),
expectErr: "unsupported attestation type: https://bogus.example.io/Statement/v9.9",
},
{
name: "empty attestation type",
setup: func(l *mockSignature) {},
dsseJSON: fmt.Sprintf(`{"payloadType":"application/vnd.in-toto+json","signatures": [%s], "payload": "%s"}`,
sig1, encode(`{
"predicateType": "https://cool-type.example.io/Amazing/v2.0",
"predicate": {}
}`)),
expectErr: "unsupported attestation type: ",
},
}

for _, c := range cases {
Expand Down
Loading