Skip to content

audit: bulk project audit + lockfile-keyed scan cache - #32

Open
superbiche wants to merge 1 commit into
mainfrom
feat/bulk-audit
Open

audit: bulk project audit + lockfile-keyed scan cache#32
superbiche wants to merge 1 commit into
mainfrom
feat/bulk-audit

Conversation

@superbiche

Copy link
Copy Markdown
Owner

Stacked on #31. Part 4 of the safe overhaul.

  • safe install project mode (auto when no specs + a manifest is present, or explicit --project): runs safe audit scan --deps-only --project ., prints a one-screen verdict summary, TTY-confirms (non-TTY: exit 0 when clean, 102 when confirmation is needed); critical findings exit 104 and --yes cannot accept them. Fresh clones finally have a first-class pre-install audit entrypoint in every shell.
  • Lockfile-keyed scan cache: --deps-only scan results cache under the audit data dir keyed by machine + target + scan mode + dependency-evidence sha256, 24h TTL, --no-cache bypass, fail-open to a real scan on any cache problem. Cold scan 45.4s → warm 0.46s on a real toolchain (~100×), which is what makes the wrapper preflight viable.
  • Gate preflight now passes --deps-only — deliberate narrowing called out for the record: bare npm ci/pnpm install preflights no longer run the first-party source-risk scan (that stays in safe audit scan --project . and machine scans). This is what the approved overhaul plan specified; the trade is preflight latency users will actually keep enabled.
  • Cache hits render from the cache entry (no fabricated dated scan results); entries never collide across machines/targets; only completed rc-0 deps-only scans are stored.

Suites: install 79/79, new scan-cache suite 10/10, dispatcher 16/16, version-aware audit 50/50, smoke/external-binary/safe-run integration all green.

Implemented by a subagent from a scoped brief; verified and integrated by the orchestrating session.


@superbiche · maintainer · drafted with Claude Fable 5.

https://claude.ai/code/session_01Rk1wZEXbFB23TamMZYuRi6

@superbiche
superbiche force-pushed the feat/mise-gating branch 2 times, most recently from 52f5892 to 5da3126 Compare August 1, 2026 00:46
Base automatically changed from feat/mise-gating to main August 1, 2026 00:47
`safe install` with no package spec and a manifest in cwd (or with the new
`--project` flag) bulk-audits the project's dependency evidence instead of
printing usage. It runs `safe audit scan --deps-only --project .`, prints a
one-screen summary (manifests, package count, findings by severity, verdict,
top critical/high findings with package + advisory id) and audits only — no
package manager is ever run. Critical findings refuse 104 even under --yes;
WARN prompts interactively and refuses 102 non-interactively; a clean verdict
exits 0 quietly. A failed scan or a missing result document fails closed with
100 rather than reporting a clean project.

A --deps-only scan now reuses its recorded result when the dependency evidence
(lockfiles + manifests) hashes to a set already scanned within 24h, printing
`[safe audit] scan cache hit (<age>)` with the same verdict and exit code
instead of re-running the scanners. Keyed on machine, target, mode, and each
evidence file's own hash, so touching any of them forces a real scan.
`--no-cache` bypasses; SAFE_AUDIT_SCAN_CACHE_TTL_SECONDS overrides the TTL.
The cache can only skip work, never invent a verdict: missing, expired,
corrupt, or unrecognizable entries fall through to a real scan, evidence-free
scans are never cached, and source/--full scans are excluded entirely.

The wrapper project-scan preflight passes --deps-only so bare installs hit the
cached path.

Tests: new tests/audit/scan_cache.sh (10 cases, hermetic scanner stubs asserting
the scanners do not re-run on a hit and that every doubt falls through to a real
scan); dispatcher gains project-mode coverage (clean/WARN/critical/--yes/--project,
fail-closed paths, and that a named spec still takes the spec path).

Claude-Session: https://claude.ai/code/session_01Rk1wZEXbFB23TamMZYuRi6
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