Skip to content

Add proxy_ca_certificate_file output to start-proxy action #2846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/start-proxy-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/start-proxy-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/start-proxy-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChildProcess, spawn } from "child_process";
import * as fs from "fs";
import * as path from "path";

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

type ProxyConfig = {
all_credentials: Credential[];
ca_certificate_file?: string;
ca: CertificateAuthority;
proxy_auth?: BasicAuthCredentials;
};
Expand Down Expand Up @@ -118,6 +120,22 @@ async function runWrapper() {
ca,
};

// Try to write the certificate to disk. Some extractors may use this to populate
// the `SSL_CERT_FILE` environment variable.
try {
const certificatePath = path.join(
actionsUtil.getTemporaryDirectory(),
"codeql_package_proxy.crt",
);
fs.writeFileSync(certificatePath, ca.cert);

proxyConfig.ca_certificate_file = certificatePath;
} catch (error) {
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch block only logs the error without failing the action. Given the PR description's goal to ensure the certificate file is successfully written, consider rethrowing the error to fail execution if the write fails.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

logger.error(
`Failed to write the proxy certificate to disk: ${util.getErrorMessage(error)}`,
);
}

// Start the Proxy
const proxyBin = await getProxyBinaryPath();
await startProxy(proxyBin, proxyConfig, proxyLogFilePath, logger);
Expand Down Expand Up @@ -171,6 +189,7 @@ async function startProxy(
core.setOutput("proxy_host", host);
core.setOutput("proxy_port", port.toString());
core.setOutput("proxy_ca_certificate", config.ca.cert);
core.setOutput("proxy_ca_certificate_file", config.ca_certificate_file);

const registry_urls = config.all_credentials
.filter((credential) => credential.url !== undefined)
Expand Down
Loading