---
title: "Assets and scans"
description: "What an asset is, why its identity is the image name rather than the digest, and what an accepted scan promises."
---

An **asset** is the thing being protected. A **scan** is one observation of it.
The distinction is what lets TRUSTIVAN say how long something has been
outstanding.

## Asset identity is the name, not the digest

For a container image, the thing being protected is "the production build of
this service", not one immutable blob. Identity is therefore
`registry/repository:tag`. A tag that names a commit is left out, so every commit
of an image is one asset:
[One asset per image](/integrations/github-actions#one-asset-per-image).

```text
index.docker.io/library/alpine:3.21     ← the asset. Stable across rebuilds.
  └── sha256:adab3844…                  ← what one scan looked at. Changes.
```

If identity were the digest, every rebuild would produce a brand-new asset.
Its findings would all look new, every triage decision would be discarded on
deploy, and "this critical has been open for 40 days" (the single most
valuable thing a vulnerability-management product says) would be
unrepresentable.

The tag is part of identity, deliberately. `myapp:staging` and
`myapp:production` are separately protected things, and `alpine:3.18` and
`alpine:3.21` are separately remediable. A digest-pinned reference carrying no
tag falls back to `registry/repository`, the most specific durable name
available.

The digest is still recorded: it is what a given scan actually examined, and
it is on the scan record.

### Upsert, not create

The full key is `(organisation, kind, identity)`, with a database uniqueness
constraint behind it. Requesting a scan of an image TRUSTIVAN has seen before
resolves to the existing asset rather than creating a second one.

The constraint is in PostgreSQL rather than in an application check because
two concurrent requests can both pass a `SELECT` before either `INSERT`s. A
webhook redelivery racing a user's click is not hypothetical, and the result
would be two assets for one image with its history split permanently in half.

### Identity carries no tenant

Two organisations scanning `alpine:3.21` get two asset rows carrying the same
identity string, and therefore the same fingerprints for the same CVE.

That is intentional. Isolation is enforced by `org_id` and scoped queries, never
by making identity unguessable. See [Tenancy and isolation](/concepts/tenancy).
Keeping identity portable is what makes "how many customers are affected by this
CVE" a query rather than a project.

## Image references are untrusted input

A scan makes outbound network requests on the caller's behalf, so the
reference is validated as a security boundary rather than formatted as a
convenience.

| Rejected | Why |
|---|---|
| `169.254.169.254/x:latest` | On AWS, GCP and Azure this address serves instance credentials to anything that asks |
| `10.0.0.5:5000/x:1`, `localhost:5000/x:1` | Would turn TRUSTIVAN into a port scanner and a reader of unauthenticated internal registries |
| `user:password@registry/x:1` | Embeds a secret in a string that reaches a database row, a job payload, a log line and an API response |
| `https://registry/x:1` | A scheme is not part of a reference; accepting one means accepting whatever a URL parser tolerates |
| `registry/../../etc/passwd:1` | Traversal segments must never reach a registry client or a cache path |
| Newline, space, NUL, leading `-` | Argument splitting, log injection, and a reference read as a flag |
| Over 512 characters | Resource exhaustion |

Private and loopback registries can be permitted, but only by a **deployment**
setting. It cannot be requested per scan, because the caller is the untrusted
party.

Images are pulled from the registry over the network. TRUSTIVAN does not consult
a local image store, use a Docker socket, or need a container runtime on the
worker at all. A reference matching an image the worker happened to have
locally would otherwise resolve to that image (possibly another tenant's) and
report its contents to whoever asked.

Registries requiring authentication are supported on Pro and Enterprise: store
a credential against the registry host and scans of images from that host
present it. The scan carries a *reference* to the credential rather than the
secret itself, so no registry password enters a job payload or a log line, and
a reference that cannot be resolved fails the scan rather than quietly
downgrading to an anonymous pull.

## A scan is an async, durable job

```bash
curl -s -X POST localhost:8080/api/v1/scans \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: build-4711" \
  -d '{"image": "alpine:3.19"}'
```

`202` means **work accepted, not work done**. Pulling and unpacking an image
takes seconds to minutes. `200` instead means an existing scan was returned, so
a client can tell a deduplicated retry from a new scan.

The scan row is committed before the response is written. The queue message
that follows is an optimisation for latency, not a step that can lose work: a
scan that was accepted is durable even if the queue drops the wakeup entirely.

| Guarantee | Mechanism |
|---|---|
| A retry does not queue a second scan | `UNIQUE (org_id, idempotency_key)` |
| Exactly one worker runs a claimed scan | `UPDATE … WHERE status = 'queued'` |
| One tenant cannot occupy every worker | Per-tenant concurrency limit from the plan: 1 / 5 / 20 |

Idempotency keys are scoped per organisation, never globally: a shared key
space would let one tenant's key suppress another tenant's scan.

The per-tenant limit is a throttle, not a quota. Work beyond it stays queued
and is dispatched as that tenant's running scans finish, so a tenant queueing
ten thousand images delays only themselves.

Poll `GET /api/v1/scans/{id}` until the status is terminal.

## Freshness is reported, and past a point it is enforced

A scan run against a stale advisory database reports "no vulnerabilities" with
exactly the same confidence as a correct one. There is no worse outcome for a
vulnerability scanner than a clean exit code and an empty report.

So the scan record carries `database_state` and the database's age, rather than
presenting a degraded result as a complete one. A moderately stale database
attaches a warning to the scan; a sufficiently old one **fails the scan
outright**.

Failing is the safe behaviour precisely because of reconciliation. A scan that
succeeded against unusable data would find nothing, and "found nothing" is how
TRUSTIVAN resolves findings, so a stale database would quietly close the entire
backlog. Refusing to produce that result is cheaper than repairing it.

## What a scan does to the findings

A completed scan is reconciled against what already exists on the asset, in one
transaction:

- A finding seen again keeps its row, its fingerprint and every decision
  recorded against it.
- A finding not seen, whose kind actually ran, is resolved by absence.
- A resolved finding seen again is reopened.
- A suppressed finding is never resolved by absence: the acceptance stands
  until its expiry returns it to the backlog.

The gating on "whose kind actually ran" matters. What ran is read from the
scan's own result, not from what the request asked for, because the two differ
whenever the engine declines a scanner it cannot run. Treating a scanner that
did not run as evidence of absence would silently close a customer's whole
backlog for that kind.

## Scope, stated plainly

TRUSTIVAN scans for **known vulnerabilities** in three kinds of target:

- **Container images**, pulled from a registry: public, or private with a
  stored credential on Pro and Enterprise. This is the default and the one
  every deployment can do.
- **Git repositories**, named by URL. The host must be on the deployment's
  allow-list.
- **Filesystem paths and SBOM documents**, and only inside a directory the
  operator has explicitly listed. **A deployment that lists none refuses both
  outright**, which is the correct default rather than a limitation: a
  filesystem target names a path on the worker, so accepting an arbitrary one
  would let any authenticated caller read the worker's own disk (its
  configuration, its credentials, other tenants' working directories) and
  receive the contents back as findings, because a secret scanner reports what
  it finds. There is deliberately no "unrestricted" setting. Each organization
  reaches only its own directory under a listed root,
  `<root>/<organization id>/…`, and the worker re-checks every path with its
  symlinks resolved before reading it, so a link out of that directory (to the
  worker's disk or to another organization's) fails the scan.

It does not scan infrastructure-as-code, virtual machines, cloud accounts or
Kubernetes clusters. `vm` and `cloud_account` exist in the scan contract and
are **not scannable by any shipped engine**: the contract is wider than the
capability on purpose, so an engine can be added without reshaping the API.

**Collecting a cloud account or a cluster is a separate subsystem, and it
ships.** It is not a scan and does not appear here: there is no scan row, no
target and no engine involved. `POST /api/v1/cloud/accounts` and
`POST /api/v1/kubernetes/clusters` connect one, and a six-hourly sweep re-reads
it. See [Cloud and Kubernetes](/configuration/cloud-and-kubernetes).

It **reads** an SBOM as a scan target where one is permitted, and it also
**writes** one: `GET /api/v1/assets/{id}/sbom` renders an asset's inventory as
CycloneDX 1.5 or SPDX 2.3, and `POST` to the same path imports one. Reading an
SBOM as a target and rendering an asset as an SBOM are genuinely different
features, and both now ship. See
[Import and export SBOMs](/how-to/import-and-export-sboms) and
[Find where a package is used](/how-to/find-where-a-package-is-used).

## Where to go next

- [Findings and identity](/concepts/findings): what a scan produces and
  how it stays recognisable.
- [The finding lifecycle](/concepts/finding-lifecycle): the states
  reconciliation moves findings between.
- [Quickstart](/getting-started/quickstart): the calls above, end to end.
