---
title: "Policies and verdicts"
description: "How rules become a pass, warn or fail decision that a pipeline can branch on, and why verdicts are never recomputed."
---

A scan produces findings. A policy answers the only question a pipeline
actually asks:

> Did this scan satisfy our security policy?

The answer is a **verdict**: `pass`, `warn` or `fail`. Exactly one of them
blocks. A warning that blocks is a failure with a friendlier name, and a team
that discovers warnings block will stop using them, which removes the only
signal between "fine" and "stop".

## One implementation, evaluated once

Policy logic lives in one place. It is not in the scanner, not in a repository,
not in an HTTP handler, not in the dashboard.

That is not tidiness. A policy evaluated in three places is three policies, and
the day they disagree is the day something ships that the dashboard said was
fine. Every consumer (the API, CI, a webhook, the UI) reads the same recorded
verdict produced by the same function.

## Evaluation is a pure function

`Evaluate(policy, findings, now)` performs no I/O, reads no clock, and mutates
none of its inputs.

`now` is a **parameter**, not a call to the system clock. That is what makes a
verdict checkable: recomputing a historical evaluation from its stored inputs
and its recorded evaluation instant gives the same answer, or the stored
decision cannot be verified at all. Age rules become testable rather than
time-dependent.

Determinism extends to the *explanation*, not just the result. Findings are put
in a total order (severity descending, then first seen, then identifier, then
ID) so a diff of two verdicts shows a policy change and never a map iteration.

## The rule language is not a language

There is no expression evaluator, no embedded interpreter and no user-supplied
code. A policy engine that executes customer code is a remote code execution
surface that runs on every scan, and the expressive power buys nothing a
security team has asked for.

A rule is a struct of conditions, all of which must hold. The conditions are
ANDed:

| Condition | Meaning |
|---|---|
| `min_severity` | At least this severe, on TRUSTIVAN's scale |
| `kinds` | `vulnerability`, `secret`, `misconfiguration`, `license` |
| `statuses` | `open`, `triaged`, `suppressed`, `resolved`, `reopened` |
| `fixabilities` | `fixable`, `unfixable`, `unknown` |
| `identifiers` | The advisory ID, matched case-insensitively |
| `older_than_days` | First seen more than N days ago |
| `min_count` | Fire only once this many findings match. Default 1 |
| `known_exploited` | `true`: only findings in the CISA KEV catalogue |
| `min_epss` | EPSS exploit probability at least this, 0 to 1 (needs EPSS enabled) |
| `min_risk_score` | [Risk score](/concepts/risk-scoring) at least this, 1 to 100 |

The three risk conditions read the finding's stored risk assessment. When the
data a condition needs is unavailable (no KEV catalogue loaded, EPSS not
enabled or no score for the CVE, a finding not yet scored) the finding does
**not** match, and the rule outcome counts it as `undetermined` and the summary
says so, so a pass is never read as "nothing is exploited". Each matched
finding in a verdict carries `matched_on`, naming the risk factor that fired
and its value, e.g. `risk_score 88 >= 80`. `min_risk_score` compares the score,
which does not change when a finding is suppressed, so the policy's
suppression mode still decides what accepted risk does.

OR is expressed by writing a second rule. That keeps every rule independently
explainable: a verdict can say *which* rule fired and why, rather than pointing
at a boolean expression and leaving the reader to work it out.

`min_severity` is a floor rather than an exact match, because tiers are
expressed by writing two rules and letting the worst effect win:
`critical → fail` plus `high → warn` gives criticals a failure and highs a
warning, with no ordering semantics to reason about.

`older_than_days` measures from when TRUSTIVAN first observed the finding, not
from the advisory's publication date. The rule expresses "this has been
outstanding too long", which is a statement about the customer's remediation.
An advisory published in 2019 and introduced by a dependency added yesterday is
one day old to the team that has to fix it.

### Effects

| Effect | What it does |
|---|---|
| `fail` | Blocks |
| `warn` | Reports without blocking |
| `ignore` | **Exempts** matching findings from every other rule |

Every rule is evaluated, and the verdict is the worst effect that fired:
`fail` beats `warn` beats `pass`.

`ignore` rules produce no result of their own. They are applied **first**,
globally, before any other rule counts its matches, so an exemption is
absolute. An exemption that only applied to the rule it was written next to
would have to be repeated for every rule, and the one place it was forgotten is
where a known false positive blocks a release at midnight.

```json
{
  "id": "accepted-in-base-image",
  "effect": "ignore",
  "identifiers": ["CVE-2024-1234"]
}
```

That is how "we accept this in the base image" is expressed without weakening
the rule that catches everything else.

### Bounds and validation

| Bound | Value | Why |
|---|---|---|
| Rules per policy | 50 | Evaluation is rules × findings, and both are caller-controlled |
| Identifiers per rule | 200 | Same |
| Findings per evaluation | 10,000 | Bounded work, with truncation reported |

A **rule with no conditions is rejected at authoring time**. It would match
every finding, which is never what anyone meant, and as a `fail` rule it would
block every build forever.

A **policy with no rules cannot be enabled**. It would pass everything, which
is indistinguishable from having no policy and considerably more dangerous,
because it looks like protection.

Validation happens when a version is created, not when it is evaluated. A
malformed policy is rejected by the person writing it rather than discovered by
a pipeline at 3am.

### One rule that is not about findings

A rule with `signed_by` is about the scanned container image itself: it fires
unless the scan verified a cosign signature made by one of the listed public
keys. It carries no finding conditions, and it does not apply to a scan of
anything but an image. See
[Image signature verification](/security/image-signatures) for the rule, what
a scan records, and what is not verified (keyless signatures, among others).

## Suppression is not a pass

A suppressed finding is one a human has accepted or judged a false positive. It
would be very convenient for that to mean the policy passes. It would also mean
the fastest route to a green build is to accept the risk.

So the policy decides explicitly, per version:

| Mode | Behaviour |
|---|---|
| `warn` (**default**) | Suppressed findings are still evaluated. A `fail` rule that fires *only* because of suppressed findings is downgraded to a warning |
| `ignore` | Suppressed findings are removed before evaluation |
| `enforce` | Suppression is disregarded entirely; a suppressed critical fails |

The default is the security-conscious option that is still usable: the build is
not blocked by a risk somebody already accepted, but the acceptance stays
visible in the verdict rather than vanishing. A team that wants suppression to
mean silence has to say so, and that choice is recorded in an immutable
version, with an author and a timestamp, which is exactly where such a decision
belongs.

The downgrade requires that **every** matching finding be suppressed. One
unsuppressed critical alongside ten suppressed ones is still a `fail`, and the
downgrade is applied per rule so the explanation says which rule was softened.

See [Suppression](/concepts/suppression) for the other side of this.

## What a scan is evaluated against

The candidate set is precisely what **this scan** observed. A resolved finding
(one a later scan no longer sees) does not normally fail a current-scan
policy.

That is not the same as pretending it never existed. The finding, its history
and its events remain, and a policy can target `statuses: ["resolved"]`
deliberately.

A scan that has not succeeded cannot be evaluated at all. An empty finding set
would produce a `pass` for a scan that never looked at anything, which is the
most dangerous possible false negative.

## Scope: organisation only

A policy applies to an **organisation**. There is no project, repository,
environment or per-asset scope today. The stored scope field exists so those
can be added later without a migration that rewrites existing rows, but nothing
today issues anything but an organisation-scoped policy.

At most one policy may be enabled per scope, enforced by a partial unique
index:

```sql
CREATE UNIQUE INDEX policies_one_enabled_per_scope
    ON policies (org_id, scope_kind) WHERE enabled;
```

Without it, "did this scan pass?" has as many answers as there are enabled
policies.

## Versions are immutable

A policy is mutable metadata: its name, its description, whether it is
enabled. Its **rules** live in versions, which are append-only, enforced by a
database trigger that rejects every `UPDATE` and `DELETE`.

Unconditionally, not "unless a verdict references it". Conditional immutability
means a version is editable right up until the moment it starts mattering,
which is precisely the moment it must stop being editable.

Changing a policy means adding version N+1. Version N stays readable forever,
so a verdict recorded in March can still be explained in December.

## The verdict

```bash
curl -s -X POST localhost:8080/api/v1/scans/$SCAN_ID/verdict \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

```json
{
  "result": "fail",
  "blocking": true,
  "policy_name": "Production images",
  "policy_version": 3,
  "evaluated_at": "2026-08-29T09:14:22Z",
  "summary": "Policy \"Production images\" failed: 2 finding(s) matched no unfixed criticals.",
  "considered": 48,
  "suppressed": 3,
  "exempt": 1,
  "rules": [
    {
      "rule_id": "no-unfixed-criticals",
      "effect": "fail",
      "fired": true,
      "matched": 2,
      "threshold": 1,
      "findings": [ "…up to 20 references…" ]
    }
  ]
}
```

### The result is in the body, never in the status code

A failing verdict is a **successful request**. A pipeline that treated a policy
failure as an HTTP error could not distinguish "the build should stop" from
"TRUSTIVAN is down", and those two demand opposite reactions.

Branch on `blocking`.

| Status | Meaning |
|---|---|
| `201` | The verdict was recorded now |
| `200` | This scan was already judged by this policy version; the original decision is returned |
| `409` | No policy is enabled for this organisation |

Idempotency is a database constraint on `(scan, policy version)`, not a handler
check. A CI runner that retries (because the response was lost, because the
pod was preempted) gets the same answer, not a second decision. A replay
records no new audit entry either: it returns the original decision without
making a second one, and auditing it would report a judgement that never
happened.

Evaluating the same scan against a *different* policy version does create a new
verdict. That is a different question, and both answers are kept.

### Verdicts are never recomputed

A verdict is a record of a decision that was made, not a cache of a decision
that could be made now. `GET /api/v1/scans/{id}/verdicts` returning several
rows is normal and is the point: a scan judged under v1 and again under v2 has
two decisions, and the v1 result remains exactly as it was.

The policy version a verdict references cannot be deleted out from under it.

### A verdict explains itself

`FAIL` on its own tells a developer nothing they can act on. Every verdict
carries the policy's ID, name and version, the evaluation instant, a one-line
summary naming what failed, and **every rule outcome, fired or not**, with
its match count and threshold.

Rules that did not fire are reported too. A verdict listing only the reasons it
failed could not answer "what else was checked?", which is the question an
auditor asks about a pass. A passing verdict explains itself for the same
reason, especially the first time a policy is turned on.

Each fired rule quotes up to **20** of the triggering findings. The count is
exact; the sample is the worst few, and the API can list the rest. A verdict
carrying ten thousand finding references explains nothing while making every
stored decision enormous.

The quoted severity and title are those at evaluation time, deliberately. A
historical explanation still reads correctly after a CVE is re-rated, which a
bare ID would not.

### Truncation is bounded and reported

Evaluation caps at 10,000 findings and the verdict sets `truncated: true` when
the cap bites.

Because findings are sorted worst-first before the cap is applied, truncation
can only ever drop *less* severe findings. It cannot turn a `fail` into a
`pass`.

## Who may do what

| Permission | Human role | Grantable to an API key |
|---|---|---|
| `policies:read` | viewer and above | Yes |
| `verdicts:request` | member and above | Yes |
| `policies:manage` | admin and above | **No** |

`verdicts:request` is separate from `scans:read` because it **writes**: a
verdict is a persisted, immutable record. A read-only credential should not be
able to create records, even records derived entirely from data it can already
see.

`policies:manage` cannot be granted to a machine credential at all. A
compromised CI key that could both request a verdict and rewrite the policy it
is judged by is a build grading its own homework: the control does not degrade,
it collapses.

The cost is real and is stated rather than hidden: policy-as-code, where a
repository is the source of truth for rules and a pipeline applies them, is not
possible with an ordinary machine key today.

## Where to go next

- [Suppression](/concepts/suppression): what the three modes are
  reacting to.
- [The finding lifecycle](/concepts/finding-lifecycle): the statuses a
  rule can match on.
- [Tenancy and isolation](/concepts/tenancy): roles, scopes and what a
  key may never hold.
