Skip to content

Commit 815e48d

Browse files
committed
Skip agent install and post-step cleanup when agent is already installed
- Third-party runners: check isAgentInstalled() and skip installation, including the monitor call, when an agent is already running. - Record agentPreinstalled state in both the third-party and the GitHub-hosted "already installed" paths so the post step skips cleanup; the runner's job hooks handle it instead. - Bump agent-ebpf (tls and bravo) to v1.9.4 and the macOS installer to v0.0.9, with updated checksums.
1 parent ccd8616 commit 815e48d

8 files changed

Lines changed: 41 additions & 18 deletions

File tree

‎dist/post/index.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32312,6 +32312,11 @@ process.on("unhandledRejection", (reason) => {
3231232312
if (process.env.STATE_customVMImage === "true") {
3231332313
return;
3231432314
}
32315+
// Agent was already installed; its cleanup is handled by
32316+
// the runner's job hooks.
32317+
if (process.env.STATE_agentPreinstalled === "true") {
32318+
return;
32319+
}
3231532320
if (String(process.env.STATE_monitorStatusCode) ===
3231632321
STATUS_HARDEN_RUNNER_UNAVAILABLE) {
3231732322
console.log(HARDEN_RUNNER_UNAVAILABLE_MESSAGE);

‎dist/post/index.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.

‎dist/pre/index.js‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85623,18 +85623,18 @@ var external_crypto_ = __nccwpck_require__(6982);
8562385623

8562485624
const CHECKSUMS = {
8562585625
tls: {
85626-
amd64: "2d052e2373a412b342480019f5cf847f84a2f9f8aca86a15acab2e8c3152beb9", // v1.9.3
85627-
arm64: "4918db19e07a7b511aea665c7b808c72cd1be9cd9ea4deb41b4d6f41f702e5e7", // v1.9.3
85626+
amd64: "66f309e8fa41aa6b96a5e740afccefa3b89e90fb62180cdbe73948f3bc068f57", // v1.9.4
85627+
arm64: "15ff7e107988333f22eb93f33ca35630c48de3fd969938bc72e0e10e7808aab9", // v1.9.4
8562885628
},
8562985629
non_tls: {
8563085630
amd64: "e0faa2687554ebd5629595bcd5531360781abe3e2746ef8ce5a030961a3acab0", // v0.17.0
8563185631
arm64: "6b5739247c06179a280f2f9548dd3337d839d3cc83284b75ddbdd593ac1ea0d6", // v0.17.0
8563285632
},
8563385633
bravo: {
85634-
amd64: "995c1157c2764d2b09ba369fc2583104096cfb9a40c09af4b00b77e32651216b", // v1.9.3
85635-
arm64: "f52555c8ab659a8a9b870fd3b8e820c064e235e3c34e83adf30db4b46e6a2efb", // v1.9.3
85634+
amd64: "c2baada041a36be6179c1467f04fd40d429e9fb0523752426f8290d03a087f51", // v1.9.4
85635+
arm64: "d903b31dcc563f0d21c85cdceae9161c97da6a5b4cfa7637d8480cd03885ecc1", // v1.9.4
8563685636
},
85637-
darwin: "da83f8b446067b9db72aa896f6cec71f1a073015bcf585e63a1d9e0a14c21910", // v0.0.7
85637+
darwin: "0e0964799818e8a63cf785bb00d70c3b1eeb9d0d0bfbcace364be7a469ee13aa", // v0.0.9
8563885638
windows: {
8563985639
amd64: "1fada923697ec6bcfd64ac29f0751fe92861d269de073af4aa79b5bf6e2b4071", // v1.0.10
8564085640
},
@@ -85705,7 +85705,7 @@ function installAgent(isTLS, configStr) {
8570585705
encoding: "utf8",
8570685706
});
8570785707
if (isTLS) {
85708-
downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.9.3/harden-runner_1.9.3_linux_${variant}.tar.gz`, undefined, auth);
85708+
downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.9.4/harden-runner_1.9.4_linux_${variant}.tar.gz`, undefined, auth);
8570985709
}
8571085710
else {
8571185711
downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent/releases/download/v0.17.0/agent_0.17.0_linux_${variant}.tar.gz`, undefined, auth);
@@ -85736,7 +85736,7 @@ function installAgentBravo(configStr_1) {
8573685736
const token = lib_core.getInput("token", { required: true });
8573785737
const auth = `token ${token}`;
8573885738
const variant = process.arch === "x64" ? "amd64" : "arm64";
85739-
const downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.9.3/harden-runner-bravo_1.9.3_linux_${variant}.tar.gz`, undefined, auth);
85739+
const downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.9.4/harden-runner-bravo_1.9.4_linux_${variant}.tar.gz`, undefined, auth);
8574085740
if (!verifyChecksum(downloadPath, true, variant, "linux", "bravo")) {
8574185741
return false;
8574285742
}
@@ -85793,7 +85793,7 @@ function installMacosAgent(configStr) {
8579385793
external_fs_.writeFileSync("/opt/step-security/agent.json", configStr);
8579485794
lib_core.info("✓ Successfully created agent.json at /opt/step-security/agent.json");
8579585795
// Download installer package
85796-
const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.7-mac/macos-installer-0.0.7.tar.gz";
85796+
const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.9-mac/macos-installer-0.0.9.tar.gz";
8579785797
lib_core.info(`Downloading macOS installer.. : ${downloadUrl}`);
8579885798
const downloadPath = yield tool_cache.downloadTool(downloadUrl, undefined, auth);
8579985799
lib_core.info(`✓ Successfully downloaded installer to: ${downloadPath}`);
@@ -86214,6 +86214,11 @@ function resolveCacheHost() {
8621486214
lib_core.info(`Detected ${providerLabel} runner on ${process.platform}. HardenRunner is not supported on this third-party provider, skipping install.`);
8621586215
return;
8621686216
}
86217+
if (isAgentInstalled(process.platform)) {
86218+
external_fs_.appendFileSync(process.env.GITHUB_STATE, `agentPreinstalled=true${external_os_.EOL}`, { encoding: "utf8" });
86219+
lib_core.info(`Agent already present on ${providerLabel} runner, skipping installation.`);
86220+
return;
86221+
}
8621786222
lib_core.info(`Detected ${providerLabel} runner environment. Installing agent-bravo.`);
8621886223
confg.correlation_id = runnerName || confg.correlation_id;
8621986224
const ghesSelfHosted = confg.is_ghes && thirdPartyProvider === "codebuild";
@@ -86283,6 +86288,7 @@ function resolveCacheHost() {
8628386288
return;
8628486289
}
8628586290
if (isGithubHosted() && isAgentInstalled(process.platform)) {
86291+
external_fs_.appendFileSync(process.env.GITHUB_STATE, `agentPreinstalled=true${external_os_.EOL}`, { encoding: "utf8" });
8628686292
console.log("Agent already installed, skipping installation");
8628786293
return;
8628886294
}

‎dist/pre/index.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/checksum.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import * as fs from "fs";
44

55
export const CHECKSUMS = {
66
tls: {
7-
amd64: "2d052e2373a412b342480019f5cf847f84a2f9f8aca86a15acab2e8c3152beb9", // v1.9.3
8-
arm64: "4918db19e07a7b511aea665c7b808c72cd1be9cd9ea4deb41b4d6f41f702e5e7", // v1.9.3
7+
amd64: "66f309e8fa41aa6b96a5e740afccefa3b89e90fb62180cdbe73948f3bc068f57", // v1.9.4
8+
arm64: "15ff7e107988333f22eb93f33ca35630c48de3fd969938bc72e0e10e7808aab9", // v1.9.4
99
},
1010
non_tls: {
1111
amd64: "e0faa2687554ebd5629595bcd5531360781abe3e2746ef8ce5a030961a3acab0", // v0.17.0
1212
arm64: "6b5739247c06179a280f2f9548dd3337d839d3cc83284b75ddbdd593ac1ea0d6", // v0.17.0
1313
},
1414
bravo: {
15-
amd64: "995c1157c2764d2b09ba369fc2583104096cfb9a40c09af4b00b77e32651216b", // v1.9.3
16-
arm64: "f52555c8ab659a8a9b870fd3b8e820c064e235e3c34e83adf30db4b46e6a2efb", // v1.9.3
15+
amd64: "c2baada041a36be6179c1467f04fd40d429e9fb0523752426f8290d03a087f51", // v1.9.4
16+
arm64: "d903b31dcc563f0d21c85cdceae9161c97da6a5b4cfa7637d8480cd03885ecc1", // v1.9.4
1717
},
18-
darwin: "da83f8b446067b9db72aa896f6cec71f1a073015bcf585e63a1d9e0a14c21910", // v0.0.7
18+
darwin: "0e0964799818e8a63cf785bb00d70c3b1eeb9d0d0bfbcace364be7a469ee13aa", // v0.0.9
1919
windows: {
2020
amd64: "1fada923697ec6bcfd64ac29f0751fe92861d269de073af4aa79b5bf6e2b4071", // v1.0.10
2121
},

‎src/cleanup.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ process.on("unhandledRejection", (reason) => {
6262
return;
6363
}
6464

65+
// Agent was already installed; its cleanup is handled by
66+
// the runner's job hooks.
67+
if (process.env.STATE_agentPreinstalled === "true") {
68+
return;
69+
}
70+
6571
if (
6672
String(process.env.STATE_monitorStatusCode) ===
6773
common.STATUS_HARDEN_RUNNER_UNAVAILABLE

‎src/install-agent.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function installAgent(
2626

2727
if (isTLS) {
2828
downloadPath = await tc.downloadTool(
29-
`https://github.com/step-security/agent-ebpf/releases/download/v1.9.3/harden-runner_1.9.3_linux_${variant}.tar.gz`,
29+
`https://github.com/step-security/agent-ebpf/releases/download/v1.9.4/harden-runner_1.9.4_linux_${variant}.tar.gz`,
3030
undefined,
3131
auth
3232
);
@@ -75,7 +75,7 @@ export async function installAgentBravo(
7575

7676
const variant = process.arch === "x64" ? "amd64" : "arm64";
7777
const downloadPath = await tc.downloadTool(
78-
`https://github.com/step-security/agent-ebpf/releases/download/v1.9.3/harden-runner-bravo_1.9.3_linux_${variant}.tar.gz`,
78+
`https://github.com/step-security/agent-ebpf/releases/download/v1.9.4/harden-runner-bravo_1.9.4_linux_${variant}.tar.gz`,
7979
undefined,
8080
auth
8181
);
@@ -145,7 +145,7 @@ export async function installMacosAgent(configStr: string): Promise<boolean> {
145145

146146
// Download installer package
147147
const downloadUrl =
148-
"https://github.com/step-security/agent-releases/releases/download/v0.0.7-mac/macos-installer-0.0.7.tar.gz";
148+
"https://github.com/step-security/agent-releases/releases/download/v0.0.9-mac/macos-installer-0.0.9.tar.gz";
149149
core.info(`Downloading macOS installer.. : ${downloadUrl}`);
150150
const downloadPath = await tc.downloadTool(downloadUrl, undefined, auth);
151151
core.info(`✓ Successfully downloaded installer to: ${downloadPath}`);

‎src/setup.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ async function resolveCacheHost(): Promise<string | undefined> {
358358
core.info(`Detected ${providerLabel} runner on ${process.platform}. HardenRunner is not supported on this third-party provider, skipping install.`);
359359
return;
360360
}
361+
if (isAgentInstalled(process.platform)) {
362+
fs.appendFileSync(process.env.GITHUB_STATE, `agentPreinstalled=true${EOL}`, { encoding: "utf8" });
363+
core.info(`Agent already present on ${providerLabel} runner, skipping installation.`);
364+
return;
365+
}
361366
core.info(`Detected ${providerLabel} runner environment. Installing agent-bravo.`);
362367
confg.correlation_id = runnerName || confg.correlation_id;
363368
const ghesSelfHosted = confg.is_ghes && thirdPartyProvider === "codebuild";
@@ -433,6 +438,7 @@ async function resolveCacheHost(): Promise<string | undefined> {
433438
}
434439

435440
if (isGithubHosted() && isAgentInstalled(process.platform)) {
441+
fs.appendFileSync(process.env.GITHUB_STATE, `agentPreinstalled=true${EOL}`, { encoding: "utf8" });
436442
console.log("Agent already installed, skipping installation");
437443
return;
438444
}

0 commit comments

Comments
 (0)