fix: Replace proxy-agent due to vm2 vulnerability (#6156)

This commit is contained in:
mamoyal
2025-10-01 20:20:32 +03:00
committed by GitHub
parent f65aebffb1
commit b398c8080e
3 changed files with 20 additions and 467 deletions

View File

@@ -1,6 +1,7 @@
const { Liquid } = require("liquidjs");
const { DOWN } = require("../../src/util");
const ProxyAgent = require("proxy-agent");
const { HttpProxyAgent } = require("http-proxy-agent");
const { HttpsProxyAgent } = require("https-proxy-agent");
class NotificationProvider {
@@ -125,9 +126,17 @@ class NotificationProvider {
getAxiosConfigWithProxy(axiosConfig = {}) {
const proxyEnv = process.env.notification_proxy || process.env.NOTIFICATION_PROXY;
if (proxyEnv) {
const agent = new ProxyAgent(proxyEnv);
axiosConfig.httpsAgent = agent;
axiosConfig.httpAgent = agent;
const proxyUrl = new URL(proxyEnv);
if (proxyUrl.protocol === "http:") {
axiosConfig.httpAgent = new HttpProxyAgent(proxyEnv);
axiosConfig.httpsAgent = new HttpsProxyAgent(proxyEnv);
} else if (proxyUrl.protocol === "https:") {
const agent = new HttpsProxyAgent(proxyEnv);
axiosConfig.httpAgent = agent;
axiosConfig.httpsAgent = agent;
}
axiosConfig.proxy = false;
}
return axiosConfig;