Skip to content

Commit eb9e1f4

Browse files
committed
Bring macOS runner updates from PR 674
1 parent 1a10b01 commit eb9e1f4

11 files changed

Lines changed: 53 additions & 21 deletions

File tree

dist/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31919,6 +31919,8 @@ function detectThirdPartyRunnerProvider() {
3191931919
return "depot";
3192031920
if (process.env["NAMESPACE_GITHUB_RUNTIME"])
3192131921
return "namespace";
31922+
if (process.env["BITRISE_IO"])
31923+
return "bitrise";
3192231924
const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
3192331925
if (runnerName.startsWith("warp-"))
3192431926
return "warp";

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31925,6 +31925,8 @@ function detectThirdPartyRunnerProvider() {
3192531925
return "depot";
3192631926
if (process.env["NAMESPACE_GITHUB_RUNTIME"])
3192731927
return "namespace";
31928+
if (process.env["BITRISE_IO"])
31929+
return "bitrise";
3192831930
const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
3192931931
if (runnerName.startsWith("warp-"))
3193031932
return "warp";

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: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85117,6 +85117,8 @@ function detectThirdPartyRunnerProvider() {
8511785117
return "depot";
8511885118
if (process.env["NAMESPACE_GITHUB_RUNTIME"])
8511985119
return "namespace";
85120+
if (process.env["BITRISE_IO"])
85121+
return "bitrise";
8512085122
const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
8512185123
if (runnerName.startsWith("warp-"))
8512285124
return "warp";
@@ -85551,7 +85553,7 @@ const CHECKSUMS = {
8555185553
amd64: "c986d0a19637325c9a8d4a331a6c4ed047e4cddb798f56b641d0e66f8bf9b1b2", // v1.8.12
8555285554
arm64: "5c3df17f82e317c8b288dfbbcee449c2a24a80deeeb3416dccabd0a61982c676", // v1.8.12
8555385555
},
85554-
darwin: "fe26a1f6af4afe9f1a854d8633832f5d18ab542827003cae445b3a64021d612c", // v0.0.5
85556+
darwin: "2990f0390d2760fa6262a3830060b6db1233f16a1410ffe1ed2bf13dfda80c38", // v0.0.6
8555585557
windows: {
8555685558
amd64: "5e3604d08aba65d7bdd1d0684826d5894ffb0c6f56b914c6ecb35c3271e04483", // v1.0.7
8555785559
},
@@ -85711,7 +85713,7 @@ function installMacosAgent(configStr) {
8571185713
external_fs_.writeFileSync("/opt/step-security/agent.json", configStr);
8571285714
lib_core.info("✓ Successfully created agent.json at /opt/step-security/agent.json");
8571385715
// Download installer package
85714-
const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.5-mac/macos-installer-0.0.5.tar.gz";
85716+
const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.6-mac/macos-installer-0.0.6.tar.gz";
8571585717
lib_core.info(`Downloading macOS installer.. : ${downloadUrl}`);
8571685718
const downloadPath = yield tool_cache.downloadTool(downloadUrl, undefined, auth);
8571785719
lib_core.info(`✓ Successfully downloaded installer to: ${downloadPath}`);
@@ -86089,15 +86091,26 @@ process.on("unhandledRejection", (reason) => {
8608986091
const thirdPartyProvider = detectThirdPartyRunnerProvider();
8609086092
if (thirdPartyProvider) {
8609186093
const providerLabel = thirdPartyProvider.charAt(0).toUpperCase() + thirdPartyProvider.slice(1);
86092-
if (process.platform !== "linux") {
86093-
lib_core.info(`Detected ${providerLabel} runner on ${process.platform}. Bravo agent is Linux-only, skipping install.`);
86094+
if (process.platform !== "linux" && process.platform !== "darwin") {
86095+
lib_core.info(`Detected ${providerLabel} runner on ${process.platform}. HardenRunner is not supported on this third-party provider, skipping install.`);
8609486096
return;
8609586097
}
8609686098
lib_core.info(`Detected ${providerLabel} runner environment. Installing agent-bravo.`);
8609786099
confg.correlation_id = runnerName || confg.correlation_id;
8609886100
yield callMonitorEndpoint(api_url, confg);
86099-
yield installAgentForBravo(github.context.repo.owner, confg);
86100-
return;
86101+
const bravoConfigStr = JSON.stringify(buildBravoConfig(confg));
86102+
switch (process.platform) {
86103+
case "darwin": {
86104+
const installed = yield installMacosAgent(bravoConfigStr);
86105+
if (!installed) {
86106+
lib_core.warning("macos bravo agent installation failed");
86107+
}
86108+
return;
86109+
}
86110+
case "linux":
86111+
yield installAgentForBravo(github.context.repo.owner, bravoConfigStr);
86112+
return;
86113+
}
8610186114
}
8610286115
external_fs_.appendFileSync(process.env.GITHUB_STATE, `selfHosted=true${external_os_.EOL}`, {
8610386116
encoding: "utf8",
@@ -86338,7 +86351,7 @@ function installAgentForSelfHosted(owner, confg) {
8633886351
}
8633986352
});
8634086353
}
86341-
function installAgentForBravo(owner, confg) {
86354+
function installAgentForBravo(owner, bravoConfigStr) {
8634286355
return setup_awaiter(this, void 0, void 0, function* () {
8634386356
try {
8634486357
console.log("Installing Harden Runner bravo agent for third-party runner");
@@ -86347,7 +86360,6 @@ function installAgentForBravo(owner, confg) {
8634786360
console.log("TLS is not enabled for this organization. Bravo agent installation skipped.");
8634886361
return;
8634986362
}
86350-
const bravoConfigStr = JSON.stringify(buildBravoConfig(confg));
8635186363
external_child_process_.execSync("sudo mkdir -p /home/agent");
8635286364
chownForFolder(process.env.USER, "/home/agent");
8635386365
yield installAgentBravo(bravoConfigStr);

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const CHECKSUMS = {
1414
amd64: "c986d0a19637325c9a8d4a331a6c4ed047e4cddb798f56b641d0e66f8bf9b1b2", // v1.8.12
1515
arm64: "5c3df17f82e317c8b288dfbbcee449c2a24a80deeeb3416dccabd0a61982c676", // v1.8.12
1616
},
17-
darwin: "fe26a1f6af4afe9f1a854d8633832f5d18ab542827003cae445b3a64021d612c", // v0.0.5
17+
darwin: "2990f0390d2760fa6262a3830060b6db1233f16a1410ffe1ed2bf13dfda80c38", // v0.0.6
1818
windows: {
1919
amd64: "5e3604d08aba65d7bdd1d0684826d5894ffb0c6f56b914c6ecb35c3271e04483", // v1.0.7
2020
},

src/install-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function installMacosAgent(configStr: string): Promise<boolean> {
143143

144144
// Download installer package
145145
const downloadUrl =
146-
"https://github.com/step-security/agent-releases/releases/download/v0.0.5-mac/macos-installer-0.0.5.tar.gz";
146+
"https://github.com/step-security/agent-releases/releases/download/v0.0.6-mac/macos-installer-0.0.6.tar.gz";
147147
core.info(`Downloading macOS installer.. : ${downloadUrl}`);
148148
const downloadPath = await tc.downloadTool(downloadUrl, undefined, auth);
149149
core.info(`✓ Successfully downloaded installer to: ${downloadPath}`);

src/setup.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,26 @@ process.on("unhandledRejection", (reason) => {
312312
const thirdPartyProvider = detectThirdPartyRunnerProvider();
313313
if (thirdPartyProvider) {
314314
const providerLabel = thirdPartyProvider.charAt(0).toUpperCase() + thirdPartyProvider.slice(1);
315-
if (process.platform !== "linux") {
316-
core.info(`Detected ${providerLabel} runner on ${process.platform}. Bravo agent is Linux-only, skipping install.`);
315+
if (process.platform !== "linux" && process.platform !== "darwin") {
316+
core.info(`Detected ${providerLabel} runner on ${process.platform}. HardenRunner is not supported on this third-party provider, skipping install.`);
317317
return;
318318
}
319319
core.info(`Detected ${providerLabel} runner environment. Installing agent-bravo.`);
320320
confg.correlation_id = runnerName || confg.correlation_id;
321321
await callMonitorEndpoint(api_url, confg);
322-
await installAgentForBravo(context.repo.owner, confg);
323-
return;
322+
const bravoConfigStr = JSON.stringify(buildBravoConfig(confg));
323+
switch (process.platform) {
324+
case "darwin": {
325+
const installed = await installMacosAgent(bravoConfigStr);
326+
if (!installed) {
327+
core.warning("macos bravo agent installation failed");
328+
}
329+
return;
330+
}
331+
case "linux":
332+
await installAgentForBravo(context.repo.owner, bravoConfigStr);
333+
return;
334+
}
324335
}
325336

326337
fs.appendFileSync(process.env.GITHUB_STATE, `selfHosted=true${EOL}`, {
@@ -596,7 +607,7 @@ export async function installAgentForSelfHosted(owner: string, confg: Configurat
596607
}
597608
}
598609

599-
export async function installAgentForBravo(owner: string, confg: Configuration) {
610+
export async function installAgentForBravo(owner: string, bravoConfigStr: string) {
600611
try {
601612
console.log("Installing Harden Runner bravo agent for third-party runner");
602613

@@ -607,8 +618,6 @@ export async function installAgentForBravo(owner: string, confg: Configuration)
607618
return;
608619
}
609620

610-
const bravoConfigStr = JSON.stringify(buildBravoConfig(confg));
611-
612621
cp.execSync("sudo mkdir -p /home/agent");
613622
chownForFolder(process.env.USER, "/home/agent");
614623

src/utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ describe("detectThirdPartyRunnerProvider", () => {
9898
process.env = { ...originalEnv };
9999
delete process.env.DEPOT_RUNNER;
100100
delete process.env.NAMESPACE_GITHUB_RUNTIME;
101+
delete process.env.BITRISE_IO;
101102
delete process.env.RUNNER_NAME;
102103
});
103104

@@ -120,6 +121,11 @@ describe("detectThirdPartyRunnerProvider", () => {
120121
expect(detectThirdPartyRunnerProvider()).toBe("namespace");
121122
});
122123

124+
test("returns bitrise when BITRISE_IO is set", () => {
125+
process.env.BITRISE_IO = "true";
126+
expect(detectThirdPartyRunnerProvider()).toBe("bitrise");
127+
});
128+
123129
test("returns warp for RUNNER_NAME prefix warp-", () => {
124130
process.env.RUNNER_NAME = "warp-4x-x64-abc";
125131
expect(detectThirdPartyRunnerProvider()).toBe("warp");

0 commit comments

Comments
 (0)