Skip to content

Commit

Permalink
fix to use new attestation headers
Browse files Browse the repository at this point in the history
Signed-off-by: pxp928 <[email protected]>
  • Loading branch information
pxp928 committed Jul 18, 2024
1 parent e182ed5 commit 397d932
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions internal/testing/testdata/exampledata/certify-vuln.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"_type": "https://in-toto.io/Statement/v0.1",
"type": "https://in-toto.io/Statement/v0.1",
"subject": [
{
"uri": "pkg:maven/org.apache.logging.log4j/[email protected]"
}
],
"predicateType": "https://in-toto.io/attestation/vuln/v0.1",
"predicate_type": "https://in-toto.io/attestation/vuln/v0.1",
"predicate": {
"invocation": {
"parameters": [""],
Expand Down
4 changes: 2 additions & 2 deletions internal/testing/testdata/exampledata/crev-review.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"_type": "https://in-toto.io/Statement/v0.1",
"type": "https://in-toto.io/Statement/v0.1",
"subject": [
{
"name": "git://github.com/kubernetes/kubernetes",
"digest": {"sha1": "5835544ca568b757a8ecae5c153f317e5736700e"}
}
],
"predicateType": "https://crev.dev/in-toto-scheme/v-1",
"predicate_type": "https://crev.dev/in-toto-scheme/v-1",
"predicate": {
"reviewer-id": {
"id-type": "crev",
Expand Down
4 changes: 2 additions & 2 deletions internal/testing/testdata/exampledata/github-review.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"_type": "https://in-toto.io/Statement/v0.1",
"type": "https://in-toto.io/Statement/v0.1",
"subject": [
{
"name": "git://github.com/kubernetes/kubernetes",
"digest": {"sha1": "5835544ca568b757a8ecae5c153f317e5736700e"}
}
],
"predicateType": "https://in-toto.io/attestation/certify/v0.1",
"predicate_type": "https://in-toto.io/attestation/certify/v0.1",
"predicate": {
"certifier": {
"name": "John Doe",
Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/processor/guesser/guesser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func Test_GuessDocument(t *testing.T) {
}, {
name: "valid ITE6 Document",
document: &processor.Document{
Blob: []byte(`{"_type": "https://in-toto.io/Statement/v0.1"}`),
Blob: []byte(`{"type": "https://in-toto.io/Statement/v0.1"}`),
Type: processor.DocumentUnknown,
Format: processor.FormatUnknown,
SourceInformation: processor.SourceInformation{},
Expand All @@ -112,7 +112,7 @@ func Test_GuessDocument(t *testing.T) {
}, {
name: "valid SLSA ITE6 Document",
document: &processor.Document{
Blob: []byte(`{"_type": "https://in-toto.io/Statement/v0.1", "predicateType": "https://slsa.dev/provenance/v0.2"}`),
Blob: []byte(`{"type": "https://in-toto.io/Statement/v0.1", "predicate_type": "https://slsa.dev/provenance/v0.2"}`),
Type: processor.DocumentUnknown,
Format: processor.FormatUnknown,
SourceInformation: processor.SourceInformation{},
Expand All @@ -122,7 +122,7 @@ func Test_GuessDocument(t *testing.T) {
}, {
name: "valid SLSA ITE6 Document with different versions",
document: &processor.Document{
Blob: []byte(`{"_type": "https://in-toto.io/Statement/v1.1", "predicateType": "https://slsa.dev/provenance/v1.0"}`),
Blob: []byte(`{"type": "https://in-toto.io/Statement/v1.1", "predicate_type": "https://slsa.dev/provenance/v1.0"}`),
Type: processor.DocumentUnknown,
Format: processor.FormatUnknown,
SourceInformation: processor.SourceInformation{},
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/processor/guesser/type_ite6.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
jsoniter "github.com/json-iterator/go"

"github.com/guacsec/guac/pkg/handler/processor"
"github.com/in-toto/in-toto-golang/in_toto"
attestationv1 "github.com/in-toto/attestation/go/v1"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary

type ite6TypeGuesser struct{}

func (_ *ite6TypeGuesser) GuessDocumentType(blob []byte, format processor.FormatType) processor.DocumentType {
var statement in_toto.Statement
var statement attestationv1.Statement
if json.Unmarshal(blob, &statement) == nil && format == processor.FormatJSON {
if strings.HasPrefix(statement.Type, "https://in-toto.io/Statement") {
if strings.HasPrefix(statement.PredicateType, "https://slsa.dev/provenance") {
Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/processor/guesser/type_ite6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ func Test_Ite6TypeGuesser(t *testing.T) {
expected: processor.DocumentUnknown,
}, {
name: "valid ITE6 Document",
blob: []byte(`{"_type": "https://in-toto.io/Statement/v0.1"}`),
blob: []byte(`{"type": "https://in-toto.io/Statement/v0.1"}`),
expected: processor.DocumentITE6Generic,
}, {
name: "valid SLSA ITE6 Document",
blob: []byte(`{"_type": "https://in-toto.io/Statement/v0.1", "predicateType": "https://slsa.dev/provenance/v0.2"}`),
blob: []byte(`{"type": "https://in-toto.io/Statement/v0.1", "predicate_type": "https://slsa.dev/provenance/v0.2"}`),
expected: processor.DocumentITE6SLSA,
}, {
name: "valid SLSA ITE6 Document with different versions",
blob: []byte(`{"_type": "https://in-toto.io/Statement/v1.1", "predicateType": "https://slsa.dev/provenance/v1.0"}`),
blob: []byte(`{"type": "https://in-toto.io/Statement/v1.1", "predicate_type": "https://slsa.dev/provenance/v1.0"}`),
expected: processor.DocumentITE6SLSA,
}, {
name: "valid CREV ITE6 Document",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingestor/parser/clearlydefined/clearlydefined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestParser(t *testing.T) {
},
},
},
wantHSA: nil,
wantHSA: []assembler.HasSourceAtIngest{},
wantErr: false,
}}

Expand Down

0 comments on commit 397d932

Please sign in to comment.