You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it would be useful to have something like chainloop policy eval that receives a material and a policy (file, URL) and returns a report with potential violations. I would be used in manual control gates
I'd love if this command has a 'development mode` (flag) that allows us to see the input, data,linting errors, and evaluation output, similar to what the rego playground does.
I'd love if this command has a 'development mode` (flag) that allows us to see the input, data,linting errors, and evaluation output, similar to what the rego playground does.
Use rego-playground to develop the policy code by providing some test data
use rego linter
run it during an attestation process to see if it works
This approach has some issues:
Our policies are more than just rego scripts, their root is a policy.yaml file that's in charge of defining arguments, encode different material type paths, etc. This is not easily tested using the process above.
It's not trivial to know in advance if a writen rego script meets our content standards (result struct, skip_reason, etc) defined in our template.
For policy evaluations, we have something like this internally that can be used as inspiration. It essentially takes a policy file (the yaml spec), a material (the raw content, like an SBOM, report, or even an ATTESTATION), and the policy arguments:
btw, what I mentioned today about making sure we are running the policies with the right capabilities, I think this is done automatically already if you eval the policies with our engine
Activity
migmartri commentedon Aug 16, 2024
I'd love if this command has a 'development mode` (flag) that allows us to see the input, data,linting errors, and evaluation output, similar to what the rego playground does.
jiparis commentedon Aug 22, 2024
I think opa eval might be of help for this:
migmartri commentedon Jul 1, 2025
@jiparis I just wrote a quick spec, what do you think?
Overview
Today, to write a custom policy, you need to
This approach has some issues:
Goals
To have a development environment to write, lint, and test custom chainloop policies.
chainloop policy develop [subcommand]
init [directory]
Bootstraps a chainloop policy and example script based on our template. This template should be workable out of the box
lint
By default it load a policy.yaml file in the current directory and perform
rego script(s)
chainloop.yaml
eval --material [material-file] --kind [...] --annotations ...
jiparis commentedon Jul 1, 2025
For policy evaluations, we have something like this internally that can be used as inspiration. It essentially takes a policy file (the yaml spec), a material (the raw content, like an SBOM, report, or even an ATTESTATION), and the policy arguments:
migmartri commentedon Jul 17, 2025
btw, what I mentioned today about making sure we are running the policies with the right capabilities, I think this is done automatically already if you eval the policies with our engine
chainloop/pkg/policies/engine/rego/rego.go
Line 233 in 17dbde7