Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
Signed-off-by: Marcela Melara <marcela.melara@intel.com>
  • Loading branch information
marcelamelara committed Dec 20, 2023
1 parent fcf6985 commit 3835580
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
9 changes: 3 additions & 6 deletions in_toto/attestation/predicates/provenance/v1/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (

prov1 "github.com/in-toto/attestation/go/predicates/provenance/v1"
ita1 "github.com/in-toto/attestation/go/v1"
acommon "github.com/in-toto/in-toto-golang/in_toto/attestation/common"
alib1 "github.com/in-toto/in-toto-golang/in_toto/attestation/v1"
"github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/common"

"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -42,9 +39,9 @@ Validation is handled in GenProvenance().
*/
func GenRunDetails(builder *prov1.Builder, metadata *prov1.BuildMetadata, byproducts []*ita1.ResourceDescriptor) *prov1.RunDetails {
runDetails := &prov1.RunDetails{
Builder: builder,
BuildMetadata: metadata,
Byproducts: byproducts,
Builder: builder,
Metadata: metadata,
Byproducts: byproducts,
}

return runDetails
Expand Down
2 changes: 1 addition & 1 deletion in_toto/attestation/v1/resource_descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func RDListFromRecord(evalArtifacts map[string]map[string]string) ([]*ita1.Resou
var rds []*ita1.ResourceDescriptor
for name, digestSet := range evalArtifacts {

rd, err := GenResourceDescriptor(name, "", digestSet, nil, "", "", nil)
rd, err := GenerateValidResourceDescriptor(name, "", digestSet, nil, "", "", nil)

if err != nil {
return nil, err
Expand Down
9 changes: 4 additions & 5 deletions in_toto/runlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,13 @@ func InTotoRun(name string, runDir string, materialPaths []string, productPaths
return nil, err
}

var dssePayload any
// FIXME: replace when Attestation Framework support is fully implemented
var link Link
if attest {
// FIXME
return nil, errors.New("in-toto attestation support not implemented yet")
} else {
link := Link{
link = Link{
Type: "link",
Name: name,
Materials: materials,
Expand All @@ -353,13 +354,11 @@ func InTotoRun(name string, runDir string, materialPaths []string, productPaths
Command: cmdArgs,
Environment: map[string]interface{}{},
}

dssePayload = link
}

if useDSSE {
env := &Envelope{}
if err := env.SetPayload(dssePayload); err != nil {
if err := env.SetPayload(link); err != nil {
return nil, err
}
if !reflect.ValueOf(key).IsZero() {
Expand Down
4 changes: 3 additions & 1 deletion in_toto/runlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ func TestInTotoRun(t *testing.T) {
}

for _, table := range tablesCorrect {
result, err := InTotoRun(linkName, "", table.materialPaths, table.productPaths, table.cmdArgs, table.key, table.hashAlgorithms, nil, nil, testOSisWindows(), false, table.useDSSE)
// FIXME: The `attest` parameter is always false until full Attestation Framework support is added
result, err := InTotoRun(linkName, "", table.materialPaths, table.productPaths, table.cmdArgs, table.key, table.hashAlgorithms, nil, nil, testOSisWindows(), false, table.useDSSE, false)
if table.useDSSE {
assert.Equal(t, table.result.(*Envelope).envelope, result.(*Envelope).envelope, fmt.Sprintf("InTotoRun returned '(%s, %s)', expected '(%s, nil)'", result, err, table.result))
} else {
Expand Down Expand Up @@ -526,6 +527,7 @@ func TestInTotoRun(t *testing.T) {
}

for _, table := range tablesInvalid {
// FIXME: The `attest` parameter is always false until full Attestation Framework support is added
result, err := InTotoRun(linkName, "", table.materialPaths, table.productPaths, table.cmdArgs, table.key, table.hashAlgorithms, nil, nil, testOSisWindows(), false, false)

Check failure on line 531 in in_toto/runlib_test.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, ubuntu-latest)

not enough arguments in call to InTotoRun

Check failure on line 531 in in_toto/runlib_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

not enough arguments in call to InTotoRun
if err == nil {
t.Errorf("InTotoRun returned '(%s, %s)', expected error",
Expand Down
3 changes: 2 additions & 1 deletion in_toto/verifylib.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ func RunInspections(layout Layout, runDir string, lineNormalization bool, useDSS
paths = []string{runDir}
}

// FIXME: The `attest` parameter is always false until full Attestation Framework support is added
linkEnv, err := InTotoRun(inspection.Name, runDir, paths, paths,
inspection.Run, Key{}, []string{"sha256"}, nil, nil, lineNormalization, false, useDSSE)
inspection.Run, Key{}, []string{"sha256"}, nil, nil, lineNormalization, false, useDSSE, false)

if err != nil {
return nil, err
Expand Down

0 comments on commit 3835580

Please sign in to comment.