Skip to content

Commit 649c1a7

Browse files
fix: apply audit fixes
1 parent f23ab31 commit 649c1a7

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

dist/index.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76765,6 +76765,13 @@ function requireFollowRedirects () {
7676576765
useNativeURL = error.code === "ERR_INVALID_URL";
7676676766
}
7676776767

76768+
// HTTP headers to drop across HTTP/HTTPS and domain boundaries
76769+
var sensitiveHeaders = [
76770+
"Authorization",
76771+
"Proxy-Authorization",
76772+
"Cookie",
76773+
];
76774+
7676876775
// URL fields to preserve in copy operations
7676976776
var preservedUrlFields = [
7677076777
"auth",
@@ -76846,6 +76853,11 @@ function requireFollowRedirects () {
7684676853
}
7684776854
};
7684876855

76856+
// Create filter for sensitive HTTP headers
76857+
this._headerFilter = new RegExp("^(?:" +
76858+
sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") +
76859+
")$", "i");
76860+
7684976861
// Perform the first request
7685076862
this._performRequest();
7685176863
}
@@ -77029,6 +77041,9 @@ function requireFollowRedirects () {
7702977041
if (!options.headers) {
7703077042
options.headers = {};
7703177043
}
77044+
if (!isArray(options.sensitiveHeaders)) {
77045+
options.sensitiveHeaders = [];
77046+
}
7703277047

7703377048
// Since http.request treats host as an alias of hostname,
7703477049
// but the url module interprets host as hostname plus port,
@@ -77211,7 +77226,7 @@ function requireFollowRedirects () {
7721177226
redirectUrl.protocol !== "https:" ||
7721277227
redirectUrl.host !== currentHost &&
7721377228
!isSubdomain(redirectUrl.host, currentHost)) {
77214-
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
77229+
removeMatchingHeaders(this._headerFilter, this._options.headers);
7721577230
}
7721677231

7721777232
// Evaluate the beforeRedirect callback
@@ -77404,6 +77419,10 @@ function requireFollowRedirects () {
7740477419
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
7740577420
}
7740677421

77422+
function isArray(value) {
77423+
return value instanceof Array;
77424+
}
77425+
7740777426
function isString(value) {
7740877427
return typeof value === "string" || value instanceof String;
7740977428
}
@@ -77420,6 +77439,10 @@ function requireFollowRedirects () {
7742077439
return URL && value instanceof URL;
7742177440
}
7742277441

77442+
function escapeRegex(regex) {
77443+
return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
77444+
}
77445+
7742377446
// Exports
7742477447
followRedirects$1.exports = wrap({ http: http, https: https });
7742577448
followRedirects$1.exports.wrap = wrap;

0 commit comments

Comments
 (0)