Write a trust policy¶
Goal: a policy.yaml that says whose results you reuse, and nobody else's.
flowchart LR
p([policy.yaml]) --> id["identities:<br>issuer + subjectRegexp,<br>or publicKey"] --> tl[trustLevel] --> min{"≥ minTrustLevel?"}
min -- yes --> ok([reuse]):::ok
min -- no --> m([miss]):::muted
The example¶
Trust one GitHub Actions workflow on main (the policy of Aval's
example-go-compose job):
# Trust policy for the GitHub Actions demo (the example-go-compose job in
# .github/workflows/ci.yaml): reuse only results signed keyless by that
# workflow on main. Anything else that sits under the fingerprint, such as a
# result signed with some key, is a verification failure (exit 5).
apiVersion: aval.trianalab.io/v1
kind: Policy
minTrustLevel: runner
identities:
- issuer: https://token.actions.githubusercontent.com
subjectRegexp: https://github\.com/TrianaLab/aval/\.github/workflows/ci\.yaml@refs/heads/main
trustLevel: runner
For a key: Sign results. Pass it with --policy,
or set AVAL_POLICY once (the flag wins):
To skip --registry, add registry: ghcr.io/acme/orders-aval to the
policy. The flag and AVAL_REGISTRY still win, and the config: line says
which one was used. Never put user:password@ in it: logins come from
docker login.
One policy for PRs and main¶
A policy that also trusts developer keys sets minTrustLevel: developer, so
PRs reuse them. On main, raise the minimum for that run only:
AVAL_MIN_TRUST_LEVEL=runner does the same (the flag wins). Both work on
aval run and aval verify and can only raise the policy's minimum: a lower
or unknown level exits 2. A developer result is then a miss (exit 4), never
exit 5. A policy that trusts only main's CI identity does not need this.
The GitHub run action does it by default
on the default branch; min-trust-level: developer opts out.
The fields¶
| Field | Meaning |
|---|---|
identities |
the signers you accept: each is an OIDC issuer plus a subjectRegexp matched against the whole certificate subject, or a publicKey PEM file. At least one. |
trustLevel |
the level an identity gets: developer, runner or isolated. |
minTrustLevel |
the lowest level a result needs to be reused. --min-trust-level or AVAL_MIN_TRUST_LEVEL on run and verify can raise it for one run, never lower it (a lower or unknown level exits 2). |
allowedCacheability |
classes reused besides hermetic and controlled-environment; only external-dependencies has an effect, and non-deterministic is rejected. |
trustedRoot |
a pinned Sigstore trusted root for keyless signatures; without it, the public-good root is fetched. |
registry |
optional: the OCI repository of attestations (host/name), used by aval run and aval verify when neither --registry nor AVAL_REGISTRY is set. No credentials: a value with user:password@ (or any @) exits 2. Logins come from the credential store. |
Tips¶
- Read the policy from a protected branch in CI, never from the PR's checkout
(why): its
identities and its
registrydecide what is trusted. - Anchor the subject to one workflow file and one branch. A PR branch runs
any code: never trust it as
runner. - Give developer keys
developer. KeepminTrustLevel: runnerin CI, so CI never reuses laptop results. subjectRegexpmust match the whole subject. Escape dots:github\.com.- Keyless checks fetch the Sigstore root on first use and cache it under
$HOME/.sigstore; offline the test runs. PintrustedRootto avoid it (details).
Read next¶
- Trust
- Troubleshooting: every policy error