chainloop-dev / chainloop

Chainloop is an Open Source evidence store for your Software Supply Chain attestations, SBOMs, VEX, SARIF, CSAF files, QA reports, and more.
https://docs.chainloop.dev
Apache License 2.0
375 stars 29 forks source link

Support policies for attestations #122

Open migmartri opened 1 year ago

migmartri commented 1 year ago

Currently, no verification is done when an attestation is received in the control plane. Creation and validation checks are done in the client side, but not on the server side.

We should allow operators to attach rego or potentially cue policies to their contracts and these should get evaluated during the reception of the attestation.

We created a task #35 which will get superseded by this functionality since 35 is in fact a policy check that some materials exist and that the runner type is correct.

re: implementation

About the policy format.

We should probably aim towards Open Policy Agent (OPA) and leverage (conftest) logic. We should take a look at policy-controller way of doing this

On the UX side of things we could allow attaching a policy to our contract today.

example from policy-controller that could map our current contract too.

using cue

policy:
        type: cue
        data: |
          predicateType: "https://cosign.sigstore.dev/attestation/v1"
          predicate: "foobar e2e test"

or rego

policy:
        type: rego
        data: |
          package sigstore
          default isCompliant = false
          isCompliant {
            input.predicateType == "https://cosign.sigstore.dev/attestation/v1"
            input.predicate == "foobar e2e test"
          }

Note: If we go ahead with the implementation based on an integration. We would need to extend the integrations model to read from its result and apply it to the workflow runs. Currently they are just fire and forget.

### Tasks
- [x] Propose policy API (protos)
- [ ] https://github.com/chainloop-dev/chainloop/issues/1107
- [ ] https://github.com/chainloop-dev/chainloop/issues/1108
- [ ] https://github.com/chainloop-dev/chainloop/issues/1110
- [ ] https://github.com/chainloop-dev/chainloop/issues/1111
- [ ] https://github.com/chainloop-dev/chainloop/issues/1112
jiparis commented 4 months ago

I'll reopen the issue, as it will be used as the umbrella for follow up tasks