Skip to content

Commit f28be58

Browse files
committed
Add proxy_ca_certificate_file output to start-proxy action
Useful to avoid duplicating this across different extractors (e.g. C# and Go)
1 parent 4b508f5 commit f28be58

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lib/start-proxy-action.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy-action.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ChildProcess, spawn } from "child_process";
2+
import * as fs from "fs";
23
import * as path from "path";
34

45
import * as core from "@actions/core";
@@ -29,6 +30,7 @@ type BasicAuthCredentials = {
2930

3031
type ProxyConfig = {
3132
all_credentials: Credential[];
33+
ca_certificate_file?: string;
3234
ca: CertificateAuthority;
3335
proxy_auth?: BasicAuthCredentials;
3436
};
@@ -118,6 +120,22 @@ async function runWrapper() {
118120
ca,
119121
};
120122

123+
// Try to write the certificate to disk. Some extractors may use this to populate
124+
// the `SSL_CERT_FILE` environment variable.
125+
try {
126+
const certificatePath = path.join(
127+
actionsUtil.getTemporaryDirectory(),
128+
"codeql_package_proxy.crt",
129+
);
130+
fs.writeFileSync(certificatePath, ca.cert);
131+
132+
proxyConfig.ca_certificate_file = certificatePath;
133+
} catch (error) {
134+
logger.error(
135+
`Failed to write the proxy certificate to disk: ${util.getErrorMessage(error)}`,
136+
);
137+
}
138+
121139
// Start the Proxy
122140
const proxyBin = await getProxyBinaryPath();
123141
await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger);
@@ -171,6 +189,7 @@ async function startProxy(
171189
core.setOutput("proxy_host", host);
172190
core.setOutput("proxy_port", port.toString());
173191
core.setOutput("proxy_ca_certificate", config.ca.cert);
192+
core.setOutput("proxy_ca_certificate_file", config.ca_certificate_file);
174193

175194
const registry_urls = config.all_credentials
176195
.filter((credential) => credential.url !== undefined)

0 commit comments

Comments
 (0)