The division of labour, before you start
Two things happen in this tutorial, and they are done by two different principals on purpose. A human writes the policy.policies:manage is not grantable to an API
key. A compromised CI credential that could both request a verdict and rewrite
the policy it is judged by is a build grading its own homework, and the entire
control collapses to nothing.
The pipeline only requests verdicts. Its key holds scans:create,
scans:read and verdicts:request, and nothing else. It cannot author a
policy, and it cannot suppress the findings that failed it.
So steps 1 to 3 are done from a browser session: the dashboard, or curl with
the session cookies from the Quickstart. Steps 4 onward are what your CI job
runs.
There is no TRUSTIVAN CLI. The CI story is curl against a scoped key,
which is why everything below is a shell command you can paste.
1. Create a policy
A policy starts disabled and with no rules. A policy that began enforcing the moment it was created would break a pipeline before its author had read it back.Terminal
id from the response:
Terminal
organization. That is the only scope implemented today,
and it is the one a team’s first policy needs: “what do we refuse to ship,
anywhere”.
2. Add a version with rules
Rules are declarative structs, not code. There is no expression language and no embedded interpreter: a rule is a set of conditions, all of which must hold for a finding to match, plus an effect.Terminal
min_severity, kinds, statuses, fixabilities, identifiers,
older_than_days and min_count. A rule with no conditions is rejected at
authoring time, because it would match every finding, which is never what
anyone meant. A policy may hold at most 50 rules, and a version with no rules
at all is rejected too.
This version is now immutable. A database trigger rejects every UPDATE
and DELETE on it, unconditionally. Changing the policy later means adding
version 2; version 1 stays readable forever, so a verdict recorded today can
still be explained next year.
3. Enable it
Terminal
4. Issue the pipeline’s key
Back to a machine credential, with the smallest set of scopes that does the job.Terminal
expires_at is optional (omitted, it defaults to 90 days), but expiry itself
is not: there is no value meaning never. The secret is in the response and
nowhere else, ever. Put it straight into your CI provider’s secret store.
Note what is absent. There is no findings:suppress, so this credential cannot
silence the findings that fail it. There is no policies:manage, because no
credential may hold it.
5. Request a scan
Terminal
202 means the work was accepted, not that it is done. A 200 instead means
an existing scan was returned, so a retry that was deduplicated is
distinguishable from a fresh request. Use your build identifier as the
idempotency key: it is reserved before any work begins, so two concurrent
retries cannot both queue a scan.
6. Poll until the scan is terminal
Terminal
database_state, which reports how fresh the
advisory data behind the result was. A scan run against stale data reports “no
vulnerabilities” with exactly the same confidence as a correct one, which is
why TRUSTIVAN surfaces the age rather than hiding it.
7. Ask for the verdict
This is the only request the gate itself needs. It never has to look at a single finding.Terminal
201 when a decision is recorded, 200 when a retry replays the one already
recorded. Idempotency here is a unique constraint on (scan, policy version),
so a CI job that retries because its pod was preempted gets the same answer
rather than a second decision.
8. Branch on the body, not the status line
This is the most important step in the tutorial.Terminal
result is one of pass, warn or fail. Only fail blocks, and blocking
is precomputed in the body so your gate does not reimplement TRUSTIVAN’s opinion
about which results stop a deployment. A warning that blocks is a failure with
a friendlier name.
9. Read why
When the gate stops a build, the reason is already in the response you have.Terminal
What you have now
A pipeline that stops on a policy failure, keeps running on a warning, and fails loudly rather than silently when TRUSTIVAN cannot answer. The decision it acted on is recorded, attributed to the key that requested it, and will still be explainable after the policy changes. From here:- Policies and verdicts: the rule language in full, including what suppression does to a verdict.
- CI pipelines: the same recipe as GitHub Actions and GitLab CI jobs.
- Triage a first backlog: what to do about the findings the gate reported.