Skip to content

Commit 6d67579

Browse files
committedMar 30, 2021
fix: replace vulnerable proxy dependency
1 parent 1449c57 commit 6d67579

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"configstore": "^5.0.1",
8787
"debug": "^4.1.1",
8888
"diff": "^4.0.1",
89+
"global-agent": "^2.1.12",
8990
"hcl-to-json": "^0.1.1",
9091
"lodash.assign": "^4.2.0",
9192
"lodash.camelcase": "^4.3.0",
@@ -110,7 +111,6 @@
110111
"ora": "5.3.0",
111112
"os-name": "^3.0.0",
112113
"promise-queue": "^2.2.5",
113-
"proxy-agent": "^3.1.1",
114114
"proxy-from-env": "^1.0.0",
115115
"rimraf": "^2.6.3",
116116
"semver": "^6.0.0",

‎src/lib/request/request.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as querystring from 'querystring';
55
import * as zlib from 'zlib';
66
import * as config from '../config';
77
import { getProxyForUrl } from 'proxy-from-env';
8-
import * as ProxyAgent from 'proxy-agent';
8+
import { bootstrap } from 'global-agent';
99
import * as analytics from '../analytics';
1010
import { Global } from '../../cli/args';
1111
import { Payload } from './types';
@@ -120,8 +120,9 @@ export = function makeRequest(
120120
const proxyUri = getProxyForUrl(url);
121121
if (proxyUri) {
122122
snykDebug('using proxy:', proxyUri);
123-
// proxyAgent type is an EventEmitter and not an http Agent
124-
options.agent = (new ProxyAgent(proxyUri) as unknown) as http.Agent;
123+
bootstrap({
124+
environmentVariableNamespace: '',
125+
});
125126
} else {
126127
snykDebug('not using proxy');
127128
}

‎test/request.test.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ test('request with https proxy calls needle as expected', (t) => {
283283
follow_max: 5, // default
284284
timeout: 300000, // default
285285
json: undefined, // default
286-
agent: sinon.match({
287-
proxy: sinon.match({
288-
href: 'https://proxy:8443/', // should be set when using proxy
289-
}),
290-
}),
286+
agent: sinon.match.truthy,
291287
rejectUnauthorized: undefined, // should not be set when not use insecure mode
292288
}),
293289
sinon.match.func, // callback function
@@ -335,11 +331,7 @@ test('request with http proxy calls needle as expected', (t) => {
335331
follow_max: 5, // default
336332
timeout: 300000, // default
337333
json: undefined, // default
338-
agent: sinon.match({
339-
proxy: sinon.match({
340-
href: 'http://proxy:8080/', // should be set when using proxy
341-
}),
342-
}),
334+
agent: sinon.match.truthy,
343335
rejectUnauthorized: undefined, // should not be set when not use insecure mode
344336
}),
345337
sinon.match.func, // callback function

0 commit comments

Comments
 (0)
Please sign in to comment.