Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm audit doesn't respect proxy setting #3755

Closed
MBelniak opened this issue Sep 8, 2021 · 3 comments · Fixed by #4057
Closed

pnpm audit doesn't respect proxy setting #3755

MBelniak opened this issue Sep 8, 2021 · 3 comments · Fixed by #4057
Projects
Milestone

Comments

@MBelniak
Copy link
Contributor

MBelniak commented Sep 8, 2021

pnpm version:

6.14.7

Code to reproduce the issue:

pnpm audit --registry https://registry.npmjs.org/

I have HTTP_PROXY and HTTPS_PROXY variables set as well as proxy and https-proxy in .npmrc file.
My package.json contains only one dependency for simplicity: "chalk": "^4.1.0"

Expected behavior:

Similar to yarn audit and npm audit.

Actual behavior:

WARN  post https://registry.npmjs.org/-/npm/v1/security/audits error (undefined). Will retry in 10 milliseconds. 5 retries left.

Additional information:

  • node -v prints: v14.15.4
  • Windows, macOS, or Linux?: Linux Ubuntu 20.04

My PC is behind a corporate proxy. To check the validity of the request I copied the request's body which pnpm.cjs prepares and I used Postman to send it. It works OK as long as I have 'Use the system proxy' setting checked. I analyzed a bit of code of fetchFromRegistry.ts and I didn't find any proxy agent being used. I came across #2650 and #3403 but that doesn't seem to address this exact issue.

@erlendk
Copy link

erlendk commented Nov 30, 2021

I have a similar experience with pnpm version 6.23.2. I am trying to run pnpm audit inside a Docker container set up both with proxy settings in .npmrc and environment variables, same as @MBelniak. The behavior is more or less the same as well. The pnpm install command use the proxy settings, but audit does not.

From reading the pnpm source code it seems to me that the audit code use the regular fetchRetry function from the '@pnpm/fetch' package, instead of using the createFetchFromRegistry function or any other function utilizing the '@pnpm/npm-registry-agent' package.

@erlendk
Copy link

erlendk commented Dec 1, 2021

@zkochan Can you confirm whether this is a real bug or us missing something?

@zkochan
Copy link
Member

zkochan commented Dec 1, 2021

We need to init and pass the proxy agent to the fetch function

https://github.com/pnpm/pnpm/blob/8a99a01ff691fc2cc3b6a497c11c4bbcf2155cdb/packages/audit/src/index.ts

@zkochan zkochan added this to Priority in Status Dec 1, 2021
zkochan added a commit that referenced this issue Dec 1, 2021
@zkochan zkochan moved this from Priority to in progress in Status Dec 1, 2021
@zkochan zkochan added this to the v6.23 milestone Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status
in progress
Development

Successfully merging a pull request may close this issue.

3 participants