Skip to content

Conversation

@migmartri
Copy link
Member

Runs the attestation-related policy evaluations in the crafting layer storing it in the state.

This is a pre-requisite for #1685.

In practice nothing changes except that policy-level evaluations happen in status and push and then the renderer layer just takes the info in the state.

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri requested a review from jiparis January 2, 2025 15:00

// execute policy evaluations
// We do not want to evaluate policies here during render since we want to do it in a separate step
statement, err := renderer.RenderStatement(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about also running it on att.add but I am not sure it's needed yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, since we want to block only on "push"

}

// We do not want to evaluate policies here during render since we want to do it in a separate step
statement, err := renderer.RenderStatement(ctx, chainloop.WithSkipPolicyEvaluation(true))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderer never evaluates policies anymore

Copy link
Member

@jiparis jiparis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

// addPolicyResults adds policy evaluation results to the statement. It does it by deserializing the predicate from a structpb.Struct,
// filling PolicyEvaluations, and serializing it again to a structpb.Struct object, using JSON as an intermediate representation.
// Note that this is needed because intoto predicates are generic structpb.Struct
func addPolicyResults(statement *intoto.Statement, policyResults []*v1.PolicyEvaluation) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this change.

@migmartri migmartri merged commit 70b0f08 into chainloop-dev:main Jan 2, 2025
13 checks passed
aarlint pushed a commit to aarlint/chainloop that referenced this pull request Jan 3, 2025
…hainloop-dev#1689)

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Austin Arlint <aarlint@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants