Repository navigation
feat(vis): answer vis audit --format json --policies none natively when the scan finds nothing - #254
Conversation
`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 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. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Thank you for following the naming conventions! 🙏 |
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
…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>
2c7912a to
2e80ee8
Compare
What
vis audit --format json --policies noneis 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 noneis required: the default config turns on thepublisherChangepolicy, 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 nonegoes to Node.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 likelocaleCompare), and thenone foundrow on stderr (tick, dimmed summary,TERM=linuxglyph, colour level).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 thatresponse.json()would read differently, a request that fails or is redirected, a proxy/CA/Node option in the environment,VIS_AUDIT_BACKENDorVIS_INSTALLER, apackageManagerpin, apnpm-workspace.yamlwithauditConfig, avis.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
fetchVulnerabilitiesstores findings undername@version, but the online handler reads them byname, so an onlinevis auditnever lists a vulnerability: the progress row says1 foundwhileresultsstays empty and--exit-codenever 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.keys_refreshmoved tohttp::node_fetch; the pnpm lockfile reader moved fromsbom/lock.rstopnpm_lock.rs;js::iso_nowandoutput::node_may_cut_shortwere lifted out ofsbom.crate::json;origin/nextdoes not compile without it. Drop it oncenexthas the fix.Tests and how the OSV stub is wired
audit/tests.rs). The code behind the gates (scan_workspace) takes the OSV address as a parameter, so the tests run it against a stubTcpListeneron 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 underTERM=linux. ThetoFixedrounding of the elapsed time was checked against Node for every millisecond from 1.0s to 120s.__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 withVIS_DEBUG_DECLINEnaming 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 otherfetch, so nothing reaches the network.route.rs,bin/route.mjs, the sharedrouting.jsonfixture and the route snapshot agree.FORCE_COLOR=3 CI=1 GITHUB_ACTIONS=true TERM=xterm-256color.🤖 Generated with Claude Code