Add minimal proxy init code

This commit is contained in:
Michael B. Gale
2026-07-08 16:24:23 +01:00
parent 5172487de5
commit a29dee455c
3 changed files with 121 additions and 10 deletions

39
lib/entry-points.js generated
View File

@@ -8941,7 +8941,7 @@ var require_proxy_agent = __commonJS({
return this.#client.destroy(err);
}
};
var ProxyAgent = class extends DispatcherBase {
var ProxyAgent2 = class extends DispatcherBase {
constructor(opts) {
super();
if (!opts || typeof opts === "object" && !(opts instanceof URL2) && !opts.uri) {
@@ -9082,7 +9082,7 @@ var require_proxy_agent = __commonJS({
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
}
}
module2.exports = ProxyAgent;
module2.exports = ProxyAgent2;
}
});
@@ -9092,7 +9092,7 @@ var require_env_http_proxy_agent = __commonJS({
"use strict";
var DispatcherBase = require_dispatcher_base();
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
var ProxyAgent = require_proxy_agent();
var ProxyAgent2 = require_proxy_agent();
var Agent = require_agent();
var DEFAULT_PORTS = {
"http:": 80,
@@ -9116,13 +9116,13 @@ var require_env_http_proxy_agent = __commonJS({
this[kNoProxyAgent] = new Agent(agentOpts);
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
if (HTTP_PROXY) {
this[kHttpProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTP_PROXY });
this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY });
} else {
this[kHttpProxyAgent] = this[kNoProxyAgent];
}
const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
if (HTTPS_PROXY) {
this[kHttpsProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTPS_PROXY });
this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY });
} else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent];
}
@@ -18906,7 +18906,7 @@ var require_undici = __commonJS({
var Pool = require_pool();
var BalancedPool = require_balanced_pool();
var Agent = require_agent();
var ProxyAgent = require_proxy_agent();
var ProxyAgent2 = require_proxy_agent();
var EnvHttpProxyAgent = require_env_http_proxy_agent();
var RetryAgent = require_retry_agent();
var errors = require_errors();
@@ -18929,7 +18929,7 @@ var require_undici = __commonJS({
module2.exports.Pool = Pool;
module2.exports.BalancedPool = BalancedPool;
module2.exports.Agent = Agent;
module2.exports.ProxyAgent = ProxyAgent;
module2.exports.ProxyAgent = ProxyAgent2;
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent;
module2.exports.RetryAgent = RetryAgent;
module2.exports.RetryHandler = RetryHandler;
@@ -145590,6 +145590,9 @@ function retry(octokit, octokitOptions) {
}
retry.VERSION = VERSION7;
// src/api-client.ts
var import_undici = __toESM(require_undici());
// src/repository.ts
function getRepositoryNwo() {
return getRepositoryNwoFromEnv("GITHUB_REPOSITORY");
@@ -145617,6 +145620,27 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
var DO_NOT_RETRY_STATUSES = [400, 410, 422, 451];
function getRegistryProxy(env) {
const host = env.getOptional("CODEQL_PROXY_HOST" /* PROXY_HOST */);
const port = env.getOptional("CODEQL_PROXY_PORT" /* PROXY_PORT */);
const cert = env.getOptional("CODEQL_PROXY_CA_CERTIFICATE" /* PROXY_CA_CERTIFICATE */);
if (host && port) {
return new import_undici.ProxyAgent({
uri: `http://${host}:${port}`,
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
requestTls: cert ? { ca: cert } : void 0
});
}
return void 0;
}
function getApiFetch(env) {
const dispatcher = getRegistryProxy(env);
const proxiedFetch = (req, init2) => {
return (0, import_undici.fetch)(req, { ...init2, dispatcher });
};
return proxiedFetch;
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth2 = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry);
@@ -145630,6 +145654,7 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
warn: core5.warning,
error: core5.error
},
request: { fetch: getApiFetch(getEnv()) },
retry: {
doNotRetry: DO_NOT_RETRY_STATUSES
}