Clean-room Trivy-compatible BoltDB writer — design memo

Status: Implemented (Sprint 20260513_001 E2, Path B) Owner: Concelier / Implementer Counsel basis: docs/legal/decisions/trivy-db-builder-counsel-thread-airgap-export-reply.md

Purpose

Concelier emits a Trivy-compatible vulnerability DB (trivy.db + metadata.json) directly from its own canonical advisory store, with no dependency on the upstream aquasecurity/trivy-db builder. This memo records how the on-disk schema was derived and states the clean-room boundary that was observed, so the artifact’s provenance is auditable.

“Trivy-compatible” is used deliberately. No Aqua endorsement is implied.

Clean-room boundary (what was and was NOT used)

Per counsel (section 3, “code/expression versus interface/format/function”): copyright does not protect an idea, procedure, process, method of operation, or the format of data files used to exploit program functions. The schema was derived only from:

  1. Public Trivy documentation — the published descriptions of the Trivy DB (a BoltDB file containing vulnerability information aggregated from feeds such as NVD, Red Hat, and Debian) and the self-hosting / air-gap guidance.
  2. The documented BoltDB (bbolt) file format — a single-file, memory-mapped B+tree key/value store with a publicly documented page layout (meta pages, freelist page, branch/leaf pages, bucket headers).
  3. Black-box round-trip inspection — writing a DB with our own writer and parsing it back with an independently written reader (__Tests/.../Bolt/TrivyDbReader.cs) that does not share code with the writer under test, confirming the observable structure parses and a known advisory round-trips.

The following were NOT used and NOT copied: Aqua trivy-db builder source code, comments, documentation prose, table-generation logic, or non-essential naming. Only the observable interface/format (bucket names, key shapes, JSON field names, the integer severity scale) was reproduced — these are functional facts required for a Trivy reader to interpret the file, not protected expression.

BoltDB file layout produced

(All multi-byte integers little-endian; page size 4096.)

Page(s)Contents
0, 1Meta pages (magic=0xED0CDAED, version=2, pageSize, root bucket pgid, freelist pgid, high-water pgid, txid, FNV-1a checksum over the meta payload).
2Freelist page (empty — the writer never frees pages).
3…Branch/leaf pages, allocated bottom-up so child bucket page chains exist before parents reference them.

Implementation: src/Concelier/__Libraries/StellaOps.Concelier.Exporter.TrivyDb/Bolt/ (BoltDbFormat, Fnv64a, BoltBucket, BoltDbWriter).

Trivy-compatible schema (bucket map)

Bucket pathKeyValue
trivymetadataTrivyMetadata JSON (Version, NextUpdate, UpdatedAt, DownloadedAt).
vulnerability<vulnID> (CVE id preferred)Vulnerability detail JSON (Title, Description, Severity, References, CVSS, dates).
<data-source><package><vulnID>Advisory detail JSON (FixedVersion, VulnerableVersions, Severity, DataSource).

Implementation: TrivyDbSchema.cs.

Source-license allowlist + provenance

Each canonical record carries its source via Concelier provenance. The SourceLicenseAllowlist resolves each source to a disposition (see counsel section 4):

Each emitted record embeds a DataSource object (ID, Name, URL, License) for downstream provenance/audit.

Data artifact, not BUSL

The produced DB is a data artifact carrying the composite third-party data notice in third-party-licenses/DATA-NOTICES.md. It is not licensed under Stella Ops’ BUSL-1.1 software license. CC-BY / CC-BY-SA content must not be placed under additional downstream restrictions.

Verification

TrivyDbBoltBuilderRoundTripTests (black-box): build trivy.db, parse it with the independent TrivyDbReader, and assert (a) the structure parses as a valid BoltDB with the expected buckets, (b) a known advisory round-trips (write → read → same FixedVersion/Severity/DataSource), © Ubuntu CC-BY-SA is absent from the main DB and present in the BY-SA shard, and (d) reruns are byte-identical (deterministic).