Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/cli/cmd/policy_develop_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ evaluates the policy against the provided material or attestation.`,

result, err := policyEval.Run()
if err != nil {
return newGracefulError(err)
return err
}

return encodeJSON(result)
Expand Down
13 changes: 3 additions & 10 deletions app/cli/internal/policydevel/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func Evaluate(opts *EvalOptions, logger zerolog.Logger) ([]*EvalResult, error) {
// 1. Create crafting schema
schema, err := createCraftingSchema(opts.PolicyPath, opts.Inputs)
if err != nil {
return nil, fmt.Errorf("creating crafting schema: %w", err)
return nil, err
}

// 2. Craft material with annotations
material, err := craftMaterial(opts.MaterialPath, opts.MaterialKind, &logger)
if err != nil {
return nil, fmt.Errorf("material crafting: %w", err)
return nil, err
}
material.Annotations = opts.Annotations

Expand Down Expand Up @@ -95,14 +95,7 @@ func verifyMaterial(schema *v1.CraftingSchema, material *v12.Attestation_Materia

// no evaluations were returned
if len(policyEvs) == 0 {
return []*EvalResult{
{
Ignored: true,
Skipped: false,
SkipReasons: []string{},
Violations: []string{},
},
}, nil
return nil, fmt.Errorf("no execution branch matched for kind %s", material.MaterialType.String())
}

results := make([]*EvalResult, 0, len(policyEvs))
Expand Down
5 changes: 2 additions & 3 deletions app/cli/internal/policydevel/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ func TestEvaluate(t *testing.T) {
}

results, err := Evaluate(opts, logger)
require.NoError(t, err)
require.NotEmpty(t, results)
assert.NotNil(t, results[0])
require.Error(t, err)
assert.Empty(t, results)
})

t.Run("evaluation with auto-detected SBOM CYCLONEDX kind", func(t *testing.T) {
Expand Down
Loading