Skip to content

Commit

Permalink
Rename recipe to invocation
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Franssen <marco.franssen@philips.com>
  • Loading branch information
marcofranssen committed Nov 11, 2021
1 parent f1d82ec commit 9551b97
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/github/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (e *Environment) GenerateProvenanceStatement(ctx context.Context, artifactP
intoto.WithMetadata(fmt.Sprintf("%s/actions/runs/%s", repoURI, e.Context.RunID)),
// NOTE: This is inexact as multiple workflows in a repo can have the same name.
// See https://github.com/github/feedback/discussions/4188
intoto.WithRecipe(
intoto.WithInvocation(
RecipeType,
e.Context.Workflow,
nil,
Expand Down
6 changes: 3 additions & 3 deletions lib/github/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestGenerateProvenance(t *testing.T) {
assert.Equal(fmt.Sprintf("%s%s", repoURL, github.HostedIDSuffix), predicate.Builder.ID)

assertMetadata(assert, predicate.Metadata, gh, repoURL)
assertRecipe(assert, predicate.Recipe)
assertInvocation(assert, predicate.Invocation)
}

func TestGenerateProvenanceFromGitHubRelease(t *testing.T) {
Expand Down Expand Up @@ -353,7 +353,7 @@ func TestGenerateProvenanceFromGitHubRelease(t *testing.T) {
assert.Equal(fmt.Sprintf("%s%s", repoURL, github.HostedIDSuffix), predicate.Builder.ID)

assertMetadata(assert, predicate.Metadata, ghContext, repoURL)
assertRecipe(assert, predicate.Recipe)
assertInvocation(assert, predicate.Invocation)

stmtPath := path.Join(artifactPath, "build.provenance")

Expand Down Expand Up @@ -393,7 +393,7 @@ func TestGenerateProvenanceFromGitHubReleaseErrors(t *testing.T) {
assert.Nil(stmt)
}

func assertRecipe(assert *assert.Assertions, recipe intoto.Recipe) {
func assertInvocation(assert *assert.Assertions, recipe intoto.Invocation) {
assert.Equal(github.RecipeType, recipe.Type)
assert.Equal(0, recipe.DefinedInMaterial)
assert.Equal("", recipe.EntryPoint)
Expand Down
18 changes: 9 additions & 9 deletions lib/intoto/intoto.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ func WithMetadata(buildInvocationID string) StatementOption {
}
}

// WithRecipe sets the Predicate Recipe and Materials
func WithRecipe(predicateType string, entryPoint string, environment json.RawMessage, arguments json.RawMessage, materials []Item) StatementOption {
// WithInvocation sets the Predicate Invocation and Materials
func WithInvocation(predicateType string, entryPoint string, environment json.RawMessage, arguments json.RawMessage, materials []Item) StatementOption {
return func(s *Statement) {
s.Predicate.Recipe = Recipe{
s.Predicate.Invocation = Invocation{
Type: predicateType,
EntryPoint: entryPoint,
Arguments: arguments,
Expand Down Expand Up @@ -108,10 +108,10 @@ type Subject struct {
//
// A predicate has a required predicateType (TypeURI) identifying what the predicate means, plus an optional predicate (object) containing additional, type-dependent parameters.
type Predicate struct {
Builder `json:"builder"`
Metadata `json:"metadata"`
Recipe `json:"recipe"`
Materials []Item `json:"materials"`
Builder `json:"builder"`
Metadata `json:"metadata"`
Invocation `json:"invocation"`
Materials []Item `json:"materials"`
}

// Builder Identifies the entity that executed the recipe, which is trusted to have correctly performed the operation and populated this provenance.
Expand All @@ -133,8 +133,8 @@ type Metadata struct {
BuildFinishedOn string `json:"buildFinishedOn"`
}

// Recipe Identifies the configuration used for the build. When combined with materials, this SHOULD fully describe the build, such that re-running this recipe results in bit-for-bit identical output (if the build is reproducible).
type Recipe struct {
// Invocation Identifies the configuration used for the build. When combined with materials, this SHOULD fully describe the build, such that re-running this recipe results in bit-for-bit identical output (if the build is reproducible).
type Invocation struct {
Type string `json:"type"`
DefinedInMaterial int `json:"definedInMaterial"`
EntryPoint string `json:"entryPoint"`
Expand Down
12 changes: 6 additions & 6 deletions lib/intoto/intoto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ func TestSLSAProvenanceStatement(t *testing.T) {
stmt = SLSAProvenanceStatement(
WithSubject(make([]Subject, 1)),
WithBuilder(builderID),
WithRecipe(
WithInvocation(
recipeType,
"CI workflow",
nil,
nil,
provenanceActionMaterial,
),
)
r := stmt.Predicate.Recipe
i := stmt.Predicate.Invocation
assert.Equal(SlsaPredicateType, stmt.PredicateType)
assert.Equal(StatementType, stmt.Type)
assert.Len(stmt.Subject, 1)
assert.Equal(builderID, stmt.Predicate.Builder.ID)
assert.Equal(recipeType, r.Type)
assert.Equal("CI workflow", r.EntryPoint)
assert.Nil(r.Arguments)
assert.Equal(0, r.DefinedInMaterial)
assert.Equal(recipeType, i.Type)
assert.Equal("CI workflow", i.EntryPoint)
assert.Nil(i.Arguments)
assert.Equal(0, i.DefinedInMaterial)
assert.Equal(provenanceActionMaterial, stmt.Predicate.Materials)
}

0 comments on commit 9551b97

Please sign in to comment.