31. Re-scanning approved subjects, and what a new finding does
Context
A scan describes the vulnerabilities known on the day it ran. An approved subject keeps running long after that, and a CVE published next month is invisible until something scans it again. M11b closes that gap without changing what approval means.
Decision
- What is re-scanned. Every subject with a current
approverow in thelifecycle_currentview, for any stage. A schedule (job kindrescan_approved) runs everyscanning.rescanIntervaland enqueues one ordinaryscanjob per approved subject, reusing the scan job’s dedupe keyscan:<digest>, so a scan already queued or running is not doubled. - Which repository the re-scan reads from. A scan job carries a repository and reads
only blobs that repository places (I2). The re-scan uses the lowest-named hosted
owner repository (from
subject_owners) that still places the subject, checked with the predicate ofCheckPlacement. Owner rows outlive a placement (only the collector removes them), so an owner that has since deleted the subject is passed over for the next one. A subject no hosted owner places is left out of the schedule. - The ledger is untouched. A re-scan only adds evidence rows. It never writes
lifecycle_events, never revokes, and never changes a decision already made. The next promotion’s severity gate reads the newest Sindri scan, so a new finding blocks future promotions only. - A new finding. A vulnerability ID present in the newest Sindri scan for a platform
and absent from the previous Sindri scan of the same subject and platform. The worker
computes it when it attaches the scan and writes the sorted IDs as
new_vulnerabilitiesin the scan evidence metadata. A first scan has no previous one, and a scan written before thevulnerabilitieslist existed (an M11a-era scan) has no list to compare with; neither carries anew_vulnerabilitiesfield. IDs are compared, not packages. - Findings carry package detail. Each entry of the metadata’s
vulnerabilitieslist gainspackage,installed, andfixed(Trivy’s PkgName, InstalledVersion, FixedVersion;fixedis empty when there is no fix). Entries are one per (id, package, installed version);severity_countskeep their ADR 30 meaning. Older scans without these fields stay valid. - The metric.
sindri_approved_findings{severity}is a gauge read at scrape time: the number of currently approved subjects whose newest Sindri scan (any platform) has at least one finding of that severity. The labels CRITICAL, HIGH, MEDIUM, LOW, and UNKNOWN are always present. - On-demand re-scan.
POST /api/v1/subjects/{digest}/scanenqueues a scan of one subject. It needs write on a hosted owner repository of the subject. A caller who cannot read the subject gets 404; one who can read it but not write it gets 403, the same as promote, revoke, and attach (all go throughrequireSubject). It answers 202 with the job (a scan already queued or running is returned instead of a second one); an administrator gets the full job and aLocationforGET /jobs/{id}, anyone else onlyid,kind, andstate; and 409 when it cannot run:SCANNING_DISABLEDwhen scanning is off, andNO_HOSTED_REPOSITORYwhen no hosted repository the caller may write holds the subject. It is the way to re-scan an npm version, which npm will not re-publish (docs/scanning.mdpromises this). - Config.
scanning.rescanInterval, a duration, default24h.0sdisables the schedule; the on-demand route still works. Values below1mand negative values are refused.
Consequences
- A re-scan costs one Trivy run per approved subject per interval. Cost follows what is approved, not the registry’s whole history.
- An approved subject with a new CRITICAL finding stays approved. The gauge, the new finding list, and the UI show it; a person decides what to do.
- Scan evidence grows by one row per subject per interval. Retention of evidence rows is a separate question and is not decided here.
- Metadata grows by the package fields; the gate still reads only
idandseverity.
Alternatives rejected
- Auto-revoke on a new finding. It rewrites what was approved and could take production down on a CVE that has no fix yet. Revoking stays a person’s call.
- A counter of new findings. It resets on restart and is awkward to alert on. A gauge answers “is something in production vulnerable right now”.
- Re-scanning every subject. Cost grows with history, and an unapproved artifact is not running anywhere.
- Diffing by package instead of ID. A package version bump that keeps the same CVE would look new, and one CVE reported against two packages would look like two.
- Putting the interval under
worker:. It only exists when scanning is on, so it belongs beside the other scanning settings.