Skip to content

feat(vis): answer vis audit --format json --policies none natively when the scan finds nothing - #254

Merged
prisis merged 3 commits into
nextfrom
t3/port-audit-native
Nov 25, 2026
Merged

prisis merged 3 commits into
nextfrom
t3/port-audit-native

Conversation

@prisis

@prisis prisis commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What

vis audit --format json --policies none is answered by the native binary when the scan finds nothing, and handed to Node before anything is printed in every other case.

Native answers (a unix CI run off a terminal, at the root of a pnpm workspace with no vis.config):

  • audit --format json --policies none (or the = forms) with at most one each of --severity <low|medium|high|critical>, --fail-on <level> and --exit-code. None of them changes the output when there is no finding.
  • --policies none is required: the default config turns on the publisherChange policy, which reads the registry's packument of every package and can report a block (exit 1) or write its cache. The binary does not reproduce that, so a run without --policies none goes to Node.
  • It reads pnpm-lock.yaml, asks OSV (POST https://api.osv.dev/v1/querybatch, 10 second limit, no redirects) over the shared HTTP client, and prints the report Node prints for a scan without findings: the package count, the duplicate versions (sorted like localeCompare), and the none found row on stderr (tick, dimmed summary, TERM=linux glyph, colour level).
  • A status outside 2xx is an empty result in the Node scan, so it is native too.

Handed to Node, before any output: every other format and flag (--fix, --offline, --prod-only, --report, --explain, table, sarif, ...), an answer that lists a finding or that response.json() would read differently, a request that fails or is redirected, a proxy/CA/Node option in the environment, VIS_AUDIT_BACKEND or VIS_INSTALLER, a packageManager pin, a pnpm-workspace.yaml with auditConfig, a vis.config, a lockfile with no package or one the reader does not take exactly, and non-ASCII names. Node then asks OSV itself.

Notes for review

  • No environment variable redirects OSV. The address is fixed in Node and in the binary.
  • Existing Node behaviour reproduced, not fixed. fetchVulnerabilities stores findings under name@version, but the online handler reads them by name, so an online vis audit never lists a vulnerability: the progress row says 1 found while results stays empty and --exit-code never trips. The native path only answers the clean case, so it copies none of this; a run with findings goes to Node and keeps whatever Node does. Worth fixing in Node separately.
  • Refactors (no behaviour change): the proxy/CA/URL/redirect checks of keys_refresh moved to http::node_fetch; the pnpm lockfile reader moved from sbom/lock.rs to pnpm_lock.rs; js::iso_now and output::node_may_cut_short were lifted out of sbom.
  • Compile fix. The first commit imports the JSON codec from crate::json; origin/next does not compile without it. Drop it once next has the fix.

Tests and how the OSV stub is wired

  • Rust (audit/tests.rs). The code behind the gates (scan_workspace) takes the OSV address as a parameter, so the tests run it against a stub TcpListener on 127.0.0.1: the request body, a clean answer, non-2xx statuses, findings, redirects, a 204, a bad body and a refused connection. The whole run is compared with what the Node handler printed for the same lockfile (tests/fixtures/audit/, recorded from Node with its OSV request answered locally): stdout, and the stderr row plain, coloured and under TERM=linux. The toFixed rounding of the elapsed time was checked against Node for every millisecond from 1.0s to 120s.
  • Parity vitest (__tests__/native/audit-parity.test.ts). The binary cannot be pointed at a stub without a variable or a build seam, so the suite only covers what the binary hands to Node before it asks OSV: each such case must exit 70 with VIS_DEBUG_DECLINE naming the gate, print nothing and leave the files alone, and the delegated run must match a direct Node run. Both Node runs load a preload that answers OSV's request locally and refuses every other fetch, so nothing reaches the network.
  • Routing: route.rs, bin/route.mjs, the shared routing.json fixture and the route snapshot agree.
  • Run with and without FORCE_COLOR=3 CI=1 GITHUB_ACTIONS=true TERM=xterm-256color.

🤖 Generated with Claude Code

prisis and others added 2 commits November 25, 2026 12:54
`run/summary_json.rs` and `security_list/scan.rs` reached the codec through
`crate::sort_package_json::json`, a private re-import since the codec moved to
`crate::json`, so the native binary no longer compiled. Import it from
`crate::json`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tream limit

Commands that replace a Node `fetch` call all need the same checks (the proxy,
CA and Node-option variables, a plain URL, `fetch`'s fixed limit and its
redirects), and `keys_refresh` kept them private. Move them to
`http::node_fetch`.

Also lift what a second command needs out of the one that owned it: the pnpm
lockfile reader (`sbom::lock` -> `pnpm_lock`), the `toISOString` clock
(`js::iso_now`) and the check for a document Node would cut short on a pipe
(`output::node_may_cut_short`). No behaviour changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo did not review this PR because this workspace reached its daily trial limit of 100 reviews. Reviews start again at 00:00 UTC. Choose a plan to continue now.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d45f36a5-b941-4171-baa7-4ce88b8086e2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions github-actions Bot added package: vis vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list. size:XXL Size of the change, tests and generated files excluded. labels Nov 25, 2026
@prisis
prisis deployed to benchmarks November 25, 2026 12:05 — with GitHub Actions Active
@codspeed

codspeed Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

🆕 3 new benchmarks
⏩ 113 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 transform/transform_ts[470] N/A 355.3 µs N/A
🆕 transform/transform_ts[47000] N/A 16 ms N/A
🆕 transform/transform_ts[9400] N/A 3.3 ms N/A

Comparing t3/port-audit-native (2e80ee8) with next (1078fa9)2

Open in CodSpeed

Footnotes

  1. 113 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on next (b2ddc1c) during the generation of this report, so 65c051d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…when the scan finds nothing

The audit handler reads the lockfile, asks OSV about every package and prints a
report. With the policy engine skipped (`--policies none`; the default config
turns on `publisherChange`, which asks the registry for every package) a scan
that lists no finding prints a fixed report (the packages scanned, the
duplicate versions) and one `none found` row on stderr. The native binary now
prints exactly that, over its own HTTPS client with the same 10 second limit,
and takes `--severity <level>`, `--fail-on <level>` and `--exit-code`, which
change nothing without a finding.

Everything else is handed to Node before anything is printed, and Node asks
OSV itself: every other format and flag, an answer that lists a finding or that
`response.json()` would read differently, a request that fails or is
redirected, a proxy, CA or Node option in the environment, an installer or
backend chosen by the environment, a `packageManager` pin, an `auditConfig`,
an empty lockfile and a lockfile or package name the reader does not take
exactly. A status outside 2xx is an empty result in Node, and here.

The OSV address is fixed. The Rust tests reach the code behind the gates with a
stub's address and compare the whole run with what the Node handler printed for
the same lockfile; the parity suite covers what is handed to Node.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@prisis
prisis force-pushed the t3/port-audit-native branch from 2c7912a to 2e80ee8 Compare November 25, 2026 12:41
@prisis prisis changed the title feat(vis): answer vis audit --format json natively when the scan finds nothing feat(vis): answer vis audit --format json --policies none natively when the scan finds nothing Nov 25, 2026
@prisis
prisis deployed to benchmarks November 25, 2026 12:42 — with GitHub Actions Active
@prisis
prisis merged commit c6792a0 into next Nov 25, 2026
33 of 34 checks passed

This branch was successfully deployed

1 active deployment
benchmarks — 2e80ee85 Deployed Nov 25, 2026 by prisis via Bench native (vis) #434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: vis size:XXL Size of the change, tests and generated files excluded. vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant