From eac7859fccf1de06122f845fa55b70b51d1dc705 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 25 Aug 2020 01:48:11 +0630 Subject: [PATCH] fix: NO_PROXY env var no longer be respected over npm_config_noproxy env var (#8295) Co-authored-by: Zach Bloomquist --- packages/https-proxy/package.json | 2 +- packages/https-proxy/test/integration/proxy_spec.js | 7 ++++++- packages/network/package.json | 2 +- packages/network/test/unit/agent_spec.ts | 5 +++++ packages/server/lib/util/proxy.ts | 2 +- yarn.lock | 7 ++++++- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/https-proxy/package.json b/packages/https-proxy/package.json index 1fe7859d38db..d1d28fb9f046 100644 --- a/packages/https-proxy/package.json +++ b/packages/https-proxy/package.json @@ -19,7 +19,7 @@ "fs-extra": "8.1.0", "lodash": "4.17.19", "node-forge": "0.9.0", - "proxy-from-env": "1.1.0", + "proxy-from-env": "1.0.0", "semaphore": "1.1.0" }, "devDependencies": { diff --git a/packages/https-proxy/test/integration/proxy_spec.js b/packages/https-proxy/test/integration/proxy_spec.js index 40d94aa47281..65ab9355eb9a 100644 --- a/packages/https-proxy/test/integration/proxy_spec.js +++ b/packages/https-proxy/test/integration/proxy_spec.js @@ -229,8 +229,13 @@ describe('Proxy', () => { context('with an upstream proxy', () => { beforeEach(function () { + // PROXY vars should override npm_config vars, so set them to cause failures if they are used + // @see https://github.com/cypress-io/cypress/pull/8295 + process.env.npm_config_proxy = process.env.npm_config_https_proxy = 'http://erroneously-used-npm-proxy.invalid' + process.env.npm_config_noproxy = 'just,some,nonsense' + process.env.NO_PROXY = '' - process.env.HTTP_PROXY = (process.env.HTTPS_PROXY = 'http://localhost:9001') + process.env.HTTP_PROXY = process.env.HTTPS_PROXY = 'http://localhost:9001' this.upstream = new DebugProxy({ keepRequests: true, diff --git a/packages/network/package.json b/packages/network/package.json index f31503436964..4ed36032fe73 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -18,7 +18,7 @@ "concat-stream": "1.6.2", "debug": "4.1.1", "lodash": "4.17.19", - "proxy-from-env": "1.1.0" + "proxy-from-env": "1.0.0" }, "devDependencies": { "@cypress/debugging-proxy": "2.0.1", diff --git a/packages/network/test/unit/agent_spec.ts b/packages/network/test/unit/agent_spec.ts index e049f7b1351e..2c955639dd16 100644 --- a/packages/network/test/unit/agent_spec.ts +++ b/packages/network/test/unit/agent_spec.ts @@ -74,6 +74,11 @@ describe('lib/agent', function () { context(testCase.name, function () { beforeEach(function () { if (testCase.proxyUrl) { + // PROXY vars should override npm_config vars, so set them to cause failures if they are used + // @see https://github.com/cypress-io/cypress/pull/8295 + process.env.npm_config_proxy = process.env.npm_config_https_proxy = 'http://erroneously-used-npm-proxy.invalid' + process.env.npm_config_noproxy = 'just,some,nonsense' + process.env.HTTP_PROXY = process.env.HTTPS_PROXY = testCase.proxyUrl process.env.NO_PROXY = '' } diff --git a/packages/server/lib/util/proxy.ts b/packages/server/lib/util/proxy.ts index eb8465dbf760..d0f57298f6fd 100644 --- a/packages/server/lib/util/proxy.ts +++ b/packages/server/lib/util/proxy.ts @@ -71,7 +71,7 @@ export const loadSystemProxySettings = () => { debug('found proxy environment variables %o', _.pick(process.env, [ 'NO_PROXY', 'HTTP_PROXY', 'HTTPS_PROXY', 'no_proxy', 'http_proxy', 'https_proxy', - 'npm_config_proxy', 'npm_config_https_proxy', + 'npm_config_proxy', 'npm_config_https_proxy', 'npm_config_noproxy', ])) ;['NO_PROXY', 'HTTP_PROXY', 'HTTPS_PROXY'].forEach(copyLowercaseEnvToUppercase) diff --git a/yarn.lock b/yarn.lock index c244ab11c0cc..e2bc1b32ccba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20423,7 +20423,12 @@ proxy-addr@~2.0.5: forwarded "~0.1.2" ipaddr.js "1.9.1" -proxy-from-env@1.1.0, proxy-from-env@^1.0.0: +proxy-from-env@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= + +proxy-from-env@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==