fix: abort proxied requests when CONNECT does not return HTTP 200 (#2037)

* fix: abort proxied requests when CONNECT does not return HTTP 200

* chore: collapse error construction to satisfy biome formatter

---------

Co-authored-by: GitHub Actions <github-aws-sdk-osds-automation@amazon.com>
This commit is contained in:
Tom KellerandGitHub Actions authored and GitHub committed 2026-11-24 15:38:50 -08:00
1 parent 416c15366b
commit f9f13dcf7f
5 files changed
+190 -22

No files matched your search

Generated Vendored
+14 -2
View File
@@ -75464,6 +75464,14 @@ function maskProxyCredentials(proxyServer) {
}
}
}
function verifyProxyConnect(req) {
req.once("proxyConnect", (response) => {
if (response.statusCode !== 200) {
const statusText = response.statusText ? ` ${response.statusText}` : "";
req.destroy(new Error(`Proxy CONNECT returned HTTP ${response.statusCode}${statusText}; aborting`));
}
});
}
function sanitizeGitHubVariables(name) {
const nameWithoutSpecialCharacters = name.replace(/[^\p{L}\p{Z}\p{N}_.:/=+\-@]/gu, SANITIZATION_CHARACTER);
const nameTruncated = nameWithoutSpecialCharacters.slice(0, MAX_TAG_VALUE_LENGTH);
@@ -76991,8 +76999,12 @@ var DEFAULT_PORTS3 = {
var ProxyResolver = class {
constructor(options) {
// This method matches the interface expected by 'proxy-agent'. It is an arrow function to bind 'this'.
this.getProxyForUrl = (url, _req) => {
return this.getProxyForUrlOptions(url, this.options);
// It is the only per-request hook proxy-agent exposes, so it is also where CONNECT enforcement is
// attached: proxy-agent calls it with the live request before the proxy connection is made.
this.getProxyForUrl = (url, req) => {
const proxy = this.getProxyForUrlOptions(url, this.options);
if (proxy) verifyProxyConnect(req);
return proxy;
};
this.options = options;
}