Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scanning and the severity gate

With scanning enabled, every hosted publish is scanned, and promotion is refused above a severity. The one exception is a signature or SBOM attached to an image as an OCI referrer, which is a document and not an image; see Signatures and SBOMs. This page turns that on, shows what a refusal looks like, and explains how to read the scan evidence behind it. It ends with how to run scanning on a server that cannot reach the internet.

The commands assume the setup from the quickstart: a server at localhost:8080 and the bootstrap token in SINDRI_TOKEN.

Enable scanning

Scanning is off by default. It needs Trivy, which the -trivy release image ships. Use ghcr.io/spjdevops/sindri:<version>-trivy (or latest-trivy) in place of the plain image, and add this to sindri.yaml:

scanning:
  enabled: true

For Docker Compose, set SINDRI_VERSION in .env to the -trivy tag and keep Trivy’s cache on a volume. The Compose guide shows the volume. For Kubernetes, set image.tag to the -trivy tag and config.scanning.enabled. The Helm guide shows the values.

Each hosted publish then queues a scan job. The worker unpacks the image or package, runs Trivy, and attaches two documents to the artifact as evidence: a CycloneDX sbom and a Trivy scan report. The queue is the same one the garbage collector uses (see ADR 20), so a scan that fails is retried with backoff. A scan that can never succeed is not retried: an archive over scanning.maxUnpackedBytes or with an unsafe path, an index with too many, no scannable, or duplicate platforms, an index child of an unsupported type, and malformed job arguments all fail on the first attempt, and last_error names the cause. Only two outcomes are skipped rather than failed, because they are expected: a subject kind with nothing to scan, and a blob the publishing repository does not hold. Every key under scanning is in the configuration reference.

Turning scanning on does not scan what was published earlier. Those artifacts have no scan until something queues one, and what does depends on the protocol:

  • OCI: pushing the same manifest again queues a scan.
  • PyPI: uploading the identical file again queues a scan. A file that was deleted cannot be uploaded again, because a deleted filename is never reused.
  • npm: nothing. Publishing a version again is refused, so an existing version cannot be scanned later. A new version is a new artifact and gets its own scan.

To scan what is already published, use the re-scan route.

Refuse promotion above a severity

A scan gate sets a severity ceiling for a stage. Declare it next to the stages:

lifecycle:
  stages: [dev, prod]
  gates:
    prod:
      - scan: {maxSeverity: high}

maxSeverity is a ceiling: critical, high, medium, or low. The ceiling high allows findings rated high and lower, and refuses a critical one. The ceiling low refuses everything rated medium or above. A finding that Trivy does not rate (UNKNOWN) is refused at every ceiling, because the gate cannot tell it is safe.

The gate reads the newest scan that Sindri itself made, for each platform of the subject. For an image index, every platform in the index must have a scan. A scan you attach yourself, with POST /subjects/{digest}/evidence, still satisfies a presence gate such as sbom, but the severity gate ignores it. Only the worker can mark evidence as its own, so nobody who can publish can produce a clean scan. ADR 29 and ADR 30 give the reasoning.

To see it work, publish an old image and try to promote it. alpine:3.10 carries a critical finding in Trivy’s database as this page was written:

echo "$SINDRI_TOKEN" | docker login localhost:8080 -u admin --password-stdin
docker pull alpine:3.10
docker tag alpine:3.10 localhost:8080/scan/old:1
docker push localhost:8080/scan/old:1
DIGEST=$(curl -fsSI -u "admin:$SINDRI_TOKEN" \
  -H 'Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \
  localhost:8080/v2/scan/old/manifests/1 \
  | tr -d '\r' | awk -F': ' 'tolower($1)=="docker-content-digest" {print $2}')
echo "$DIGEST"

The scan runs in the background, so wait for the scan evidence to appear before you promote. This polls for up to two minutes, longer than a small image needs once the database is cached:

for _ in $(seq 1 60); do
  n=$(curl -fsS -H "Authorization: Bearer $SINDRI_TOKEN" \
    "localhost:8080/api/v1/subjects/$DIGEST/evidence" \
    | jq '[.items[] | select(.type == "scan")] | length')
  [ "$n" -gt 0 ] && break
  sleep 2
done
echo "scans: $n"

A subject with no scan yet is refused, the same as one with a bad scan. Now promote:

curl -sS -X POST -H "Authorization: Bearer $SINDRI_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"repository":"scan","stage":"prod","reason":"try the severity gate"}' \
  "localhost:8080/api/v1/subjects/$DIGEST/promote" | jq .

The server answers 409 Conflict with code GATE_FAILED. The violations list names each rule that failed, the platform when the subject has one, and the findings above the ceiling:

{
  "code": "GATE_FAILED",
  "message": "promotion to prod refused: scan.max_severity=high: findings above the ceiling: CVE-2021-36159 CRITICAL",
  "request_id": "c8b7cda5d42367d73f26d5e00778564b",
  "violations": [
    {
      "rule": "scan.max_severity=high",
      "findings": [{"id": "CVE-2021-36159", "severity": "CRITICAL"}]
    }
  ]
}

The message names at most ten findings and then counts the rest; violations lists them all. A subject with a platform that has findings also carries "platform": "linux/arm64" (or whichever platform it is) on that violation. When the gate refuses for lack of evidence instead, the violation has a reason and no findings:

reasonCause
no Sindri scan for sha256:...The scan is queued, failed after its retries, or the artifact predates scanning.
scan incomplete: no Sindri scan for platform linux/arm64One platform of an index has no scan: the job is still running, or it failed part way.
scan incomplete: no Sindri scan for the index child without a platformThe same, for an index child that declares no platform.
the Sindri scan <id> lists no vulnerabilities; it needs a new scan, ...A scan written before the gate existed. Pushing it again (OCI) or uploading it again (PyPI) queues a new scan, and the re-scan route does it for any artifact, npm included.
the Sindri scan <id> does not list the platforms of its index; it needs a new scan, ...A scan of an index child written before the gate existed. The same applies.

A refusal writes no event to the ledger. A promotion that passes records the ids of the scan and presence evidence it evaluated, in evidence_ids on the event, so an audit can show exactly which scan the decision rested on. Read them with GET /api/v1/subjects/{digest}/events or GET /api/v1/audit. A later scan never rewrites a decision that was already made.

Read the evidence

Evidence is listed per artifact. Each item carries the metadata the worker wrote:

curl -fsS -H "Authorization: Bearer $SINDRI_TOKEN" \
  "localhost:8080/api/v1/subjects/$DIGEST/evidence" \
  | jq '.items[] | select(.type == "scan") | {id, media_type, created_at, metadata}'
{
  "id": "3670f7f3-ea62-491e-8398-4fe4cb6b44a8",
  "media_type": "application/vnd.aquasec.trivy.report+json",
  "created_at": "2026-11-11T09:41:07Z",
  "metadata": {
    "producer": "sindri",
    "scanner": "trivy",
    "scanner_version": "0.76.2",
    "db_updated_at": "2026-11-10T18:34:12.5Z",
    "severity_counts": {"CRITICAL": 1, "HIGH": 0, "MEDIUM": 0, "LOW": 0, "UNKNOWN": 0},
    "vulnerabilities": [{"id": "CVE-2021-36159", "severity": "CRITICAL", "package": "apk-tools", "installed": "2.10.6-r0", "fixed": "2.10.7-r0"}],
    "new_vulnerabilities": ["CVE-2021-36159"],
    "coverage": "image"
  }
}
KeyMeaning
producersindri on evidence the worker wrote. The severity gate reads only this.
scanner, scanner_versionThe scanner and its version.
db_updated_atWhen the vulnerability database the scan used was built. See Keep the database fresh.
severity_countsFindings per severity.
vulnerabilitiesEach finding as id, severity, and the package with its installed and fixed versions (fixed is empty when no fix exists), worst first. On scan rows only; the sbom row omits it. Scans written before re-scanning exist have only id and severity.
new_vulnerabilitiesThe ids in this scan that the previous Sindri scan of the same subject and platform did not list. Absent on a first scan, and when the previous scan predates the vulnerabilities list (an older scan has no list to compare with). See Re-scanning.
coverageimage for an OCI image, package for a wheel, sdist, or npm tarball.
platformThe platform of an index child, such as linux/arm64. Absent on a single image.
platformsOn an index child’s scan, every platform the job scanned. The gate requires a scan for each.

The full report and the SBOM are the evidence documents themselves. GET /api/v1/subjects/{digest}/evidence/{id} returns the bytes. The web UI shows the same evidence on the artifact’s page. Each Sindri scan row there also shows its findings per severity, worst first, and its platform, or “no findings”. A scan a client attached shows no summary, because the page only repeats what Sindri itself found. Below the evidence, a Vulnerabilities panel lists the findings of the newest Sindri scan of each platform: id, severity, package, installed version, and fixed version. A finding the previous scan did not list carries a new marker. The panel shows the first 500 findings of a scan and says how many it left out; the full report is the evidence document.

Prometheus series describe the worker (see Operating Sindri): sindri_scans_total{result} counts scan job attempts as succeeded, failed, or skipped, and sindri_scan_duration_seconds times them. Both exist only while scanning is on. sindri_queue_jobs{state="failed"} rises when a scan has used up its retries or failed permanently. That artifact then has no Sindri scan and a severity gate refuses it.

Re-scanning

A scan describes the vulnerabilities known on the day it ran. An approved artifact keeps running long after that, so Sindri scans it again. ADR 31 has the reasoning. In short:

  • Only approved artifacts. Every subject with a current approve decision, in any stage, is scanned again. Artifacts nobody approved are not.
  • Daily by default. scanning.rescanInterval is 24h. Set 0s to turn the schedule off; the on-demand route below still works. Values under 1m are refused.
  • The ledger does not change. A re-scan adds evidence and nothing else. It never revokes and never rewrites a decision already made.
  • A new finding blocks the next promotion only. The severity gate reads the newest Sindri scan, so an artifact with a new CRITICAL finding cannot be promoted further, but where it already runs is untouched.
  • Revoking is a person’s call. Sindri shows the finding, in the evidence, the Vulnerabilities panel, and a metric, and a person decides. It does not take production down over a CVE that may have no fix.

A scan reads the artifact from the lowest-named hosted repository that owns it and still holds it, so an artifact copied to another repository and deleted from the first is scanned from the other. An approved artifact no hosted repository holds is left out. Each re-scan is one Trivy run per approved artifact, so cost follows what is approved, not everything ever published.

Re-scan one artifact now

POST /api/v1/subjects/{digest}/scan queues a scan of one artifact. It needs write access to a hosted repository that holds it. It answers 202 Accepted, and the same job if a scan of that artifact is already queued or running. An administrator gets the full job (attempts, last_error) and a Location header for GET /api/v1/jobs/{id}, which only administrators may read. Anyone else gets only {"id", "kind", "state"} and no Location. Errors:

StatusCodeWhen
404SUBJECT_NOT_FOUNDThe caller cannot read the artifact.
403FORBIDDENThe caller can read it but not write it.
409SCANNING_DISABLEDScanning is off on this server.
409NO_HOSTED_REPOSITORYNo hosted repository the caller may write holds the artifact.

This block scans the image from the section above again, waits for the new scan, and prints the ids that scan found and the previous one did not. It prints [] while the database has not changed. After the vulnerability database is updated, a published CVE shows up here:

BEFORE=$(curl -fsS -H "Authorization: Bearer $SINDRI_TOKEN" \
  "localhost:8080/api/v1/subjects/$DIGEST/evidence" \
  | jq '[.items[] | select(.type == "scan")] | length')
curl -fsS -X POST -H "Authorization: Bearer $SINDRI_TOKEN" \
  "localhost:8080/api/v1/subjects/$DIGEST/scan" | jq -c '{id, kind, state}'
for _ in $(seq 1 60); do
  EVIDENCE=$(curl -fsS -H "Authorization: Bearer $SINDRI_TOKEN" \
    "localhost:8080/api/v1/subjects/$DIGEST/evidence")
  n=$(echo "$EVIDENCE" | jq '[.items[] | select(.type == "scan")] | length')
  [ "$n" -gt "$BEFORE" ] && break
  sleep 2
done
echo "scans: $n"
echo "$EVIDENCE" | jq -c '[.items[] | select(.type == "scan" and .metadata.new_vulnerabilities != null)] | last | .metadata.new_vulnerabilities'

Watch for findings in approved artifacts

sindri_approved_findings{severity} is a gauge read at scrape time: the number of approved artifacts whose newest Sindri scan lists at least one finding of that severity. All five labels (CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN) are always present. It exists only while scanning is on. An alert for the one that matters:

- alert: SindriApprovedCriticalFinding
  expr: sindri_approved_findings{severity="CRITICAL"} > 0
  for: 1h
  labels: {severity: warning}

The operations guide carries it in its starting set.

A gauge tells whoever looks at it. To have Sindri tell someone the moment a re-scan finds something new in an approved artifact, configure a finding.new webhook; see Notifications.

Size the cache

Trivy keeps its vulnerability database in scanning.cacheDir. The -trivy image sets that to /var/cache/sindri/trivy. Scans also unpack each image or package into the same volume, so size it for two things:

  • The databases. The vulnerability database is about 130 MiB compressed and the Java database about 950 MiB compressed, both larger once unpacked. Trivy downloads the Java database only when a scan finds a jar.
  • The largest thing you scan. Each scan unpacks the whole image. A volume smaller than the largest image fails that scan, and the job is retried. For wheels and tarballs, scanning.maxUnpackedBytes (1 GiB by default) caps one archive.

Keep the cache on a volume that survives a restart, or Trivy downloads the database again each time. Compose and Helm both give the cache a place; their guides show it. scanning.timeout (ten minutes by default) cancels a scan that runs too long.

What scanning does not cover

  • It is off by default. Nothing is scanned until you set scanning.enabled.
  • Hosted repositories only. Content cached from an upstream through a proxy is never scanned. It has no subject of its own, and a proxy is a mirror of someone else’s artifacts (ADR 16, ADR 23).
  • Coverage differs by protocol. An image scan covers the OS and language packages installed in its layers. A wheel or npm tarball scan covers the package’s own name and version and anything pinned inside the archive, such as a bundled node_modules. It does not resolve the dependency ranges the package declares, so a clean scan of a wheel does not mean what pip install fetches beside it is clean. Teams that need that scan their lockfile in CI and attach the result for presence gates. Generic files are not scanned. ADR 29 has the detail.
  • Only Sindri’s scans count. The severity gate ignores evidence a client attached.
  • A missing scan refuses. A queued job, a failed job, or an artifact published before scanning was on has no Sindri scan, and the gate refuses it.
  • A scan is a point in time. A vulnerability published tomorrow does not change today’s scan or a decision made on it. Re-scanning scans approved artifacts again on a schedule, and POST /api/v1/subjects/{digest}/scan scans any one on demand, which is how to scan an npm version: npm will not accept the same version twice, so there is no other way to give it a newer database. Neither changes a decision already made.

Scan without internet access

Trivy fetches two databases from ghcr.io/aquasecurity: trivy-db for vulnerabilities and trivy-java-db for the Maven index it uses to identify jars. Both are ordinary OCI artifacts. An air-gapped install copies them into a registry it can reach and points Sindri at the copy.

Mirror the databases

Run this on a machine that can reach both ghcr.io and your mirror. It uses oras (the commands were run with oras 1.3.0) and any registry that accepts OCI artifacts. For a first try, this starts a throwaway one:

docker run -d --name trivy-mirror -p 127.0.0.1:5001:5000 registry:3
export MIRROR=localhost:5001

The mirror listens on port 5001 because macOS uses 5000 for AirPlay Receiver.

For a real mirror, set MIRROR to your registry’s host, and log in with oras login "$MIRROR" if it needs credentials. Then copy both databases. oras cp copies the manifest and layers as they are, and the tag you give is the tag Trivy asks for:

oras cp --to-plain-http ghcr.io/aquasecurity/trivy-db:2 "$MIRROR/trivy/trivy-db:2"
oras cp --to-plain-http ghcr.io/aquasecurity/trivy-java-db:1 "$MIRROR/trivy/trivy-java-db:1"

Drop --to-plain-http for a mirror that serves HTTPS. Trivy reaches a mirror over HTTPS unless its host is localhost, so a real mirror needs TLS. If its certificate comes from a private CA, set SSL_CERT_FILE in the server’s environment to a bundle that holds the CA; Sindri passes it on to Trivy.

Point Sindri at the copies. Give each as a full reference with its tag:

scanning:
  enabled: true
  dbRepository: mirror.example.com/trivy/trivy-db:2
  javaDbRepository: mirror.example.com/trivy/trivy-java-db:1

With these set, Trivy asks only the mirror. It no longer falls back to the public registries. Sindri passes the values to Trivy as --db-repository and --java-db-repository, and Trivy reads any registry credentials from the server’s Docker config.

The mirror covers the two databases only. Sindri always passes --skip-version-check and --disable-telemetry, so Trivy never checks check.trivy.dev for a newer version or sends telemetry, but during a scan it can still look packages up. On a server that can reach the mirror and nothing else, add offlineScan: true, which passes --offline-scan so Trivy makes no request of its own:

scanning:
  enabled: true
  dbRepository: mirror.example.com/trivy/trivy-db:2
  javaDbRepository: mirror.example.com/trivy/trivy-java-db:1
  offlineScan: true

Keep the database fresh

Aquasec publishes a new vulnerability database regularly. The mirror holds the copy you made, so it ages until you copy again. Run the two oras cp commands on a schedule from a machine that sees both registries. A cron entry or a Kubernetes CronJob that runs every six hours is enough. Sindri needs no restart: on its next scan Trivy checks whether its cached database is due for an update, and if so downloads from the mirror.

Every scan records db_updated_at, the build time of the database it used, so a stale mirror is visible on the artifacts it scanned. This prints the age in days of the newest scan of one artifact:

curl -fsS -H "Authorization: Bearer $SINDRI_TOKEN" \
  "localhost:8080/api/v1/subjects/$DIGEST/evidence" \
  | jq -r '[.items[] | select(.type == "scan")] | sort_by(.created_at) | last
           | .metadata.db_updated_at
           | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601
           | ((now - .) / 86400 | floor)
           | "database is \(.) days old"'

Alert on that age from your own tooling. A scan made against a month-old database is still a valid scan, and the gate does not look at its age. It will pass an artifact whose newest vulnerabilities the database does not know yet.

Or pre-seed the cache

If you cannot run a registry, fill the cache directly and tell Trivy never to download. On a machine with internet access, use the same Trivy version as the -trivy image (0.76.2 at the time of writing; the version is in scanner_version on any scan):

mkdir -p trivy-cache
docker run --rm -v "$PWD/trivy-cache:/cache" aquasec/trivy:0.76.2 \
  image --download-db-only --cache-dir /cache
docker run --rm -v "$PWD/trivy-cache:/cache" aquasec/trivy:0.76.2 \
  image --download-java-db-only --cache-dir /cache
tar -C trivy-cache -czf trivy-cache.tar.gz .

Carry trivy-cache.tar.gz across the gap and unpack it into the cache directory the server uses (/var/cache/sindri/trivy in the -trivy image). The server accepts only a cache directory with mode 0700, owned by the user it runs as, which is uid 65532 in the release image. With Docker, this fills a named volume that way:

docker volume create sindri-trivy-cache
docker run --rm -v sindri-trivy-cache:/cache -v "$PWD:/in:ro" alpine:3.20 sh -c \
  'tar -xzf /in/trivy-cache.tar.gz -C /cache && chown -R 65532:65532 /cache && chmod 0700 /cache'

Mount that volume at /var/cache/sindri/trivy. Then set:

scanning:
  enabled: true
  skipDBUpdate: true

skipDBUpdate cannot be combined with dbRepository or javaDbRepository, and the server refuses to start with both. With skipDBUpdate, offlineScan defaults to true, so Sindri also passes --offline-scan, and Trivy makes no request of its own while scanning. Write offlineScan: false to allow package lookups. Refresh the cache by repeating the steps. The Helm chart’s scan cache is an emptyDir, which is empty again when the pod is replaced, so use the mirror there.

Images with jars fail closed

Trivy loads the Java database only when a scan finds a jar. An air-gapped server with no Java database does not skip those files: the scan fails, retries, and runs out of attempts. That artifact has no Sindri scan, and a severity gate refuses it. This is the intended direction of failure, because a scan that quietly skipped the jars could report an image clean that is not.

It happens in two ways. With skipDBUpdate, the Java database is missing from the cache. With a mirror, javaDbRepository is unset, so Trivy tries the public registries and cannot reach them. Either way the fix is to supply the Java database. Watch for it in sindri_queue_jobs{state="failed"} and in sindri_scans_total{result="failed"}.

Clean up

If you started the throwaway mirror above:

docker rm -f trivy-mirror