Nothing needs to be installed. A gate is one shell script: request a scan, poll it to a terminal state, ask for a verdict, and branch on the body. The trustivan gate command is the same loop as a single binary, if you would rather not maintain the script.

The credential

Issue one key per pipeline, with the minimum scopes: Nothing else. In particular not findings:suppress, because a runner that can queue scans has no business being able to silence its own failures. And policies:manage is not grantable to a key at all, so the pipeline cannot rewrite the policy that judges it. Someone with a browser session writes the policy; see Gate a pipeline on a policy. Store the secret in your CI provider’s secret store, never in the repository, never in the job definition. It is shown exactly once at creation and expires in at most 365 days, so put the rotation in your calendar (Rotate an API key).

The generic recipe

Works anywhere with bash, curl and jq.
Three exit codes, because there are three outcomes: 0 ship, 1 the policy says stop, 2 TRUSTIVAN could not answer. Collapsing the last two is the mistake this whole design is arranged to prevent.

The four things that matter

Branch on the body, never the status line. POST /scans/{id}/verdict returns 201 when it records a decision and 200 when it replays one; a failing verdict is still a successful request. A pipeline that treated a policy failure as an HTTP error could not distinguish “the build should stop” from “TRUSTIVAN is unreachable”, and those demand opposite reactions: the first fails the build, the second is retried or escalated, and neither is silently treated as a pass. blocking is precomputed in the body so your gate does not reimplement TRUSTIVAN’s opinion about which results stop a deployment. Give the key the minimum scopes, and store it as a secret. See the table above. Set a real poll timeout. A large image takes minutes to pull and unpack. An unbounded loop is a build that hangs rather than one that reports a problem; exit 2 on timeout puts it in the same bucket as any other infrastructure failure. Use the build ID as the idempotency key. It is reserved before any work, so two concurrent retries cannot both queue a scan, and a replayed request is marked with Idempotent-Replay: true.

GitHub Actions

github.run_id alone would be reused by a re-run, so the attempt number is appended: a deliberate re-run should be able to queue a fresh scan, while a transient retry inside one attempt should not. TRUSTIVAN does not scan pull requests and is not triggered by a push. This job is what runs on push, and it is the whole of the GitHub story. See Integrations overview.

GitLab CI

TRUSTIVAN_KEY goes in a masked, protected CI/CD variable rather than in this file. To let a failing policy report without blocking while a team settles in, use allow_failure on the job rather than making the script swallow the exit code. The distinction between exit 1 and exit 2 is worth keeping.

Other CI systems

Each of these runs trustivan gate with the system’s own secret store, artifact upload and retry semantics: Jenkins, CircleCI, Azure Pipelines, Bitbucket Pipelines and Buildkite.

Certificate checks with tls-check

tls-check fails a build when a host’s certificate is expired, expiring, untrusted, mismatched or weak, or the host still accepts TLS 1.0/1.1, and with -file it judges a PEM file, a Kubernetes TLS Secret or a cert-manager Certificate before it is deployed. It needs no TRUSTIVAN account. On GitHub it is an action (Certificates); there is no release binary for it, so anywhere else you build it from the repository with Go:
The Go version is the one in backend/go.mod. Exit 0 means nothing at or above -fail-on (low, medium, high or never), 1 means a host or file failed, and 2 is a usage error. -upload also posts the result to TRUSTIVAN as pipeline gate evidence on the Certificates page, with TRUSTIVAN_API_KEY (scope scans:create) and TRUSTIVAN_URL from the environment. It reads the repository, ref, commit and run link from GitHub Actions or GitLab CI variables only. On any other system, set the GitLab names yourself so the evidence says where it came from:

Gotchas

  • The image must already be pushed and reachable from TRUSTIVAN. A public registry needs nothing; a private one needs a credential stored against that registry host beforehand (Pro and Enterprise). Either way TRUSTIVAN never reads from the runner: it pulls the image itself, so a credential in your CI environment is not one TRUSTIVAN can see or use.
  • 409 on the verdict request means no policy is enabled for the organisation. That is a configuration problem, not a security decision. Treat it as exit 2.
  • Check database_state. A scan against stale advisory data reports “no vulnerabilities” with exactly the same confidence as a correct one.
  • A retried verdict request returns the same decision, not a second one: idempotency here is a unique constraint on (scan, policy version).
  • Prefer a webhook to a long poll for fleets. For one image per build, polling is fine; across many, subscribe to verdict.recorded instead (Webhooks).

See also