<!--
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2026 ndaal Gesellschaft für Sicherheit in der Informationstechnik mbH & Co KG, Cologne
SPDX-FileCopyrightText: Author: Pierre Gronau <Pierre.Gronau@ndaal.eu>
-->
# Developer Guide — ndaal SBOM Auditor
Developer-facing notes on the SBOM Auditor's internals. For the project
structure see [structure.md](structure.md); for the full architecture see
[arc42/en/](arc42/en/01-introduction-and-goals.md); for the exhaustive option
and route tables see [REFERENCE.md](../REFERENCE.md). The sections below
document individual subsystems in depth.
## The Stored-SBOMs dashboard and search
The home page (`GET /`) is a filtered, sorted, paginated table of every stored
SBOM, each row carrying its single highest finding severity, with a free-text
search box over the inventory. Three modules cooperate: `src/routes/home.rs`
(the handler), `src/store.rs` (the SQL page query) and `src/search.rs` (the
full-text index). The data flow for one request is:
- `home()` reads and validates the query string.
- A non-empty `q` goes to the search index, which returns a bounded set of
matching SBOM ids.
- `Store::list_sboms_page` runs one filtered/sorted/paginated SQL query
(restricted to that id set when searching) and returns a `SbomPage`.
### Request parameters
`GET /` accepts six query parameters, each validated against a fixed vocabulary
— an unknown or malformed value falls back to its default rather than erroring:
| Parameter | Meaning | Default |
| ---------- | ---------------------------------------------------- | --------- |
| `sort` | Column: `name` / `format` / `components` / `created` | `created` |
| `dir` | Direction: `asc` / `desc` | `desc` |
| `format` | Restrict to one detected format | none |
| `severity` | Restrict to one highest-severity band | none |
| `page` | 1-based page number | `1` |
| `q` | Free-text search over the inventory | none |
Every link the page renders (sort headers, filter controls, pager) is rebuilt
from this state so it round-trips; only `q` is percent-encoded. The page size is
a fixed `PER_PAGE = 25`, not client-controllable, so paging cost is bounded
regardless of the request. A store read failure degrades to an empty dashboard,
never a `500`.
### The whitelisted sort — the SQL-injection boundary
The sort column is the one place a URL token influences `ORDER BY`, so it is
resolved through a fixed mapping rather than interpolated.
`SbomSort::from_token` turns the raw token into one of four enum variants (or
`None`, which the handler replaces with the default); `SbomSort::sql_column`
then maps that variant to a fixed physical column name:
```rust
// src/store.rs — SbomSort::sql_column
Self::Name => "original_name",
Self::Format => "format",
Self::Components => "component_count",
Self::Created => "created_at",
```
Only that `&'static str` — never the user's token — reaches the query string,
and `SortDir` maps to a literal `ASC` / `DESC` the same way. Every other value
(the format filter, the severity, the id hit set, `LIMIT` / `OFFSET`) is a bound
parameter, not interpolated text.
### Highest severity per SBOM
Each dashboard row shows the single most severe finding across all of the SBOM's
analyzer runs. `list_sboms_page` computes it with a `MIN(rank)` correlated
subquery over the SBOM's runs' findings, where the rank ladder is
`critical = 0 … unknown = 5` (`NULL` when the SBOM has no findings yet):
```text
(SELECT MIN(CASE f.severity
WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2
WHEN 'low' THEN 3 WHEN 'negligible' THEN 4 ELSE 5 END)
FROM analysis_runs r JOIN findings f ON f.run_id = r.id
WHERE r.sbom_id = sboms.id)
```
This ladder is the one `Severity` exposes as `rank()` / `from_rank()` (with
`badge()` for the UI class) in `src/findings.rs`, and the same ordering
`read_findings` uses, so the dashboard and the detail view agree on "highest".
The `severity` filter matches on the computed rank; sorting and paging run over
the derived `(row, sev_rank)` set, and `SbomPage` also carries the unpaged total
for the pager.
### The search module boundary
`src/search.rs` is a hardened wrapper around a tantivy index. `tantivy::` types
never escape it: callers see only `SearchDoc` (one SBOM as it enters the index),
`SearchIndex` (the handle) and a `Vec<i64>` of matching ids — a `TantivyError`
is mapped once into the module-local `SearchError` and never propagated. The
schema indexes `sbom_id` (the unique key), `name`, `format`, `spec_version` and
a joined component-names-plus-purls field, so "find every SBOM containing log4j"
resolves to the ids that carry that component.
### The total query path
`SearchIndex::search` is the untrusted-input boundary and is deliberately
*total* — it never errors and never panics; any failure yields an empty result:
- The query is trimmed and rejected if empty or longer than 1 KiB
(`MAX_QUERY_BYTES`), before any parsing.
- It is parsed with `parse_query_lenient`, so a malformed query degrades rather
than failing.
- Regex queries are never enabled (`allow_regexes` is never called), because an
attacker-chosen pattern over the term dictionary is a CPU / memory amplifier.
- The result window is clamped to `1..=MAX_HITS` (1000), bounding collector
memory regardless of the requested limit.
The handler feeds the returned ids straight into `SbomListQuery.ids`; an empty
hit set correctly renders the no-matches state, and the same filter, sort and
pagination then apply over the subset.
### The RAM index and the startup rebuild
The index is RAM-backed (`Index::create_in_ram`) — there is no on-disk index
directory, which removes that attack surface entirely. SQLite remains the source
of truth; the index is a derived copy:
- Built at start-up. `AppState::new` calls `rebuild_search`, which lists every
stored SBOM, builds a `SearchDoc` per row (reading its component text) and
replaces the index contents in one committed batch. It is best-effort: a
failure is logged and leaves search empty until re-ingest — it never blocks
start-up, because search is an accelerator, not a correctness dependency.
- Kept in sync. `AppState::reindex_search` re-indexes one SBOM after ingest or a
component recompute (via `SearchIndex::index_one`), and a delete calls
`SearchIndex::remove`. Both are best-effort and idempotent, so a stale search
entry can never fail an ingest or a delete.
Because the index lives only in RAM, restart cost scales with the store size and
there is nothing extra to back up — an operational note repeated in the
[Administrator Guide](Administrator_Guide.md#search-index).
## Vulnerability enrichment
After an analysis finishes, `enrich_sbom_findings` (`src/enrichment.rs`)
annotates each finding by CVE with three exploitation signals — EPSS, CISA-KEV
and a nuclei public-template flag — fetched from a configured vulnlookup
service. Enrichment is on by default and is the auditor's only unattended
outbound path. Three concerns stay separate: the wire DTO that parses the
response, the mapping into the internal model, and the cache that fronts the
network.
### Parsing the response at the boundary
The `/enrichment` response is parsed once, into DTOs that never leave the
module. The live shape is `{"enrichments": {"epss", "cisa-kev", "nuclei"}}`,
mirrored by `EnrichmentDto` → `Enrichments` → `EpssDto` / `KevDto` /
`NucleiDto`. The wire name `cisa-kev` is bound with
`#[serde(rename = "cisa-kev")]`, and every field is optional, so a partial or
extended payload degrades to fewer signals instead of failing. The nuclei block
is a boolean flag plus an optional severity string — there is no template id —
and EPSS carries a probability and percentile only, with no wire timestamp.
`dto_to_enrichment(cve_id, dto, source_base, fetched_at) -> CveEnrichment` is
the sole mapping from a parsed DTO to the internal model. It un-nests
`enrichments`, clamps each EPSS float into `[0, 1]` with `clamp_unit` (a `NaN`
or infinity becomes `None`), and sets `source_url` to the CVE's record link,
`{source}api/v1/vulnerability/{cve}`. The endpoint URL itself is built by
`enrichment_url`, which appends `api/v1/vulnerability/{cve}/enrichment` to a
`/`-terminated source, so each configured source is combined with its own TCP
port. The QUIC port is stored but reserved for a future HTTP/3 transport; the
current TCP path ignores it.
### Source order, first answer wins, and the cache
The client walks the configured sources in order: the first `2xx` that parses
wins, and a `404` is a definitive "no data" answer that ends the walk for that
CVE. Lookups are cached in the `cve_enrichment` table (schema v7) and are
cache-first — a CVE whose cached row is younger than `ENRICHMENT_TTL_SECS`
(86,400 s, i.e. 24 h) is served from the cache and never re-queried. Lookup
concurrency is clamped into `1..=MAX_LOOKUP_CONCURRENCY`, so a zero or oversized
setting can neither deadlock nor flood a source.
Findings are ordered — for both the UI and the exports — by
`enrichment_ordering` (`src/export.rs`): KEV-known first, then descending EPSS
percentile (a missing percentile sorts last), with ties left in analyzer order
by a stable sort. A report with no enrichment therefore renders exactly as the
analyzer produced it.
### Test coverage of the parse boundary
The parse boundary is the untrusted-input surface, so it is fuzzed and
property-tested:
- **Fuzz.** `fuzz/fuzz_targets/fuzz_enrichment_parse.rs` drives arbitrary bytes
through the DTO parse and `dto_to_enrichment`, seeded from the real
`fuzz/corpus/fuzz_enrichment_parse/` fixtures (Log4Shell and an EPSS-only
record); it must never panic.
- **Property.** The `proptest!` block in `src/enrichment.rs` covers the total
helpers — `clamp_unit` (any float, `NaN` and infinities included, yields
`None` or a value in `[0, 1]`), `dto_to_enrichment`, `is_safe_cve_id`,
`normalise_source` and `source_base_with_port`.
- **Fixtures.** Unit tests map two real vulnlookup samples end to end —
`tests/fixtures/enrichment/cve-2021-44228.json` (KEV, a critical nuclei
template, near-certain EPSS) and `cve-2005-2541.json` (no nuclei) — and assert
the echoed CVE never renames the finding row.
## CSAF drafts from audit findings
GitLab work item #2 adds a **Create CSAF document** action: one SBOM's audit
findings become a draft CSAF 2.1 advisory that is filed with a csaf-crud
service. The draft generator (`src/csaf`), the **CSAF upload** settings, the
upload client (`src/csaf_upload.rs`), the routes and result page
(`src/routes/csaf.rs`) and the `--export-csaf` command-line option implement
it.
### The modules
- **`src/csaf/builder.rs`** is shared with the export. `TrackingStatus`
(`Final` for the export, `Draft` here) sets `tracking.status`,
`tracking.version` and the first revision number together, as `final` /
`1.0.0` or `draft` / `0.1.0`, because OASIS tests 6.1.16 and 6.1.17 fail on
any other pairing. `PublisherInput::from_settings` is the one mapping from
the stored settings to the publisher block.
- **`src/csaf/draft.rs`** is the boundary. `generate_draft` reuses the export's
`build`, so merging, scoring and the coverage disclosure are identical, and
adds the checks that make a document safe to hand to a third-party CSAF
service:
- a never-analysed SBOM is `DraftError::NotAnalysed`, never an informational
advisory that reads as "no vulnerabilities";
- every text field is trimmed, bounded and free of control characters (NUL,
ESC and NEL are refused; tab and newline pass);
- CVE ids are upper-cased and must match `CVE-YYYY-NNNN…`; an implausible
package URL is dropped rather than published;
- `DEFAULT_DRAFT_LIMITS` caps a draft at 20,000 findings, 16,384 bytes per
field and 32 MiB of text in total; `generate_draft_with` takes other limits
for tests.
- **`src/csaf/gather.rs`** reads the store. `draft_for_sbom` takes the newest
run per tool and uses it only when it is `Ok`, the same rule as the export,
through `analyzer::latest_runs_in`. Unlike `latest_runs_per_tool`, that
function returns store errors instead of an empty list, because an empty
list would read as "never analysed" or, worse, as clean. The document's
clock is the SBOM's `created_at`, so the download, the upload and the
command line all produce the same bytes for the same SBOM.
The tracking id is `ndaal-sba-draft-` followed by the first 16 hex digits of
the SBOM's SHA-256, so one SBOM always yields the same id and two instances
filing different SBOMs with one csaf-crud never overwrite each other. An SBOM
with findings becomes a `csaf_security_advisory` that lists only the affected
components; one without findings becomes a `csaf_informational_advisory`.
### The upload client
`src/csaf_upload.rs` files one draft with csaf-crud. `CsafUploader::upload`
walks the configured endpoints in order (at most three) and `classify` decides
each step from the method and the status:
| Request | Status | Step |
| --- | --- | --- |
| `POST /api/v1/csaf` | 200, 201 | `Created`: done |
| `POST` | 409 | `RetryAsPut`: `PUT /api/v1/csaf/{id}` on the same endpoint |
| `PUT` | 200, 201 | `Updated`: done |
| `PUT` | 404 | `Vanished`: stop |
| either | 400, 422 | `Rejected`: the document is bad; stop |
| either | any other, or a transport error | `NextEndpoint`, with a fresh `POST` |
The report records every attempt. `rejection_details` reads csaf-crud's 422
`errors[]` and 400 problem+json, at most 20 entries of 512 bytes each with
control characters stripped, and nothing for any other status or shape, so a
WAF's HTML page is never echoed as a reason.
`upload_with_excerpts` (crate-private) returns the same report together with
one excerpt per attempt, in order: a separate, display-only reading of the
same body. It is `None` when no response came back or the status was a 2xx
(whose body is never read), otherwise `response_excerpt(body)`. That is lossy
UTF-8 with control characters removed, whitespace runs collapsed to one
space, trimmed, and cut to `MAX_EXCERPT_CHARS` (512) characters with `…`
appended; an empty body stays `Some("")`, because a bare `403` is the
diagnostic. The excerpts ride beside the report rather than in `Attempt`, and
a walk that stores nothing still ends `Unreachable`, so `Attempt`,
`UploadOutcome` and `upload` keep their 1.6.33 shape and
`cargo semver-checks` sees a patch release. The failover order is unchanged,
and a later `Created`, `Updated`, `Rejected` or `Vanished` still wins.
- **Time.** 5 s to connect and 15 s per request. With three endpoints of a
`POST` and a `PUT` each, `WORST_CASE_UPLOAD` is 90 s; a `const` assertion in
`src/main.rs` fails the build if that ever reaches the server's 120 s
`REQUEST_TIMEOUT`, which would turn a slow upload into a `408`.
- **Bodies.** A 2xx body is not read at all, so a stored document can never
turn into a failover; any other body is capped at 64 KiB. Redirects are not
followed.
- **TLS.** The strict client is TLS 1.3 over `enrichment::system_roots()`,
that is, the shared trust-store reader. The lenient client exists only when
`csaf_trust_loopback_self_signed` is on and is picked only for a loopback
URL. It connects to `localhost` by address: `pin_localhost` rewrites the
host to `127.0.0.1` and sends the original authority as `Host`, so the
resolver never decides where a trusted-anyway certificate comes from.
`LoopbackOnlyVerifier` then accepts only a loopback IP address as the server
name, refuses every DNS name, still verifies the TLS 1.3 handshake signature
and refuses TLS 1.2.
- **Paths.** An endpoint URL keeps only its scheme, host and port, as the
enrichment sources do, so a csaf-crud behind a reverse proxy at a sub-path
is not supported.
Its 104 tests run against a scripted fake transport and against a loopback TLS
server (`src/test_tls_server.rs`, shared with the enrichment tests), plus
property tests and the `fuzz_csaf_crud_response` target (7 seeds). Mutation
testing of the failover, `classify`, the loopback checks, `pin_localhost`,
`rejection_details`, `error_chain` and `response_excerpt` left no surviving
mutant.
### Routes, result page and command line
`src/routes/csaf.rs` serves `GET /sbom/{id}/csaf/draft.json` and
`POST /sbom/{id}/csaf/upload`; `--export-csaf` lives in `src/cli.rs`
(`csaf_export_request`, `parse_sbom_id`) and `src/main.rs`
(`run_export_csaf`). All three take their bytes from `draft_for_sbom`, so the
download, the upload and the CLI agree byte for byte.
`run_csaf_upload_request` is the upload's decision point, and its order is
the contract: same origin (`403`), a known SBOM (`404`), a draft that can be
generated (`409` not analysed, `422` invalid), at least one configured
endpoint (`502` otherwise). Only then is `make_transport` called. It is a
parameter, so `tests/test_csaf.rs` passes a scripted transport and a counter,
and every refusal asserts that no transport was built and nothing was sent.
A transport that cannot be built answers `500`.
| Outcome | Status | Page |
| --- | --- | --- |
| `Created`, `Updated` | `200` | success |
| `Rejected` | `422` | csaf-crud's reasons, escaped by askama |
| `Vanished`, `Unreachable`, `NoEndpoints` | `502` | warning or danger |
`report_view` reads an `Unreachable` walk with at least one `403` among its
attempts as refused: `502`, danger, `csaf.outcome_refused`. csaf-crud never
answers `403` on its API, so a `403` is the front end in front of it. Every
other outcome keeps its `outcome_view`, so a draft stored, rejected or
vanished after an earlier `403` reads as such. Mutation testing of
`report_page`, `report_view`, `was_refused` and `with_excerpt` left no
surviving mutant.
`csaf_result.html` has no `<script>`, so the CSP hashes are unchanged, and
every table header carries `scope="col"`. `attempt_row` appends the excerpt
to the result cell after the status line, as
`HTTP 403 Forbidden — Response: <excerpt>`, with the label from
`csaf.col_response` and the translated `csaf.empty_body` marker for an empty
body; askama escapes the cell, never `|safe`.
The browser suites never reach a real CSAF service. Bruno's `sbom-csaf/04`
points all three endpoints at `https://127.0.0.1/` on the closed ports 1, 2
and 3, `05` reads them back and sets `csaf_endpoints_closed`, and every
upload request's pre-request script throws unless that variable is `yes`; a
request whose script throws is not sent. `10` restores the defaults. The
folder sorts after `sbom/`, whose `09-analyze-start` gives SBOM 1 its runs.
Playwright's `13-csaf-draft.spec.ts` sets and reads back the same closed
ports before its one upload click and restores the endpoints in `afterAll`;
it reads the download through `page.request` because the config keeps
`acceptDownloads: false`.
The CLI is covered by process-contract tests in `tests/cli_contract.rs`
against the built binary: an empty data directory stays empty, stdout and
`--csaf-output` are byte-identical to the download, and a missing output
directory creates nothing. `parse_sbom_id` has a property test: every id from
1 to `i64::MAX` round-trips, and any string holding a non-digit is refused.
Mutation testing (`cargo mutants`) of `src/routes/csaf.rs`, of
`csaf_export_request` and `parse_sbom_id`, and of the export functions in
`src/main.rs` left no surviving mutant. Two tests exist for that reason:
`the_routed_upload_handler_refuses_a_cross_origin_post` drives `csaf_upload`
over a real HTTP/1.1 connection, because only `Router::handle` can call a
body handler and it needs a `hyper::body::Incoming`; and the result-page
tests pin the alert class, so a failure cannot render as a success notice.
### Two conformance fixes that also change the export
Both surfaced while the draft was validated against the OASIS `basic` preset:
- An informational advisory used to emit `"product_tree": {}` and no
external reference. It now omits an empty product tree and, for the
informational category only, references the project homepage (test
6.1.27.2).
- A vulnerability no analyzer described had no `notes` (test 6.1.27.5). It now
gets a fallback note, `<id> was reported by the analysis; the analyzer
supplied no description.` The regression pin
`an_unenriched_cve_serialises_exactly_as_before` was updated on purpose.
### Tests
- **Conformance.** Every draft variant (security, informational, partial tool
coverage, enriched, undescribed, CVSS 4.0) is loaded with the `csaf-rs`
dev-dependency and validated with
`validate_by_preset(&loaded, "2.1", "basic")`.
- **Boundaries.** One unit test per `DraftError` case and per limit, at N and
N+1, including a multibyte character on the field limit.
- **Properties** (`src/csaf/draft/proptests.rs`): never panics, round-trips
through JSON, is always `draft`, never repeats a CVE (6.1.23), lists only
components that are referenced, references only products that exist, and
emits a well-formed tracking id. The literal "one vulnerability per finding"
invariant is impossible under 6.1.23; the tested invariant is one
vulnerability per distinct merge key.
- **Snapshot.** `src/csaf/snapshots/…csaf_draft_2_1.snap` pins a whole draft.
`*.snap` is gitignored here, so stage a new one with `git add -f`.
- **Fuzz.** `fuzz/fuzz_targets/fuzz_csaf_generator.rs` (7 seeds) feeds a JSON
envelope to `generate_draft`; an `Ok` must be valid draft JSON.
- **Compile-time.** `DraftError` and `DraftFailure` are pinned to the error
contract in `tests/static_assertions_invariants.rs`.
### Adding a setting
The CSAF upload card (phase b) touched every place a setting lives; a new
setting needs the same list or a test fails:
- `src/store.rs`: the `Settings` field, its default, and its row in
`STR_FIELDS`, `U64_FIELDS` or `BOOL_FIELDS`.
- `src/routes/settings.rs`: parse it in the form handler, reusing
`optional_https_url`, `parse_port` or `checkbox`; keep each function at 50
lines or fewer.
- `src/templates/pages/settings.html`: the field, with its help text.
- Every one of the 49 tables in `src/i18n_data/` for each new key;
`csaf_strings_are_defined_in_every_language_table` checks the CSAF ones.
- `tests/test_routes.rs` (`SETTINGS_FIELDS`, `VALID_SETTINGS_FORM`) and the
Bruno request `test/bruno/collections/settings/03-save-happy.bru`, plus a
Bruno case for each new `422`.
## The analyzer version probe
Before a scan, `run_one_tool` starts the tool once with its version argument
(`probe_tool`, bounded by `PROBE_TIMEOUT`, 15 s). The outcome is a
`ProbeOutcome`, and `probe_verdict` maps it to what the run does:
| `ProbeOutcome` | `ProbeVerdict` | Recorded as |
| --- | --- | --- |
| `NotFound` | `Skip` | `<tool>: not found on PATH` |
| `SpawnFailed(error)` | `Fail` | `<tool>: could not be started: <error>` |
| `TimedOut(deadline)` | `Fail` | `<tool>: version probe did not answer within 15s` |
| `Present { version }` | `Run` | the scan runs; the version is stored |
Only a genuinely absent binary is a `skip`. Until 1.6.33 the three failure
outcomes were folded into one boolean and all recorded as `not found on PATH`,
which hid the cause of the load-time failures described under
[Testing against stub tools](#testing-against-stub-tools). The `/tools`
inventory page still shows `Present` as a plain yes or no.
## The OS trust store: one reader
`src/trust_store.rs` is the only caller of
`rustls_native_certs::load_native_certs`. Every outbound HTTPS client gets its
roots from `trust_store::system_roots()`: the enrichment client (through
`enrichment::system_roots`), the self-updater, and the CSAF upload client.
On macOS the load enters Security.framework, which is not safe
to enter from several threads at once. Concurrent loads crashed the 1.6.27
server, and measured under load they come back empty: at a load average of
400, 102 of 120 concurrent loads returned no certificate, against 0 of 30
serial ones. The self-updater used to load on its own, outside the lock, and
raced the enrichment client; that race was the flaky
`system_roots_are_loaded_once_and_shared_across_threads` test.
- `RootsCache::get_or_load` holds the lock across the load, caches a success
and never caches a failure.
- An empty store is an error that quotes up to three of the operating
system's own errors.
- `only_this_module_reads_the_os_trust_store` scans `src/` and fails the build
if any other file calls `load_native_certs(`. Do not add a second loader;
call `system_roots()`.
- The once-and-shared property is tested with a stub loader and eight racing
threads, asserting one load, at most one thread inside the loader, and one
shared store. The real trust store is not needed for that, so the test no
longer depends on how busy the host is.
## Testing against stub tools
`tests/test_analyze.rs` replaces the analyzers with two-line shell scripts.
Two conventions keep that suite deterministic:
- **`write_stub` runs every stub once before returning it.** macOS assesses a
freshly written executable on its first start (`syspolicyd`, triggered by
the `com.apple.provenance` attribute every new file carries). Measured on a
loaded host, that first start took 9 seconds and the second 0.2 seconds;
under heavy load the stub was still asleep, unstarted, when the 15-second
version probe killed it, and 8 of 8 suite runs failed. Priming moves that
one-time cost outside every deadline. A test that writes its own stub and
probes it must prime it the same way.
- **`assert_run_status` prints why.** It reports the run's `skip_reason` and
`stderr_text` with the status, so a failure names its cause instead of only
`left: Fail, right: Ok`.
To reproduce a load-dependent failure before fixing it, run the compiled test
binary several times in parallel next to CPU burners, and keep the logs:
```bash
BIN=$(ls -t target/debug/deps/test_analyze-* | grep -v '\.d$' | head -1)
for k in $(seq 1 48); do (exec yes > /dev/null) & done
for i in 1 2 3 4 5 6 7 8; do "$BIN" > "run_$i.log" 2>&1 & done
wait %49 %50 %51 %52 %53 %54 %55 %56
pkill -x yes
grep -h -o 'stderr=.*' run_*.log | sort | uniq -c
```
The fix for the stub suite was accepted only after the same run went from 8
of 8 failing at a load average of 50 to 8 of 8 passing at 190 to 210.
## Benchmarks and the regression gate
Two Criterion bench targets measure the CPU-bound paths:
- `benches/parsers.rs`: the format sniffer and three analyzer-output parsers
(grype JSON, SARIF, ScanCode), 64 records each.
- `benches/csaf.rs`: `generate_draft` at 100 findings and at
`DEFAULT_DRAFT_LIMITS.max_findings` (20,000), the largest draft the auditor
builds, and `rejection_details` on a typical csaf-crud 422, on a 422 at the
64 KiB body cap and on a WAF's HTML page answered as 400. Before measuring,
each draft fixture is checked to produce a draft, so a fixture the boundary
rejects can never pass off the fast error path as a speed-up.
Run one target with `cargo bench --bench csaf`. `cargo test --all-targets`
runs every benchmark once as a smoke test, which proves only that it runs.
`tests/scripts/test_cargo_bench.sh` is gate 30 of `scripts/quality_gates.sh`
(a live gate, skipped by `--fast`, because the bench profile is a full
release build). It runs every bench target and compares each benchmark with
a baseline saved on the same host:
- The first run, or a run after `target/` was cleared, records the baseline
(`--save-baseline sba-main`) and says so; there is nothing to compare yet.
- Later runs compare with `--baseline-lenient sba-main`. A benchmark fails
the gate when the whole 95 % confidence interval of its mean change lies
above +15 %. A point estimate above the threshold whose interval reaches
below it is load noise, not evidence of a slowdown. A benchmark added
since the baseline was saved is listed as such and not compared.
- `--threshold PCT` and `--baseline NAME` (or `SBA_BENCH_THRESHOLD_PCT`,
`SBA_BENCH_BASELINE`) change the defaults; after an intended slowdown,
re-record with `--save-baseline`.
- Exit codes: 0 passed, recorded or no bench target; 1 `cargo bench` failed,
a regression, or an unreadable estimate; 64 a usage error.
- Each run writes `stdout.log`, `changes.tsv` (one line per benchmark: mean
change, interval bounds, verdict) and a copy of `target/criterion/` to
`documentation/rust/perf/cargo-bench_<timestamp>/`.
Baselines are machine-local on purpose: an absolute timing from another host
compares nothing. They also compare only under similar host conditions.
Measured on 2026-10-13 on a shared, busy Mac: a baseline recorded at the end
of an hour-long build made 6 of 8 benchmarks read 50 to 206 % slower an hour
later, with no code change. Re-recorded and compared back to back at the same
load, all 8 stayed between -11 and +16 % and none failed. The interval rule
held there: `generate_draft` at 100 findings read +16.4 %, but its interval
reached down to +12.5 %, so it passed. Re-record the baseline when the host's
load changes, and run this gate on a quiet host. Until 1.6.33 the gate never benchmarked anything in this
repository. It looked for `[[bench]]` only under `crates/`, which this
root-crate repository does not have, and it ended in `exit 0` even when
`cargo bench` failed. Its 16 behaviour tests in `test_cargo_bench.bats` run it
against a stub `cargo` that writes Criterion-shaped estimates.
## Quality gates and Git hooks
Two Git hooks live under `.githooks/`; activate them once per clone with
`git config core.hooksPath .githooks`.
- **`pre-commit`** (on a Rust-touching commit) auto-fixes, then enforces in
order: `rustfmt`, `clippy --workspace --all-targets -- -D warnings`, the test
suite plus doctests, a `RUSTDOCFLAGS="-D warnings" cargo doc` broken-link
check, `typos`, and a **rust-doctor 100/100** health gate. Bypass one commit
with `SKIP_RUST_HOOKS=1 git commit` or `git commit --no-verify`.
- **`pre-push`** runs the heavier, network tier: `cargo audit`, `cargo deny
check`, `cargo semver-checks` (published crates only), and an MSRV
`cargo +<rust-version> check`. It asks crates.io which crates are
published, with a User-Agent that names the hook; an answer other than
`200` or `404` blocks the push, as an unreachable crates.io does. Its
tests are in `.githooks/pre-push.bats`.
The rust-doctor gate is configured in `rust-doctor.toml` for the installed
0.7.0 (its schema is `blocking`, `[categories]`, `[rules]`, `[structure]` — the
older `verbose`/`fail_on`/`[ignore]` keys are rejected). Every `#[allow]` in the
tree carries a `reason = "…"`; the opinionated structural rules (file/module
-scope allows, unit size, near-duplicate bodies) and the six transitive
duplicate-major-version conflicts are declined with a documented `[rules]`
policy rather than by reshaping cohesive code — dependency-version policy is
owned by `cargo deny` (`deny.toml`). `clippy.toml` bans the `print!` / `println!`
macro family in the runtime binary; build scripts keep a scoped allow for the
cargo directive protocol.
## Driving the HTTP surface — upload, analyze, export
The Auditor is a server-rendered htmx application, **not a JSON REST API**.
There is no `/api/v1`: every mutation is an ordinary HTML form `POST` that
answers `303 See Other` with a `Location` header, and every read returns HTML.
Automating it therefore means three things:
- Do not follow redirects — the `303` **is** the result. The new SBOM's id is
the last path segment of `Location`.
- Send the file as `multipart/form-data`; send everything else as
`application/x-www-form-urlencoded`.
- Poll `GET /sbom/{id}/runs/partial` for completion. Analysis is asynchronous:
the analyze `POST` returns as soon as the runs are queued.
Every example below was executed against both a local `1.6.25` build and the
public instance, and the terminal output is the real captured output.
### Endpoints used
| Method + path | Body | Success | Meaning |
| --- | --- | --- | --- |
| `POST /upload` | `multipart/form-data`, part `file` | `303` → `/sbom/{id}` | Store an SBOM |
| `POST /sbom/{id}/analyze` | empty | `303` → `/sbom/{id}` | Queue the analyzer ensemble |
| `GET /sbom/{id}/runs/partial` | — | `200` HTML fragment | Run status + findings |
| `POST /export/run` | form: `sbom`, `format`×N, `overwrite` | `303` → `/export?sbom={id}&written=N` | Render + write reports |
| `GET /export/download?file=NAME` | — | `200` + `Content-Disposition` | Stream one artifact |
| `GET /healthz`, `GET /readyz` | — | `200` `ok` / `ready` | Liveness / readiness |
### The same-origin gate is the CSRF boundary
`POST /upload`, `/analyze` and `/export/run` all pass through
`same_origin()` in `src/router.rs`. It decides in this order:
- If `Sec-Fetch-Site` is present it wins outright: only `same-origin` and
`none` are accepted. A matching `Origin` does **not** override it.
- Otherwise, if `Origin` is present it must parse as a URI with an **https**
scheme whose authority equals the `Host` header.
- If neither header is present the request is allowed.
That last rule is why a bare `curl` works while a browser-like client can be
rejected. Measured against a running server:
```console
$ curl -sk -o /dev/null -w 'HTTP %{http_code}\n' -X POST https://127.0.0.1:8690/upload \
-F "file=@demo-sbom.cdx.json"
HTTP 303
$ curl -sk -o /dev/null -w 'HTTP %{http_code}\n' -X POST https://127.0.0.1:8690/upload \
-H 'Origin: https://evil.example' -F "file=@demo-sbom.cdx.json"
HTTP 403
$ curl -sk -o /dev/null -w 'HTTP %{http_code}\n' -X POST https://127.0.0.1:8690/upload \
-H 'Sec-Fetch-Site: cross-site' -F "file=@demo-sbom.cdx.json"
HTTP 403
$ curl -sk -o /dev/null -w 'HTTP %{http_code}\n' -X POST https://127.0.0.1:8690/upload \
-H 'Origin: https://127.0.0.1:8690' -F "file=@demo-sbom.cdx.json"
HTTP 303
```
If your HTTP library sets `Origin` automatically, either make it match the
target authority over https or drop the header.
### The sample SBOM
Every example uses this file, committed as
[`documentation/demo/demo-sbom.cdx.json`](demo/demo-sbom.cdx.json). It lives
outside `example/`, because `.gitattributes` routes `example/**/*.json` through
Git LFS and an 806-byte fixture has no business being an LFS object. It is
small enough to paste and deliberately carries two known-vulnerable components
so the analyzers return findings:
```json
{
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"serialNumber": "urn:uuid:6f0c2f1e-6a0e-4f6f-9a4b-2c7b1d3e5a90",
"version": 1,
"metadata": {
"timestamp": "2026-09-20T00:00:00Z",
"component": {
"bom-ref": "demo-app", "type": "application",
"name": "demo-app", "version": "1.0.0"
}
},
"components": [
{
"bom-ref": "pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1",
"type": "library", "name": "log4j-core",
"group": "org.apache.logging.log4j", "version": "2.14.1",
"purl": "pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1"
},
{
"bom-ref": "pkg:npm/lodash@4.17.15",
"type": "library", "name": "lodash", "version": "4.17.15",
"purl": "pkg:npm/lodash@4.17.15"
}
]
}
```
### CLI — curl
Against a local instance. The development server presents a regenerated
self-signed certificate, so `-k` is required locally and **must not** be used
against a public instance.
```console
$ curl -sk -D - -o /dev/null -X POST https://127.0.0.1:8690/upload \
-F "file=@demo-sbom.cdx.json;type=application/json"
HTTP/2 303
content-type: text/plain; charset=utf-8
location: /sbom/1
x-frame-options: DENY
strict-transport-security: max-age=31536000
content-security-policy: default-src 'self'; img-src 'self' data:; style-src 'self'; ...
x-content-type-options: nosniff
referrer-policy: no-referrer
cross-origin-opener-policy: same-origin
cross-origin-resource-policy: same-origin
cross-origin-embedder-policy: require-corp
content-length: 8
$ curl -sk -D - -o /dev/null -X POST https://127.0.0.1:8690/sbom/1/analyze
HTTP/2 303
location: /sbom/1
content-length: 16
```
Poll until the fragment's `hx-trigger` flips from `every 2s` to `none`. Note
that the attribute is **always present** — the terminal signal is its *value*,
not its absence:
```console
$ curl -sk https://127.0.0.1:8690/sbom/1/runs/partial | grep -o 'hx-trigger="[^"]*"'
hx-trigger="none"
```
Rendered to text, the fragment carries one row per analyzer plus the findings
table:
```console
$ curl -sk https://127.0.0.1:8690/sbom/1/runs/partial \
| sed -E 's/<[^>]+>/|/g' | tr '|' '\n' | grep -vE '^\s*$' | head -20
Tool
Status
Version
Duration
Detail
syft
OK
1.52.0
1s
exit 0
grype
OK
13
0.119.0
1s
exit 0
Findings from
grype
Severity
Vulnerability
Package
```
Export every flavour in one request — repeat the `format` field once per
format — then stream one artifact back:
```console
$ curl -sk -o /dev/null -w '%{http_code} %{redirect_url}\n' \
-X POST https://127.0.0.1:8690/export/run \
--data 'sbom=1' --data 'overwrite=1' \
--data 'format=sarif-2.1' --data 'format=sarif-2.2' \
--data 'format=markdown' --data 'format=odt' \
--data 'format=docx' --data 'format=pdf' \
--data 'format=csaf-2.1' --data 'format=csaf-2.2'
303 https://127.0.0.1:8690/export?sbom=1&written=8
$ curl -sk -D - -o sbom-1.md 'https://127.0.0.1:8690/export/download?file=sbom-1.md'
HTTP/2 200
content-type: text/markdown; charset=utf-8
content-disposition: attachment; filename="sbom-1.md"
content-length: 14965
```
The same three calls against the public instance differ only in the base URL
and in dropping `-k`:
```console
$ curl -sS -o /dev/null -w 'HTTP %{http_code} %{redirect_url}\n' \
-X POST https://sbom.ndaal.eu/upload \
-F "file=@demo-sbom.cdx.json;type=application/json"
HTTP 303 https://sbom.ndaal.eu/sbom/1941
$ curl -sS -w '\n' https://sbom.ndaal.eu/healthz
ok
```
### Python
Requires `requests`. The full flow — upload, analyze, poll, export, download:
```python
import os, re, time, requests
BASE = os.environ.get("BASE", "https://127.0.0.1:8690")
VERIFY = "127.0.0.1" not in BASE and "localhost" not in BASE
FORMATS = ["sarif-2.1", "sarif-2.2", "markdown", "odt",
"docx", "pdf", "csaf-2.1", "csaf-2.2"]
s = requests.Session()
s.verify = VERIFY
# 1. upload -> 303 Location: /sbom/{id}
with open("demo-sbom.cdx.json", "rb") as fh:
r = s.post(f"{BASE}/upload",
files={"file": ("demo-sbom.cdx.json", fh, "application/json")},
allow_redirects=False)
sbom_id = int(r.headers["location"].rsplit("/", 1)[1])
print(f"upload -> HTTP {r.status_code} Location: {r.headers['location']}")
# 2. analyze -> 303; runs are queued, analysis is asynchronous
r = s.post(f"{BASE}/sbom/{sbom_id}/analyze", allow_redirects=False)
print(f"analyze -> HTTP {r.status_code} Location: {r.headers.get('location')}")
# 3. poll until hx-trigger == "none"
while True:
fragment = s.get(f"{BASE}/sbom/{sbom_id}/runs/partial").text
trigger = re.search(r'hx-trigger="([^"]*)"', fragment)
if trigger and trigger.group(1) == "none":
break
time.sleep(2)
cves = sorted(set(re.findall(r"CVE-\d{4}-\d{4,7}", fragment)))
print(f" CVEs: {', '.join(cves)}")
# 4. export every flavour -> 303 ?written=N
payload = [("sbom", str(sbom_id)), ("overwrite", "1")]
payload += [("format", f) for f in FORMATS]
r = s.post(f"{BASE}/export/run", data=payload, allow_redirects=False)
print(f"export -> HTTP {r.status_code} {r.headers.get('location')}")
# 5. download one artifact
r = s.get(f"{BASE}/export/download", params={"file": f"sbom-{sbom_id}.md"})
print(f"download -> HTTP {r.status_code} {r.headers.get('content-type')} "
f"{len(r.content)} bytes")
```
Against a local instance:
```console
$ BASE=https://127.0.0.1:8690 python3 audit_client.py demo-sbom.cdx.json
upload -> HTTP 303 Location: /sbom/1
analyze -> HTTP 303 Location: /sbom/1
run syft OK
run grype OK
run trivy OK
run osv-scanner OK
run bomber OK
run bomdrift OK
run shieldbom OK
run provenant OK
CVEs: CVE-2020-28500, CVE-2020-8203, CVE-2021-23337, CVE-2021-44228, CVE-2021-44832, CVE-2021-45046, CVE-2021-45105, CVE-2025-13465, CVE-2025-68161, CVE-2026-2950, CVE-2026-34477, CVE-2026-34480, CVE-2026-4800
export -> HTTP 303 written=8 (/export?sbom=1&written=8)
download -> HTTP 200 sbom-1.md text/markdown; charset=utf-8 18728 bytes
```
Against the public instance — same script, one environment variable:
```console
$ BASE=https://sbom.ndaal.eu python3 audit_client.py demo-sbom.cdx.json
upload -> HTTP 303 Location: /sbom/2298
analyze -> HTTP 303 Location: /sbom/2298
run syft OK
run grype OK
run trivy OK
run osv-scanner OK
run bomber OK
run bomdrift OK
run shieldbom Failed
run provenant OK
CVEs: CVE-2020-28500, CVE-2020-8203, CVE-2021-23337, CVE-2021-44228, CVE-2021-44832, CVE-2021-45046, CVE-2021-45105, CVE-2025-13465, CVE-2025-68161, CVE-2026-2950, CVE-2026-34477, CVE-2026-34480, CVE-2026-4800
export -> HTTP 303 written=154 (/export?sbom=2298&written=154)
download -> HTTP 200 sbom-2298.md text/markdown; charset=utf-8 15107 bytes
```
Two differences in that output are real and worth understanding rather than
retrying: a single analyzer (`shieldbom`) failed on the public instance while
succeeding locally — a per-tool failure is isolated and never blocks the other
runs — and `written` is 154 rather than 8, which the next section explains.
### Rust
`reqwest` 0.13 gates the builder methods behind features; `form`, `query` and
`multipart` are all required, and the TLS feature is `rustls`, not
`rustls-tls`:
```toml
[dependencies]
reqwest = { version = "0.13", default-features = false, features = [
"blocking", "multipart", "form", "query", "rustls", "rustls-native-certs",
] }
regex = "1"
```
The redirect policy matters: `Policy::none()` keeps the `303` readable.
```rust
use reqwest::blocking::{multipart, Client};
use reqwest::redirect::Policy;
let base = std::env::var("BASE").unwrap_or_else(|_| "https://127.0.0.1:8690".into());
let local = base.contains("127.0.0.1") || base.contains("localhost");
let client = Client::builder()
.redirect(Policy::none()) // read the 303, do not follow it
.danger_accept_invalid_certs(local) // dev self-signed cert only
.build()?;
// 1. upload
let form = multipart::Form::new().part(
"file",
multipart::Part::bytes(std::fs::read(&path)?)
.file_name(path.clone())
.mime_str("application/json")?,
);
let response = client.post(format!("{base}/upload")).multipart(form).send()?;
let location = response.headers()["location"].to_str()?.to_owned();
let id: u64 = location.rsplit('/').next().unwrap_or("0").parse()?;
// 2. analyze
client.post(format!("{base}/sbom/{id}/analyze")).send()?;
// 3. poll until hx-trigger == "none"
let trigger = regex::Regex::new(r#"hx-trigger="([^"]*)""#)?;
let fragment = loop {
let body = client.get(format!("{base}/sbom/{id}/runs/partial")).send()?.text()?;
if trigger.captures(&body).is_some_and(|c| &c[1] == "none") { break body; }
std::thread::sleep(std::time::Duration::from_secs(2));
};
// 4. export every flavour
let mut form: Vec<(&str, String)> = vec![("sbom", id.to_string()), ("overwrite", "1".into())];
form.extend(FORMATS.iter().map(|f| ("format", (*f).to_owned())));
let response = client.post(format!("{base}/export/run")).form(&form).send()?;
// 5. download
let name = format!("sbom-{id}.md");
let response = client.get(format!("{base}/export/download"))
.query(&[("file", &name)]).send()?;
```
Both targets, same binary:
```console
$ BASE=https://127.0.0.1:8690 cargo run --release -- demo-sbom.cdx.json
upload -> HTTP 303 Location: /sbom/1
analyze -> HTTP 303
runs -> all terminal; 13 distinct CVEs
export -> HTTP 303 /export?sbom=1&written=8
download -> HTTP 200 sbom-1.md text/markdown; charset=utf-8 18728 bytes
$ BASE=https://sbom.ndaal.eu cargo run --release -- demo-sbom.cdx.json
upload -> HTTP 303 Location: /sbom/2298
analyze -> HTTP 303
runs -> all terminal; 13 distinct CVEs
export -> HTTP 303 /export?sbom=2298&written=154
download -> HTTP 200 sbom-2298.md text/markdown; charset=utf-8 15107 bytes
```
### The eight report flavours, and why `written` is not the format count
`format` accepts these values (`src/export.rs`); each also has a short alias:
| `format` value | Alias | Written as | Media type |
| --- | --- | --- | --- |
| `sarif-2.1` | `sarif21` | `sbom-{id}-v2.1.0.sarif` | `application/sarif+json` |
| `sarif-2.2` | `sarif22` | `sbom-{id}-v2.2.sarif` | `application/sarif+json` |
| `markdown` | `md` | `sbom-{id}.md` | `text/markdown` |
| `odt` | — | `sbom-{id}.odt` | `application/vnd.oasis.opendocument.text` |
| `docx` | — | `sbom-{id}.docx` | `…wordprocessingml.document` |
| `pdf` | — | `sbom-{id}.pdf` | `application/pdf` |
| `csaf-2.1` | `csaf21` | `sbom-{id}-csaf-v2.1.json` | `application/json` |
| `csaf-2.2` | `csaf22` | `sbom-{id}-csaf-v2.2.json` | `application/json` |
`written=N` in the redirect counts **artifacts, not formats**, and one format
can fan out into many files. The `csaf_split_per_finding` setting (default
`false`) is the reason:
- **off** — each CSAF version renders one rollup advisory carrying every
finding. Eight formats → eight artifacts, which is the `written=8` above.
- **on** — each CSAF version renders the rollup *plus* one advisory per
finding, named `sbom-{id}-csaf-v2.1-0001.json`, `-0002`, … The public
instance runs with it on, so the same eight formats over 73 findings
produced `6 + 2 × (1 + 73) = 154` artifacts.
Every artifact is written with all five checksum sidecars (`.sha-256`,
`.sha-512`, `.sha3-512`, `.blake3-512`, `.shake256-512`), so the eight-artifact
local export leaves 48 files in the export directory (`./data_export` by
default):
```console
$ ls -1 data_export/ | grep -vE '\.(sha-256|sha-512|sha3-512|blake3-512|shake256-512)$'
sbom-1-csaf-v2.1.json
sbom-1-csaf-v2.2.json
sbom-1-v2.1.0.sarif
sbom-1-v2.2.sarif
sbom-1.docx
sbom-1.md
sbom-1.odt
sbom-1.pdf
```
`GET /export/download` allowlists the `file` parameter against the actual
directory listing, so the query string is never used as a path.
### Status codes you will actually hit
All measured against a running instance:
| Status | Endpoint | Cause |
| --- | --- | --- |
| `303` | upload / analyze / export | Success — read `Location` |
| `400` | `POST /upload` | Body is not `multipart/form-data`, or the file part is empty |
| `403` | any gated `POST` | `Origin` mismatch, or `Sec-Fetch-Site: cross-site` |
| `413` | `POST /upload` | Body exceeds `upload_max_bytes` |
| `422` | `POST /upload` | Parsed, but not a recognised SBOM |
`upload_max_bytes` bounds **one request body**, not a cumulative quota, and it
is an operator setting — so the cap is per-instance and you cannot infer it
from the default. It now defaults to 10 GiB, but the public instance is
configured far lower: a 51 MiB file is already `413` there. Size-filter batch
uploads against the *target's* cap, discovered by probing, not against the
default.
The body is buffered in memory before the multipart parse, so this setting is
also the worst-case per-request allocation — see the Administrator Guide before
raising it on a memory-constrained host.
Three of these are terminal for batch tooling and must not be retried:
- `422` — the payload parsed but is not an SBOM. Running the `example/` corpus
against the public instance, every `422` was a `*_grype.json` or
`*_trivy-sbom.json` file: a *scan report* is not an SBOM.
- `400` — in a batch run this is almost always a **zero-byte file** rather than
a malformed request; `example/` contains 14 of them.
- `413` — over the target instance's cap.
Only `5xx` and connection errors are worth a retry with backoff.
[`scripts/upload_sboms.sh`](../scripts/upload_sboms.sh) implements exactly that
policy for a whole directory tree. It pre-filters on size client-side, treats
`303`/`422`/`413`/`400` as terminal, retries everything else with linear
backoff, and writes one TSV row per file which doubles as the resume log — a
re-run skips anything already stored:
```console
$ BASE_URL=https://sbom.ndaal.eu ROOT=example scripts/upload_sboms.sh
Info: ✅ progress: sent=25 failed=0 skipped_oversize=0 skipped_already=0
...
Info: ✅ scanned=1157 sent=1028 failed=105 skipped_oversize=24 skipped_already=0
```
Against a local instance the self-signed certificate needs an explicit opt-in;
verification is never disabled implicitly:
```console
$ BASE_URL=https://127.0.0.1:8680 CURL_INSECURE=1 scripts/upload_sboms.sh
Warning: ⚠️ CURL_INSECURE=1 — TLS certificate verification is DISABLED
```
#### Not every `403` comes from the application
A deployment may sit behind a WAF that answers before the Auditor sees the
request, and it uses the same status code as the CSRF gate. Distinguish them by
the response headers: the application's `403` carries the normal security
header set and a short text body, whereas the public instance's edge returns an
empty body and a `waf-block` header.
```console
$ curl -sS -D - -o /dev/null -X POST https://sbom.ndaal.eu/upload \
-F "file=@vex.json;type=application/json"
HTTP/2 403
waf-block: request
content-length: 0
```
That exact file uploads successfully (`303`) against a local build of the same
version, so a `403` with `waf-block: request` is an edge decision about the
payload — not a malformed request, and not something a different `Origin`
header will fix. Batch tooling should log it separately from a CSRF `403`, and
escalate it to whoever owns the WAF rules rather than retrying.
Uploading the same file twice is content-addressed: the second `POST` returns
the `Location` of the existing SBOM rather than creating a duplicate.