Skip to content

docs(ci): define the aligned dependency-audit gating policy - #337

Merged
CameronBrooks11 merged 1 commit into
mainfrom
docs/audit-gating-policy
Jul 16, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
docs/audit-gating-policy

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Writes down the single audit policy the three jobs now share — High/Critical blocks, rest reported, full tree in scope — with the Python job documented as deliberately stricter (pip-audit cannot tier by severity), per-ecosystem allowlist mechanics with justification + re-check rules, the not-a-required-check rationale, and the remediation flow. Replaces the stale deferred-advisories list (rand 0.7.3 etc. left the tree long ago) with a reasoning-record keyed to re-check triggers. Workflow diffs are comments/step-names only — no gate behavior changes; cargo (CVSS≥7 tested gate) and npm (--audit-level=high) already enforce the policy.

Decisions encoded (chosen 2026-07-15): threshold = High+ tiered; direction = harmonize the three native jobs (not osv-scanner); scope = full tree.

The three audit jobs enforced three unwritten, inconsistent policies
(cargo: CVSS>=7; python: any advisory; npm: high+). Align them under one
written policy in dependency-policy.md ("CI audit gating"):

- High/Critical vulnerabilities block; everything else is reported but
  does not block. Full tree in scope (dev + build deps block the same as
  runtime — the build chain produces the shipped binaries).
- Python stays deliberately stricter (any advisory blocks): pip-audit
  has no severity filter and PyPI/OSV advisories often lack CVSS, so
  tiering is not implementable there. Documented as policy, with the
  --ignore-vuln allowlist as the escape hatch.
- Allowlist mechanics per ecosystem, each entry requiring the advisory
  ID, a justification, and a re-check trigger.
- Enforcement note: Dependency Audit is intentionally not a required
  status check (advisories land asynchronously; unrelated PRs must not
  be hard-blocked) — the gate is the weekly run + triage-by-convention.
- Remediation flow: Renovate weekly lock-file maintenance lands before
  the Monday audit; urgent advisories get direct lockfile bumps (floor
  constraints mean no Renovate update PR will exist).

Refresh the stale "Currently deferred advisories" into a reasoning
record: drop rand 0.7.3 / old glib GHSA entries (no longer in the
tree), add the gtk3-rs unmaintained cluster (RUSTSEC-2024-04xx,
structurally pinned by Tauri on Linux), and note quick-xml
RUSTSEC-2026-0194/0195 were remediated, not accepted. The section now
records reasoning only — live state belongs to the audit artifacts,
which is what let the old list go stale.

Workflow: comment-only changes pointing each job at the policy doc
(no functional gate changes — cargo and npm already enforce High+).
@CameronBrooks11
CameronBrooks11 merged commit 4f41d95 into main Jul 16, 2026
9 checks passed
@CameronBrooks11
CameronBrooks11 deleted the docs/audit-gating-policy branch July 16, 2026 19:01
CameronBrooks11 added a commit that referenced this pull request Oct 14, 2026
The npm half of Dependency Audit cannot go green on its own. After lock
file maintenance (#380), the only npm finding is `braces` <= 3.0.3,
[GHSA-vfj7-8cjw-p6xm](GHSA-vfj7-8cjw-p6xm)
(high, CVSS 7.5). The advisory lists no patched version, and 3.0.3 is
the latest `braces` on npm (`npm view braces dist-tags` → `latest:
3.0.3`). npm's suggested fix is downgrading `stylelint` to 7.7.0.

npm has no per-advisory ignore, so this takes the route
`dependency-policy.md` has prescribed since #337: a post-processor over
`npm-audit.json`, mirroring `cargo_audit_gate.py`.

## Changes

- `scripts/ci/npm_audit_gate.py`:
- Blocks on a high/critical advisory not waived by `--ignore <GHSA-ID>`,
and on any severity it does not recognise. Reports moderate/low/info
without blocking.
- Counts each advisory once from the `via` objects; string `via` entries
are the same advisory propagated up the tree. The 7 "high" packages in
#380's report are one advisory.
- Fails closed on a missing or malformed report, and on any
`auditReportVersion` other than 2.
- Every package npm flags at high/critical (or an unknown severity) must
trace through its `via` links to a parsed advisory at least as severe as
itself; an ignored one counts. This stays in force while `braces` is
ignored. npm sets a package's severity to the highest of its advisories,
and a dependency link inherits its source's severity (arborist 9.9.1,
`vuln.js` `addAdvisory`), so a real report always satisfies it. A hidden
advisory no more severe than one already reachable from the same package
cannot be detected.
  - On an id collision, keeps the advisory that would block.
- Warns when an `--ignore` matches nothing, so the entry gets removed
once `braces` is patched.
- `dependency-audit.yml`: `npm audit --json > npm-audit.json || true`,
then the gate with `--ignore GHSA-vfj7-8cjw-p6xm`.
- `dependency-policy.md`: Node row, allowlist mechanics and Required
Tooling updated; `braces` added to the accepted advisories with its
reasoning and re-check trigger. `ci-cd.md`: one line updated.
- `ci-check.yml`: the backend path filter now includes
`scripts/**/*.py`. Before, a PR touching only a gate script, or
`export_openapi.py`/`generate_schema.py` (which `backend-ci.yml` runs),
skipped the backend job.

## Why accepting `braces` is safe here

The DoS needs an attacker-supplied brace pattern. In
`fiberpath_gui/package-lock.json`, `braces`, `micromatch`, `fast-glob`
and `globby` are reached only through `stylelint`, which expands
`src/**/*.css` (`npm run lint:css`). Dropping the dependent, as
`@vitest/ui` was dropped for `flatted` in v0.5.4, is not an option:
`stylelint` 17.16.0 still depends on the same chain.

## Verification

The gate against the real reports:

| Report | `--ignore` braces | Result |
| --- | --- | --- |
| #380 run 38427831685 | yes | rc 0: 1 advisory, accepted |
| #380 run 38427831685 | no | rc 1: braces blocks |
| pre-#380 `main`, scheduled run 38277199756 | yes | rc 1: devalue ×3
and source-map-js block (fixed by #380) |
| npm 11.19.0 registry error (`--registry http://127.0.0.1:9`) | — | rc
1: not `auditReportVersion` 2 |

Hand-built malformed reports, each run with `--ignore` braces as in CI,
against the gate at `c4074d6` (first version), `ff6a5fb` (count
cross-check), `541e813` (severity-blind trace) and this head. The
`row-*` reports are single-shape cases (`row-no-via` holds only a
`braces` package, with its advisory outside `via`). The `hole-*` reports
carry five packages of the `braces` chain plus one hidden critical. The
`chain-*` reports put a hidden critical on, or link one into, the
ignored chain.

| Report | `c4074d6` | `ff6a5fb` | `541e813` | now | Check that fails it
now |
| --- | --- | --- | --- | --- | --- |
| `row-capitalised`: severity `"High"` | 0 | 1 | 1 | 1 | unrecognised
severity blocks |
| `row-no-severity` | 0 | 1 | 1 | 1 | unrecognised severity blocks |
| `row-no-via`: advisory outside `via` | 0 | 1 | 1 | 1 | trace |
| `row-via-string`: `via` is a string | 0 | 1 | 1 | 1 | trace |
| `row-id-collision`: no-id low + no-id critical | 0 | 1 | 1 | 1 |
collision keeps the blocking advisory |
| `hole-outside-via` | 0 | **0** | 1 | 1 | trace |
| `hole-via-string`: `via` names a missing package | 0 | **0** | 1 | 1 |
trace |
| `hole-id-collision` | 0 | **0** | 1 | 1 | collision keeps the blocking
advisory |
| `chain-hidden-critical`: critical on `micromatch`, advisory outside
`via` | 0 | **0** | **0** | 1 | trace, severity-aware |
| `chain-critical-link`: critical package linking into `micromatch` | 0
| **0** | **0** | 1 | trace, severity-aware |

The `chain-*` rows are the round-3 fixtures
`open-hidden-critical-on-chain-pkg` and
`open-hidden-critical-plus-chain-link`. Across 51 report files, each run
with and without the `braces` ignore (102 runs), these two are the only
results that differ between `541e813` and this head. The pre-#380
report, ten flagged packages with mixed high and moderate advisories,
passes the trace once its five blockers are waived.

`uv run ruff check` and `ruff format --check` are clean; `pytest
tests/ci` passes 54 tests. `uv run mypy` does not cover `scripts/` or
`tests/` (its `packages` are the three shipped packages), the same as
for the cargo gate.

Mutations, each anchor matched exactly once, the file hash checked to
confirm the mutation applied, `--maxfail=1000` so every failing test is
listed:

```
any ignore accepts all          -> test_ignored_advisory_does_not_hide_another_critical test_ignore_does_not_cover_another_advisory test_id_collision_keeps_the_blocking_advisory
missing vulnerabilities passes  -> test_missing_vulnerabilities_fails_closed
no stale-ignore warning         -> test_stale_ignore_warns_but_passes
warn on every ignore            -> test_ignore_accepts_listed_advisory
id ignores GHSA url             -> test_advisory_id_from_url test_ignore_accepts_listed_advisory test_via_cycle_is_traced_without_recursing_forever test_main_passes_ignore_flags
any version accepted            -> test_other_report_versions_fail_closed[1] [3] [None]
unknown severity passes         -> test_unrecognised_severity_blocks[High] [None] []
critical filed non-blocking     -> test_blocks_on_critical test_ignored_advisory_does_not_hide_another_critical test_id_collision_keeps_the_blocking_advisory
high filed non-blocking         -> test_blocks_on_high test_ignore_does_not_cover_another_advisory test_main_passes_ignore_flags
blocking returns 0              -> 9 tests
no trace check                  -> test_untraced_package_fails_closed_while_braces_ignored[entry0..3] test_high_package_with_only_a_moderate_advisory_fails_closed test_critical_on_ignored_chain_package_fails_closed test_critical_linked_into_ignored_high_chain_fails_closed test_critical_linked_only_to_moderate_package_fails_closed
collision keeps first           -> test_id_collision_keeps_the_blocking_advisory
trace ignores string links      -> test_ignore_accepts_listed_advisory test_via_cycle_is_traced_without_recursing_forever test_main_passes_ignore_flags
string link always explains     -> test_critical_on_ignored_chain_package_fails_closed test_critical_linked_into_ignored_high_chain_fails_closed test_critical_linked_only_to_moderate_package_fails_closed
trace accepts any severity      -> test_high_package_with_only_a_moderate_advisory_fails_closed test_critical_on_ignored_chain_package_fails_closed test_critical_linked_into_ignored_high_chain_fails_closed test_critical_linked_only_to_moderate_package_fails_closed
trace severity-blind            -> test_critical_on_ignored_chain_package_fails_closed test_critical_linked_into_ignored_high_chain_fails_closed
package need ignores severity   -> test_critical_on_ignored_chain_package_fails_closed test_critical_linked_into_ignored_high_chain_fails_closed
no cycle guard                  -> test_via_cycle_is_traced_without_recursing_forever
trace skips unknown pkg sev     -> test_untraced_package_fails_closed_while_braces_ignored[entry3]
```

Known limits, not addressed: the trace is recursive, so a `via` chain
about 1,000 packages deep raises `RecursionError` (rc 1, a false red);
the deepest chain in either real report is 7. An `--ignore` is keyed by
advisory id, so if GHSA-vfj7-8cjw-p6xm were extended to a second package
it would be waived there too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant