From dc92ab6239882e606e05bdd154915f887765d7f2 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Tue, 30 Jul 2024 17:58:20 +0200 Subject: [PATCH 1/7] Consider registries_credentials as input --- lib/start-proxy-action.js | 71 ++++++++++++++++++++--------- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 86 ++++++++++++++++++++++++----------- start-proxy/action.yml | 3 ++ 4 files changed, 113 insertions(+), 49 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 7ce62b08d1..d5984df97f 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -79,40 +79,32 @@ function generateCertificateAuthority() { return { cert: pem, key }; } async function runWrapper() { + // Setup logging const tempDir = actionsUtil.getTemporaryDirectory(); const logFilePath = path.resolve(tempDir, "proxy.log"); - const input = actionsUtil.getOptionalInput("registry_secrets") || "[]"; - const credentials = JSON.parse(input); - const ca = generateCertificateAuthority(); - const proxy_password = actionsUtil.getOptionalInput("proxy_password"); core.saveState("proxy-log-file", logFilePath); - let proxy_auth = undefined; - if (proxy_password) { - proxy_auth = { - username: PROXY_USER, - password: proxy_password, - }; - } + // Get the configuration options + const credentials = getCredentials(); + const ca = generateCertificateAuthority(); + const proxyAuth = getProxyAuth(); const proxyConfig = { all_credentials: credentials, ca, - proxy_auth, + proxy_auth: proxyAuth, }; + // Start the Proxy + const proxyBin = await getProxyBinaryPath(); + await startProxy(proxyBin, proxyConfig, logFilePath); +} +async function startProxy(binPath, config, logFilePath) { const host = "127.0.0.1"; - let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); - if (!proxyBin) { - const temp = await toolcache.downloadTool(UPDATEJOB_PROXY_URL); - const extracted = await toolcache.extractTar(temp); - proxyBin = await toolcache.cacheDir(extracted, UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); - } - proxyBin = path.join(proxyBin, UPDATEJOB_PROXY); let port = 49152; try { let subprocess = undefined; let tries = 5; let subprocessError = undefined; while (tries-- > 0 && !subprocess && !subprocessError) { - subprocess = (0, child_process_1.spawn)(proxyBin, ["-addr", `${host}:${port}`, "-config", "-", "-logfile", logFilePath], { + subprocess = (0, child_process_1.spawn)(binPath, ["-addr", `${host}:${port}`, "-config", "-", "-logfile", logFilePath], { detached: true, stdio: ["pipe", "ignore", "ignore"], }); @@ -130,7 +122,7 @@ async function runWrapper() { subprocess = undefined; } }); - subprocess.stdin?.write(JSON.stringify(proxyConfig)); + subprocess.stdin?.write(JSON.stringify(config)); subprocess.stdin?.end(); // Wait a little to allow the proxy to start await util.delay(1000); @@ -141,11 +133,46 @@ async function runWrapper() { core.info(`Proxy started on ${host}:${port}`); core.setOutput("proxy_host", host); core.setOutput("proxy_port", port.toString()); - core.setOutput("proxy_ca_certificate", ca.cert); + core.setOutput("proxy_ca_certificate", config.ca.cert); } catch (error) { core.setFailed(`start-proxy action failed: ${util.wrapError(error).message}`); } } +// getCredentials returns registry credentials from action inputs. +// It prefers `registries_credentials` over `registry_secrets`. +// If neither is set, it returns an empty array. +function getCredentials() { + const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); + if (encodedCredentials !== undefined) { + core.info(`Using encoded credentials.`); + const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); + return JSON.parse(credentialsStr); + } + core.info(`Using structured credentials.`); + const registrySecrets = actionsUtil.getOptionalInput("registry_secrets") || "[]"; + return JSON.parse(registrySecrets); +} +// getProxyAuth returns the authentication information for the proxy itself. +function getProxyAuth() { + const proxy_password = actionsUtil.getOptionalInput("proxy_password"); + if (proxy_password) { + return { + username: PROXY_USER, + password: proxy_password, + }; + } + return; +} +async function getProxyBinaryPath() { + let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); + if (!proxyBin) { + const temp = await toolcache.downloadTool(UPDATEJOB_PROXY_URL); + const extracted = await toolcache.extractTar(temp); + proxyBin = await toolcache.cacheDir(extracted, UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); + } + proxyBin = path.join(proxyBin, UPDATEJOB_PROXY); + return proxyBin; +} void runWrapper(); //# sourceMappingURL=start-proxy-action.js.map \ No newline at end of file diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index c124342d47..afa1bfdb52 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAE/B,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA0B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAC;AAEF,SAAS,4BAA4B;IACnC,MAAM,IAAI,GAAG,gBAAG,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,gBAAG,CAAC,iBAAiB,EAAE,CAAC;IACrC,IAAI,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AAI,CAAC,SAAS,CAAC,sBAAsB,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,8BAA8B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAE/B,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA0B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAC;AAEF,SAAS,4BAA4B;IACnC,MAAM,IAAI,GAAG,gBAAG,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG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-action.ts index 57074a0b8d..eab898fb69 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -89,38 +89,29 @@ function generateCertificateAuthority(): CertificateAuthority { } async function runWrapper() { + // Setup logging const tempDir = actionsUtil.getTemporaryDirectory(); const logFilePath = path.resolve(tempDir, "proxy.log"); - const input = actionsUtil.getOptionalInput("registry_secrets") || "[]"; - const credentials = JSON.parse(input) as Credential[]; - const ca = generateCertificateAuthority(); - const proxy_password = actionsUtil.getOptionalInput("proxy_password"); core.saveState("proxy-log-file", logFilePath); - let proxy_auth: BasicAuthCredentials | undefined = undefined; - if (proxy_password) { - proxy_auth = { - username: PROXY_USER, - password: proxy_password, - }; - } + // Get the configuration options + const credentials = getCredentials(); + const ca = generateCertificateAuthority(); + const proxyAuth = getProxyAuth(); + const proxyConfig: ProxyConfig = { all_credentials: credentials, ca, - proxy_auth, + proxy_auth: proxyAuth, }; + + // Start the Proxy + const proxyBin = await getProxyBinaryPath(); + await startProxy(proxyBin, proxyConfig, logFilePath); +} + +async function startProxy(binPath: string, config: ProxyConfig, logFilePath: string) { const host = "127.0.0.1"; - let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); - if (!proxyBin) { - const temp = await toolcache.downloadTool(UPDATEJOB_PROXY_URL); - const extracted = await toolcache.extractTar(temp); - proxyBin = await toolcache.cacheDir( - extracted, - UPDATEJOB_PROXY, - UPDATEJOB_PROXY_VERSION, - ); - } - proxyBin = path.join(proxyBin, UPDATEJOB_PROXY); let port = 49152; try { let subprocess: ChildProcess | undefined = undefined; @@ -128,7 +119,7 @@ async function runWrapper() { let subprocessError: Error | undefined = undefined; while (tries-- > 0 && !subprocess && !subprocessError) { subprocess = spawn( - proxyBin, + binPath, ["-addr", `${host}:${port}`, "-config", "-", "-logfile", logFilePath], { detached: true, @@ -149,7 +140,7 @@ async function runWrapper() { subprocess = undefined; } }); - subprocess.stdin?.write(JSON.stringify(proxyConfig)); + subprocess.stdin?.write(JSON.stringify(config)); subprocess.stdin?.end(); // Wait a little to allow the proxy to start await util.delay(1000); @@ -160,7 +151,7 @@ async function runWrapper() { core.info(`Proxy started on ${host}:${port}`); core.setOutput("proxy_host", host); core.setOutput("proxy_port", port.toString()); - core.setOutput("proxy_ca_certificate", ca.cert); + core.setOutput("proxy_ca_certificate", config.ca.cert); } catch (error) { core.setFailed( `start-proxy action failed: ${util.wrapError(error).message}`, @@ -168,4 +159,47 @@ async function runWrapper() { } } +// getCredentials returns registry credentials from action inputs. +// It prefers `registries_credentials` over `registry_secrets`. +// If neither is set, it returns an empty array. +function getCredentials(): Credential[] { + const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); + if (encodedCredentials !== undefined) { + core.info(`Using encoded credentials.`); + const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); + return JSON.parse(credentialsStr) as Credential[]; + } + core.info(`Using structured credentials.`); + const registrySecrets = actionsUtil.getOptionalInput("registry_secrets") || "[]"; + return JSON.parse(registrySecrets) as Credential[]; +} + +// getProxyAuth returns the authentication information for the proxy itself. +function getProxyAuth(): BasicAuthCredentials | undefined{ + const proxy_password = actionsUtil.getOptionalInput("proxy_password"); + if (proxy_password) { + return { + username: PROXY_USER, + password: proxy_password, + }; + } + return ; +} + + +async function getProxyBinaryPath(): Promise { + let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); + if (!proxyBin) { + const temp = await toolcache.downloadTool(UPDATEJOB_PROXY_URL); + const extracted = await toolcache.extractTar(temp); + proxyBin = await toolcache.cacheDir( + extracted, + UPDATEJOB_PROXY, + UPDATEJOB_PROXY_VERSION, + ); + } + proxyBin = path.join(proxyBin, UPDATEJOB_PROXY); + return proxyBin; +} + void runWrapper(); diff --git a/start-proxy/action.yml b/start-proxy/action.yml index bbebeeb5a5..cba91f1cb3 100644 --- a/start-proxy/action.yml +++ b/start-proxy/action.yml @@ -6,6 +6,9 @@ inputs: description: The URLs and credentials of package registries required: false default: "[]" + registries_credentials: + description: Base64 encoded JSON configuration for the URLs and credentials of the package registries + required: false proxy_password: required: false description: The password of the proxy From 3b3012e89150bc271a5d890f469795cd505d9856 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Fri, 2 Aug 2024 08:12:51 +0000 Subject: [PATCH 2/7] Clean-up logging --- lib/start-proxy-action.js | 16 +++++++++------- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 18 +++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index d5984df97f..c59a11f5f5 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -30,6 +30,7 @@ const toolcache = __importStar(require("@actions/tool-cache")); const node_forge_1 = require("node-forge"); const actionsUtil = __importStar(require("./actions-util")); const util = __importStar(require("./util")); +const logging_1 = require("./logging"); const UPDATEJOB_PROXY = "update-job-proxy"; const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912"; const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.18.1/update-job-proxy.tar.gz"; @@ -79,12 +80,14 @@ function generateCertificateAuthority() { return { cert: pem, key }; } async function runWrapper() { - // Setup logging + const logger = (0, logging_1.getActionsLogger)(); + // Setup logging for the proxy const tempDir = actionsUtil.getTemporaryDirectory(); - const logFilePath = path.resolve(tempDir, "proxy.log"); - core.saveState("proxy-log-file", logFilePath); + const proxyLogFilePath = path.resolve(tempDir, "proxy.log"); + core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options const credentials = getCredentials(); + logger.debug(`Credentials loaded for the following URLs:\n ${credentials.map(c => c.host).join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); const proxyConfig = { @@ -94,9 +97,9 @@ async function runWrapper() { }; // Start the Proxy const proxyBin = await getProxyBinaryPath(); - await startProxy(proxyBin, proxyConfig, logFilePath); + await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger); } -async function startProxy(binPath, config, logFilePath) { +async function startProxy(binPath, config, logFilePath, logger) { const host = "127.0.0.1"; let port = 49152; try { @@ -130,7 +133,7 @@ async function startProxy(binPath, config, logFilePath) { if (subprocessError) { throw subprocessError; } - core.info(`Proxy started on ${host}:${port}`); + logger.info(`Proxy started on ${host}:${port}`); core.setOutput("proxy_host", host); core.setOutput("proxy_port", port.toString()); core.setOutput("proxy_ca_certificate", config.ca.cert); @@ -145,7 +148,6 @@ async function startProxy(binPath, config, logFilePath) { function getCredentials() { const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); if (encodedCredentials !== undefined) { - core.info(`Using encoded credentials.`); const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); return JSON.parse(credentialsStr); } diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index afa1bfdb52..b9093b8285 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAE/B,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA0B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI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AAC;QACnD,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CACjC,SAAS,EACT,eAAe,EACf,uBAAuB,CACxB,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAC/B,uCAAqD;AAErD,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA0B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAC;AAEF,SAAS,4BAA4B;IACnC,MAAM,IAAI,GAAG,gBAAG,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,g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CAAC;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index eab898fb69..c39a67d691 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -7,6 +7,7 @@ import { pki } from "node-forge"; import * as actionsUtil from "./actions-util"; import * as util from "./util"; +import { getActionsLogger, Logger } from "./logging"; const UPDATEJOB_PROXY = "update-job-proxy"; const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912"; @@ -89,13 +90,17 @@ function generateCertificateAuthority(): CertificateAuthority { } async function runWrapper() { - // Setup logging + const logger = getActionsLogger(); + + // Setup logging for the proxy const tempDir = actionsUtil.getTemporaryDirectory(); - const logFilePath = path.resolve(tempDir, "proxy.log"); - core.saveState("proxy-log-file", logFilePath); + const proxyLogFilePath = path.resolve(tempDir, "proxy.log"); + core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options const credentials = getCredentials(); + logger.debug(`Credentials loaded for the following URLs:\n ${credentials.map(c => c.host).join("\n")}`) + const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); @@ -107,10 +112,10 @@ async function runWrapper() { // Start the Proxy const proxyBin = await getProxyBinaryPath(); - await startProxy(proxyBin, proxyConfig, logFilePath); + await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger); } -async function startProxy(binPath: string, config: ProxyConfig, logFilePath: string) { +async function startProxy(binPath: string, config: ProxyConfig, logFilePath: string, logger: Logger) { const host = "127.0.0.1"; let port = 49152; try { @@ -148,7 +153,7 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str if (subprocessError) { throw subprocessError; } - core.info(`Proxy started on ${host}:${port}`); + logger.info(`Proxy started on ${host}:${port}`); core.setOutput("proxy_host", host); core.setOutput("proxy_port", port.toString()); core.setOutput("proxy_ca_certificate", config.ca.cert); @@ -165,7 +170,6 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str function getCredentials(): Credential[] { const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); if (encodedCredentials !== undefined) { - core.info(`Using encoded credentials.`); const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); return JSON.parse(credentialsStr) as Credential[]; } From e4afb79aebc45c535a0f858aa8deafd769dd0c0e Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Tue, 13 Aug 2024 13:31:10 +0000 Subject: [PATCH 3/7] More debugging of credentials --- lib/start-proxy-action.js | 5 ++++- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index c59a11f5f5..d08f5fcdf2 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -37,6 +37,9 @@ const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/do const PROXY_USER = "proxy_user"; const KEY_SIZE = 2048; const KEY_EXPIRY_YEARS = 2; +function CredentialToStr(c) { + return `Type: ${c.type}; Host: ${c.host}; Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; +} const CERT_SUBJECT = [ { name: "commonName", @@ -87,7 +90,7 @@ async function runWrapper() { core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options const credentials = getCredentials(); - logger.debug(`Credentials loaded for the following URLs:\n ${credentials.map(c => c.host).join("\n")}`); + logger.info(`Credentials loaded for the following URLs:\n ${credentials.map(c => CredentialToStr(c)).join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); const proxyConfig = { diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index b9093b8285..eecce5df36 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["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proxy-action.ts index c39a67d691..07c39b9156 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -30,6 +30,10 @@ export type Credential = { token?: string; }; +function CredentialToStr(c: Credential): string { + return `Type: ${c.type}; Host: ${c.host}; Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` +} + export type BasicAuthCredentials = { username: string; password: string; @@ -99,7 +103,7 @@ async function runWrapper() { // Get the configuration options const credentials = getCredentials(); - logger.debug(`Credentials loaded for the following URLs:\n ${credentials.map(c => c.host).join("\n")}`) + logger.info(`Credentials loaded for the following URLs:\n ${credentials.map(c => CredentialToStr(c)).join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); From f7368810c64c517eaa2ec2605aa76c3ea2e11da7 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Tue, 13 Aug 2024 13:37:22 +0000 Subject: [PATCH 4/7] Support URL --- lib/start-proxy-action.js | 2 +- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index d08f5fcdf2..587c7e0adc 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -38,7 +38,7 @@ const PROXY_USER = "proxy_user"; const KEY_SIZE = 2048; const KEY_EXPIRY_YEARS = 2; function CredentialToStr(c) { - return `Type: ${c.type}; Host: ${c.host}; Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; + return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; } const CERT_SUBJECT = [ { diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index eecce5df36..5e7d7461ee 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-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AQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAC/B,uCAAqD;AAErD,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAgB3B,SAAS,eAAe,CAAC,CAAa;IACpC,OAAO,SAAS,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,QAAQ,eAAe,CAAC,CAAC,QAAQ,KAAK,SAAS,YAAY,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAA;AAC1J,CAAC;AAaD,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAC;AAEF,SAAS,4BAA4B;IACnC,MAAM,IAAI,GAAG,gBAAG,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ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AAS,EACT,eAAe,EACf,uBAAuB,CACxB,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index 07c39b9156..d952877a63 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -24,14 +24,15 @@ export type CertificateAuthority = { export type Credential = { type: string; - host: string; + host?: string; + url?: string; username?: string; password?: string; token?: string; }; function CredentialToStr(c: Credential): string { - return `Type: ${c.type}; Host: ${c.host}; Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` + return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` } export type BasicAuthCredentials = { From 5b34615fe07e76d4bff403e1d9eba235bf646c45 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Thu, 15 Aug 2024 11:04:35 +0000 Subject: [PATCH 5/7] Validate credentials input --- lib/start-proxy-action.js | 50 ++++++++++++++++++++-------- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 61 ++++++++++++++++++++++++----------- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index cd194bc320..4e79522b67 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -37,9 +37,6 @@ const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/do const PROXY_USER = "proxy_user"; const KEY_SIZE = 2048; const KEY_EXPIRY_YEARS = 2; -function CredentialToStr(c) { - return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; -} const CERT_SUBJECT = [ { name: "commonName", @@ -89,8 +86,8 @@ async function runWrapper() { const proxyLogFilePath = path.resolve(tempDir, "proxy.log"); core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options - const credentials = getCredentials(); - logger.info(`Credentials loaded for the following URLs:\n ${credentials.map(c => CredentialToStr(c)).join("\n")}`); + const credentials = getCredentials(logger); + logger.info(`Credentials loaded for the following registries:\n ${credentials.map(c => credentialToStr(c)).join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); const proxyConfig = { @@ -149,15 +146,39 @@ async function startProxy(binPath, config, logFilePath, logger) { // getCredentials returns registry credentials from action inputs. // It prefers `registries_credentials` over `registry_secrets`. // If neither is set, it returns an empty array. -function getCredentials() { - const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); - if (encodedCredentials !== undefined) { - const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); - return JSON.parse(credentialsStr); +function getCredentials(logger) { + const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials"); + const registrySecrets = actionsUtil.getOptionalInput("registry_secrets"); + var credentialsStr; + if (registriesCredentials !== undefined) { + logger.info(`Using registries_credentials input.`); + credentialsStr = Buffer.from(registriesCredentials, "base64").toString(); + } + else if (registrySecrets !== undefined) { + logger.info(`Using registry_secrets input.`); + credentialsStr = registrySecrets; + } + else { + logger.info(`No credentials defined.`); + return []; } - core.info(`Using structured credentials.`); - const registrySecrets = actionsUtil.getOptionalInput("registry_secrets") || "[]"; - return JSON.parse(registrySecrets); + // Parse and validate the credentials + const parsed = JSON.parse(credentialsStr); + let out = []; + parsed.forEach(e => { + if (e.url === undefined && e.host === undefined) { + throw "Invalid credentials - must specify host or url"; + } + out.push({ + type: e.type, + host: e.host, + url: e.url, + username: e.username, + password: e.password, + token: e.token, + }); + }); + return out; } // getProxyAuth returns the authentication information for the proxy itself. function getProxyAuth() { @@ -180,5 +201,8 @@ async function getProxyBinaryPath() { proxyBin = path.join(proxyBin, UPDATEJOB_PROXY); return proxyBin; } +function credentialToStr(c) { + return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; +} void runWrapper(); //# sourceMappingURL=start-proxy-action.js.map \ No newline at end of file diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index 85a5f463ad..08572ba5a0 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAC/B,uCAAqD;AAErD,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAgB3B,SAAS,eAAe,CAAC,CAAa;IACpC,OAAO,SAAS,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,QAAQ,eAAe,CAAC,CAAC,QAAQ,KAAK,SAAS,YAAY,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAA;AAC1J,CAAC;AAaD,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,K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MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnD,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CACjC,SAAS,EACT,eAAe,EACf,uBAAuB,CACxB,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACjD,2CAAiC;AAEjC,4DAA8C;AAC9C,6CAA+B;AAC/B,uCAAqD;AAErD,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AACtD,MAAM,mBAAmB,GACvB,yGAAyG,CAAC;AAC5G,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA2B3B,MAAM,YAAY,GAAG;IACnB;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;C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AC,KAAK,KAAK,SAAS,EAAE,CAAA;AAC1J,CAAC;AAGD,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index 69e791a3cb..ff535757d4 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -17,12 +17,12 @@ const PROXY_USER = "proxy_user"; const KEY_SIZE = 2048; const KEY_EXPIRY_YEARS = 2; -export type CertificateAuthority = { +type CertificateAuthority = { cert: string; key: string; }; -export type Credential = { +type Credential = { type: string; host?: string; url?: string; @@ -31,16 +31,12 @@ export type Credential = { token?: string; }; -function CredentialToStr(c: Credential): string { - return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` -} - -export type BasicAuthCredentials = { +type BasicAuthCredentials = { username: string; password: string; }; -export type ProxyConfig = { +type ProxyConfig = { all_credentials: Credential[]; ca: CertificateAuthority; proxy_auth?: BasicAuthCredentials; @@ -103,8 +99,8 @@ async function runWrapper() { core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options - const credentials = getCredentials(); - logger.info(`Credentials loaded for the following URLs:\n ${credentials.map(c => CredentialToStr(c)).join("\n")}`); + const credentials = getCredentials(logger); + logger.info(`Credentials loaded for the following registries:\n ${credentials.map(c => credentialToStr(c)).join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); @@ -173,15 +169,39 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str // getCredentials returns registry credentials from action inputs. // It prefers `registries_credentials` over `registry_secrets`. // If neither is set, it returns an empty array. -function getCredentials(): Credential[] { - const encodedCredentials = actionsUtil.getOptionalInput("registries_credentials"); - if (encodedCredentials !== undefined) { - const credentialsStr = Buffer.from(encodedCredentials, "base64").toString(); - return JSON.parse(credentialsStr) as Credential[]; +function getCredentials(logger: Logger): Credential[] { + const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials"); + const registrySecrets = actionsUtil.getOptionalInput("registry_secrets"); + + var credentialsStr: string; + if (registriesCredentials !== undefined) { + logger.info(`Using registries_credentials input.`); + credentialsStr = Buffer.from(registriesCredentials, "base64").toString(); + } else if (registrySecrets !== undefined) { + logger.info(`Using registry_secrets input.`); + credentialsStr = registrySecrets; + } else { + logger.info(`No credentials defined.`); + return []; } - core.info(`Using structured credentials.`); - const registrySecrets = actionsUtil.getOptionalInput("registry_secrets") || "[]"; - return JSON.parse(registrySecrets) as Credential[]; + + // Parse and validate the credentials + const parsed = JSON.parse(credentialsStr) as Credential[]; + let out: Credential[] = [] + parsed.forEach(e => { + if (e.url === undefined && e.host === undefined) { + throw "Invalid credentials - must specify host or url" + } + out.push({ + type: e.type, + host: e.host, + url: e.url, + username: e.username, + password: e.password, + token: e.token, + }) + }); + return out; } // getProxyAuth returns the authentication information for the proxy itself. @@ -212,4 +232,9 @@ async function getProxyBinaryPath(): Promise { return proxyBin; } +function credentialToStr(c: Credential): string { + return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` +} + + void runWrapper(); From 7baf39279e64e683e4a9e32dd9dd1aadd1e8c888 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Thu, 15 Aug 2024 12:17:00 +0000 Subject: [PATCH 6/7] fixes --- lib/start-proxy-action.js | 16 ++++++----- lib/start-proxy-action.js.map | 2 +- src/start-proxy-action.ts | 53 +++++++++++++++++++++-------------- start-proxy/action.yml | 2 +- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 4e79522b67..787d4864c9 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -29,8 +29,8 @@ const core = __importStar(require("@actions/core")); const toolcache = __importStar(require("@actions/tool-cache")); const node_forge_1 = require("node-forge"); const actionsUtil = __importStar(require("./actions-util")); -const util = __importStar(require("./util")); const logging_1 = require("./logging"); +const util = __importStar(require("./util")); const UPDATEJOB_PROXY = "update-job-proxy"; const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912"; const UPDATEJOB_PROXY_URL = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.18.1/update-job-proxy.tar.gz"; @@ -87,7 +87,9 @@ async function runWrapper() { core.saveState("proxy-log-file", proxyLogFilePath); // Get the configuration options const credentials = getCredentials(logger); - logger.info(`Credentials loaded for the following registries:\n ${credentials.map(c => credentialToStr(c)).join("\n")}`); + logger.info(`Credentials loaded for the following registries:\n ${credentials + .map((c) => credentialToStr(c)) + .join("\n")}`); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); const proxyConfig = { @@ -149,7 +151,7 @@ async function startProxy(binPath, config, logFilePath, logger) { function getCredentials(logger) { const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials"); const registrySecrets = actionsUtil.getOptionalInput("registry_secrets"); - var credentialsStr; + let credentialsStr; if (registriesCredentials !== undefined) { logger.info(`Using registries_credentials input.`); credentialsStr = Buffer.from(registriesCredentials, "base64").toString(); @@ -164,10 +166,10 @@ function getCredentials(logger) { } // Parse and validate the credentials const parsed = JSON.parse(credentialsStr); - let out = []; - parsed.forEach(e => { + const out = []; + for (const e of parsed) { if (e.url === undefined && e.host === undefined) { - throw "Invalid credentials - must specify host or url"; + throw new Error("Invalid credentials - must specify host or url"); } out.push({ type: e.type, @@ -177,7 +179,7 @@ function getCredentials(logger) { password: e.password, token: e.token, }); - }); + } return out; } // getProxyAuth returns the authentication information for the proxy itself. diff --git a/lib/start-proxy-action.js.map b/lib/start-proxy-action.js.map index 08572ba5a0..1069d6b46f 100644 --- a/lib/start-proxy-action.js.map +++ b/lib/start-proxy-action.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action.js","sourceRoot":"","sources":["../src/start-proxy-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,2CAA6B;AAE7B,oDAAsC;AACtC,+DAAiD;AACj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AC,QAAQ,CACjC,SAAS,EACT,eAAe,EACf,uBAAuB,CACxB,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,CAAa;IACpC,OAAO,SAAS,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,cACpD,CAAC,CAAC,QACJ,eAAe,CAAC,CAAC,QAAQ,KAAK,SAAS,YAAY,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;AAC7E,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index ff535757d4..f2ff5efc93 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -6,8 +6,8 @@ import * as toolcache from "@actions/tool-cache"; import { pki } from "node-forge"; import * as actionsUtil from "./actions-util"; -import * as util from "./util"; import { getActionsLogger, Logger } from "./logging"; +import * as util from "./util"; const UPDATEJOB_PROXY = "update-job-proxy"; const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912"; @@ -100,7 +100,11 @@ async function runWrapper() { // Get the configuration options const credentials = getCredentials(logger); - logger.info(`Credentials loaded for the following registries:\n ${credentials.map(c => credentialToStr(c)).join("\n")}`); + logger.info( + `Credentials loaded for the following registries:\n ${credentials + .map((c) => credentialToStr(c)) + .join("\n")}`, + ); const ca = generateCertificateAuthority(); const proxyAuth = getProxyAuth(); @@ -116,7 +120,12 @@ async function runWrapper() { await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger); } -async function startProxy(binPath: string, config: ProxyConfig, logFilePath: string, logger: Logger) { +async function startProxy( + binPath: string, + config: ProxyConfig, + logFilePath: string, + logger: Logger, +) { const host = "127.0.0.1"; let port = 49152; try { @@ -170,10 +179,12 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str // It prefers `registries_credentials` over `registry_secrets`. // If neither is set, it returns an empty array. function getCredentials(logger: Logger): Credential[] { - const registriesCredentials = actionsUtil.getOptionalInput("registries_credentials"); + const registriesCredentials = actionsUtil.getOptionalInput( + "registries_credentials", + ); const registrySecrets = actionsUtil.getOptionalInput("registry_secrets"); - var credentialsStr: string; + let credentialsStr: string; if (registriesCredentials !== undefined) { logger.info(`Using registries_credentials input.`); credentialsStr = Buffer.from(registriesCredentials, "base64").toString(); @@ -187,25 +198,25 @@ function getCredentials(logger: Logger): Credential[] { // Parse and validate the credentials const parsed = JSON.parse(credentialsStr) as Credential[]; - let out: Credential[] = [] - parsed.forEach(e => { + const out: Credential[] = []; + for (const e of parsed) { if (e.url === undefined && e.host === undefined) { - throw "Invalid credentials - must specify host or url" + throw new Error("Invalid credentials - must specify host or url"); } out.push({ - type: e.type, - host: e.host, - url: e.url, - username: e.username, - password: e.password, - token: e.token, - }) - }); + type: e.type, + host: e.host, + url: e.url, + username: e.username, + password: e.password, + token: e.token, + }); + } return out; } // getProxyAuth returns the authentication information for the proxy itself. -function getProxyAuth(): BasicAuthCredentials | undefined{ +function getProxyAuth(): BasicAuthCredentials | undefined { const proxy_password = actionsUtil.getOptionalInput("proxy_password"); if (proxy_password) { return { @@ -213,10 +224,9 @@ function getProxyAuth(): BasicAuthCredentials | undefined{ password: proxy_password, }; } - return ; + return; } - async function getProxyBinaryPath(): Promise { let proxyBin = toolcache.find(UPDATEJOB_PROXY, UPDATEJOB_PROXY_VERSION); if (!proxyBin) { @@ -233,8 +243,9 @@ async function getProxyBinaryPath(): Promise { } function credentialToStr(c: Credential): string { - return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}` + return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${ + c.username + }; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`; } - void runWrapper(); diff --git a/start-proxy/action.yml b/start-proxy/action.yml index cba91f1cb3..5756bba479 100644 --- a/start-proxy/action.yml +++ b/start-proxy/action.yml @@ -1,5 +1,5 @@ name: "CodeQL: Start proxy" -description: "[Experimental] Start HTTP proxy server" +description: "[Experimental] Start HTTP proxy server. This action is for internal GitHub used only and will change without notice." author: "GitHub" inputs: registry_secrets: From 0b84d89476de2d695a1e9eff728d49ac093e5fa1 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Thu, 15 Aug 2024 16:23:18 +0000 Subject: [PATCH 7/7] Try upload teh proxy logs --- lib/start-proxy-action-post.js | 17 +++++++++++++---- lib/start-proxy-action-post.js.map | 2 +- src/start-proxy-action-post.ts | 24 +++++++++++++++++++----- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index f30c61fa8a..e263ce0fdd 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -28,7 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); * It will run after the all steps in this job, in reverse order in relation to * other `post:` hooks. */ -const fs = __importStar(require("fs")); +const artifact = __importStar(require("@actions/artifact")); const core = __importStar(require("@actions/core")); const actionsUtil = __importStar(require("./actions-util")); const configUtils = __importStar(require("./config-utils")); @@ -46,9 +46,18 @@ async function runWrapper() { const config = await configUtils.getConfig(actionsUtil.getTemporaryDirectory(), core); if ((config && config.debugMode) || core.isDebug()) { const logFilePath = core.getState("proxy-log-file"); - if (logFilePath) { - const readStream = fs.createReadStream(logFilePath); - readStream.pipe(process.stdout, { end: true }); + core.info("Debug mode is on. Uploading proxy log as Actions debugging artifact..."); + try { + await artifact + .create() + .uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), { + continueOnError: true, + retentionDays: 7, + }); + } + catch (e) { + // A failure to upload debug artifacts should not fail the entire action. + core.warning(`Failed to upload debug artifacts: ${e}`); } } } diff --git a/lib/start-proxy-action-post.js.map b/lib/start-proxy-action-post.js.map index 83a05cb4e4..843ab52d08 100644 --- a/lib/start-proxy-action-post.js.map +++ b/lib/start-proxy-action-post.js.map @@ -1 +1 @@ -{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,uCAAyB;AAEzB,oDAAsC;AAEtC,4DAA8C;AAC9C,4DAA8C;AAC9C,iCAAmC;AAEnC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,wCAAwC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CACnE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACxC,WAAW,CAAC,qBAAqB,EAAE,EACnC,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACpD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACpD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src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newline at end of file diff --git a/src/start-proxy-action-post.ts b/src/start-proxy-action-post.ts index f9e68819b7..1fe601e7d4 100644 --- a/src/start-proxy-action-post.ts +++ b/src/start-proxy-action-post.ts @@ -3,8 +3,7 @@ * It will run after the all steps in this job, in reverse order in relation to * other `post:` hooks. */ -import * as fs from "fs"; - +import * as artifact from "@actions/artifact"; import * as core from "@actions/core"; import * as actionsUtil from "./actions-util"; @@ -29,9 +28,24 @@ async function runWrapper() { if ((config && config.debugMode) || core.isDebug()) { const logFilePath = core.getState("proxy-log-file"); - if (logFilePath) { - const readStream = fs.createReadStream(logFilePath); - readStream.pipe(process.stdout, { end: true }); + core.info( + "Debug mode is on. Uploading proxy log as Actions debugging artifact...", + ); + try { + await artifact + .create() + .uploadArtifact( + "proxy-log-file", + [logFilePath], + actionsUtil.getTemporaryDirectory(), + { + continueOnError: true, + retentionDays: 7, + }, + ); + } catch (e) { + // A failure to upload debug artifacts should not fail the entire action. + core.warning(`Failed to upload debug artifacts: ${e}`); } } }