Repository navigation
Conversation
The signatures marshall reads npm's signing keys (the cached set in `~/.vis/cache/registry-keys`, else `VIS_NPM_KEYS_URL` or the registry's keys address, the variable the Node side already honours) and checks each `dist.signatures` entry of the inspected version: a missing signature or integrity is a warning, a keyid the registry does not list an error, an expired key a warning. A keys request answered with a status other than 2xx falls back to the old keys or ends in the `fetch-failed` warning, as Node does, and a fresh answer is cached in the bytes Node writes. The signature is verified with `ring` (ECDSA P-256 over SHA-256, DER), which `rustls` already links, so `ring` is now named in the binary's manifest and the lock file gains no package. The key and signature must be canonical base64 and an uncompressed P-256 SubjectPublicKeyInfo. A signature that verifies is no finding; one that does not verify here is handed to Node, whose OpenSSL and `Buffer.from` read keys and signatures more leniently, so the `invalid-signature` report is Node's to make. A key whose `expires` is `null` (npm's current key) or empty never expires; one in the form registries write is compared with the clock; any other form goes to Node. Also handed over before any output or write: a keys request that fails before an answer, a redirect, a keys answer or cache file that is not what Node reads, and a keys address that is not a plain URL. The launcher gate accepts `signatures`; a run that executes `expiredDomains` still stays in Node. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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
|
PR Summary by QodoRun explicit vis inspect signature checks natively
AI Description
Merge Risk
|
|
Thank you for following the naming conventions! 🙏 |
Code Review by Qodo
1. Expired signing keys can go unreported
|
Merging this PR will not alter performance
Comparing Footnotes
|
What
vis inspect <package> --json --only signaturesruns natively. Stacked on #264 (which is stacked on #262): it uses theirServicesaddresses inContext,version_entryand the test stub. Merge in order and retarget each PR tonextas its base lands (GitHub does it by itself only when merged branches are deleted). Followed by #266.signaturesis not part of the default set (it runs only when asked for with--only signatures), so this PR does not change what a plainvis inspect <package> --jsondoes.Behaviour
~/.vis/cache/registry-keys/npmjs.json, 24 hours) else a request toVIS_NPM_KEYS_URLorhttps://registry.npmjs.org/-/npm/v1/keys.VIS_NPM_KEYS_URLis a variable the Node side already reads, so both sides honour it and it is also the loopback address of the parity tests; no new override. A fresh answer is cached in the bytes Node writes ({"createdAt","keys","ttlMs"},keysasJSON.stringifywrites them, through the same readersecurity keys-refreshuses). A status other than 2xx falls back to the old keys, or ends in thefetch-failedwarning, as Node does.dist.signatures/ nodist.integrity(warnings), keyid the registry does not list (error), expired key (warning), in Node's messages and order. A key withoutexpires, with an empty one, or withnull(npm's current key has"expires": null) never expires; a date in the form registries write is compared with the clock.name@version:integritywithring.Handed to Node before any output or write
A signature that does not verify here (so
invalid-signaturestays Node's report:createPublicKeyandBuffer.from(…, "base64")are lenient where this reader is strict, so "does not verify here" is not evidence Node agrees); a key that is not an uncompressed P-256 SubjectPublicKeyInfo in canonical base64; anexpiresin any other form; a keys request that fails before an answer; a redirect; a keys answer or cache file that is not what Node reads (not JSON, not an object, no numericcreatedAt/ttlMs, nokeysarray); aVIS_NPM_KEYS_URLthat is not text or not a plain URL.Dependency
ringis now named innative/cli/Cargo.toml(ring = { version = "0.17", default-features = false }). It is already linked:rustls(featurering) andurequse 0.17.14, soCargo.lockgains one line (the dependency edge) and no package, and the features are the ones already unified.cargo deny check: advisories, bans, licenses and sources ok. I chose it over a pure-Rustp256because it adds nothing to the binary; verification code is the onerustlsalready trusts for TLS signatures.Proof
cargo test -p vis-cli: unit tests with keys generated at test time (every finding, the exact cache bytes, fresh/stale/refused keys, hand-overs, canonical base64 and SPKI parsing, expiry forms);cargo fmt --all --check,cargo clippy -p vis-cli --all-targets -- -D warnings,cargo deny checkclean.__tests__/native/inspect-parity.test.ts: native vs Node on the stub registry and a stub keys endpoint (keys and signatures generated withnode:crypto): good, two signatures (one unknown), expired key, key that expires far ahead,nullexpiry, no signature, no integrity, keys answered 500 and{}, fresh/old/refreshed key cache, with identical stdout, exit status and cache bytes;invalidand malformed signatures and a non-JSON keys answer are handed over (exit 70, nothing touched) and the delegated run matches Node.left-pad@1.3.0(signed with a now expired key),@types/node,typescript,esbuild@0.19.0,lodash@4.17.21in a scratch workspace with separate temp homes: identical stdout and identical cached keys, native without a Node fallback (real npm signatures verified byring).🤖 Generated with Claude Code