fix: Upgrade axios to address CVE-2023-45857 (#7713)

[GH Advisory](https://github.com/advisories/GHSA-wf5p-g6vw-rhxx)
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-19 16:17:01 +01:00
committed by GitHub
parent 8e6b951a76
commit 64eb9bbc36
11 changed files with 104 additions and 69 deletions

View File

@@ -43,6 +43,21 @@ class ResponseError extends Error {
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const legacyParamSerializer = (params: Record<string, any>) =>
Object.keys(params)
.filter((key) => params[key] !== undefined)
.map((key) => {
if (Array.isArray(params[key])) {
return params[key].map((v) => `${key}[]=${encodeURIComponent(v)}`).join('&');
}
if (typeof params[key] === 'object') {
params[key] = JSON.stringify(params[key]);
}
return `${key}=${encodeURIComponent(params[key])}`;
})
.join('&');
export async function request(config: {
method: Method;
baseURL: string;
@@ -67,8 +82,9 @@ export async function request(config: {
}
if (['POST', 'PATCH', 'PUT'].includes(method)) {
options.data = data;
} else {
} else if (data) {
options.params = data;
options.paramsSerializer = legacyParamSerializer;
}
try {