@@ -84976,6 +84976,7 @@ __nccwpck_require__.r(__webpack_exports__);
8497684976
8497784977// EXPORTS
8497884978__nccwpck_require__.d(__webpack_exports__, {
84979+ installAgentForBravo: () => (/* binding */ installAgentForBravo),
8497984980 installAgentForSelfHosted: () => (/* binding */ installAgentForSelfHosted),
8498084981 sleep: () => (/* binding */ setup_sleep)
8498184982});
@@ -85037,6 +85038,19 @@ function isAgentInstalled(platform) {
8503785038function shouldDeployAgentOnSelfHosted(deployOnSelfHostedVm, isContainer, agentAlreadyInstalled) {
8503885039 return deployOnSelfHostedVm && !isContainer && !agentAlreadyInstalled;
8503985040}
85041+ function detectThirdPartyRunnerProvider() {
85042+ var _a;
85043+ if (process.env["DEPOT_RUNNER"] === "1")
85044+ return "depot";
85045+ if (process.env["NAMESPACE_GITHUB_RUNTIME"])
85046+ return "namespace";
85047+ const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
85048+ if (runnerName.startsWith("warp-"))
85049+ return "warp";
85050+ if (runnerName.startsWith("blacksmith-"))
85051+ return "blacksmith";
85052+ return null;
85053+ }
8504085054function utils_getAnnotationLogs(platform) {
8504185055 switch (platform) {
8504285056 case "linux":
@@ -85441,29 +85455,38 @@ var external_crypto_ = __nccwpck_require__(6982);
8544185455
8544285456const CHECKSUMS = {
8544385457 tls: {
85444- amd64: "86d042adcdc03eb1ea50d35d265da47622a6d0aedef9657f84ce1eb7f04d6057 ",
85445- arm64: "ea1074a2358d50db9a9fe18ae3971b87305cda63f262c494a5f43b25f4e524ce ",
85458+ amd64: "713c91e921292027dacf446db44bafbc8e36a3f7f51dff664ba681c6e4398a05 ",
85459+ arm64: "2c1eb365d6d9ae4cd4b6632a5f833bcdb7e75d0d9604de3391ff22e4e28e8d42 ",
8544685460 },
8544785461 non_tls: {
85448- amd64: "4aaaeebbe10e619d8ce13e8cc4a1acbafc8f891e8cdd319984480b9ec08407b8", // v0.15.0
85462+ amd64: "e38de61e1afd98dd339bb9acce4996183875d482be1638fb198ab02b3e25bbef", // v0.16.0
85463+ },
85464+ bravo: {
85465+ amd64: "8d002af0c1c4bb73eaef0f2b641f7aa353cc3f4da36a4e418b69895a2baa922c",
85466+ arm64: "1ce74a30d704c2e994246fc809d65af83e3f354aae7b9080b2c2eaee715cf005",
8544985467 },
85450- darwin: "797399a3a3f6f9c4c000a02e0d8c7b16499129c9bdc2ad9cf2a10072c10654fb ",
85468+ darwin: "fe26a1f6af4afe9f1a854d8633832f5d18ab542827003cae445b3a64021d612c ",
8545185469 windows: {
85452- amd64: "e98f8b9cf9ecf6566f1e16a470fbe4aef01610a644fd8203a1bab3ff142186c8 ", // v1.0.0
85470+ amd64: "93f1e5d87c6647e6eca7963d5f4b4bd73107029430f8e6945ffece93007a89f5 ", // v1.0.2
8545385471 },
8545485472};
8545585473// verifyChecksum returns true if checksum is valid
85456- function verifyChecksum(downloadPath, isTLS, variant, platform) {
85474+ function verifyChecksum(downloadPath, isTLS, variant, platform, agentType = "default" ) {
8545785475 const fileBuffer = external_fs_.readFileSync(downloadPath);
8545885476 const checksum = external_crypto_.createHash("sha256")
8545985477 .update(fileBuffer)
8546085478 .digest("hex"); // checksum of downloaded file
8546185479 let expectedChecksum = "";
8546285480 switch (platform) {
8546385481 case "linux":
85464- expectedChecksum = isTLS
85465- ? CHECKSUMS["tls"][variant]
85466- : CHECKSUMS["non_tls"][variant];
85482+ if (agentType === "bravo") {
85483+ expectedChecksum = CHECKSUMS["bravo"][variant];
85484+ }
85485+ else {
85486+ expectedChecksum = isTLS
85487+ ? CHECKSUMS["tls"][variant]
85488+ : CHECKSUMS["non_tls"][variant];
85489+ }
8546785490 break;
8546885491 case "darwin":
8546985492 expectedChecksum = CHECKSUMS["darwin"];
@@ -85513,14 +85536,14 @@ function installAgent(isTLS, configStr) {
8551385536 encoding: "utf8",
8551485537 });
8551585538 if (isTLS) {
85516- downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.8.0 /harden-runner_1.8.0_linux_ ${variant}.tar.gz`, undefined, auth);
85539+ downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.8.2 /harden-runner_1.8.2_linux_ ${variant}.tar.gz`, undefined, auth);
8551785540 }
8551885541 else {
8551985542 if (variant === "arm64") {
8552085543 console.log(ARM64_RUNNER_MESSAGE);
8552185544 return false;
8552285545 }
85523- downloadPath = yield tool_cache.downloadTool("https://github.com/step-security/agent/releases/download/v0.15 .0/agent_0.15 .0_linux_amd64.tar.gz", undefined, auth);
85546+ downloadPath = yield tool_cache.downloadTool("https://github.com/step-security/agent/releases/download/v0.16 .0/agent_0.16 .0_linux_amd64.tar.gz", undefined, auth);
8552485547 }
8552585548 if (!verifyChecksum(downloadPath, isTLS, variant, "linux")) {
8552685549 return false;
@@ -85542,6 +85565,51 @@ function installAgent(isTLS, configStr) {
8554285565 return true;
8554385566 });
8554485567}
85568+ function installAgentBravo(configStr) {
85569+ return install_agent_awaiter(this, void 0, void 0, function* () {
85570+ // Note: to avoid github rate limiting
85571+ const token = lib_core.getInput("token", { required: true });
85572+ const auth = `token ${token}`;
85573+ const variant = process.arch === "x64" ? "amd64" : "arm64";
85574+ const downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-ebpf/releases/download/v1.8.2/harden-runner-bravo_1.8.2_linux_${variant}.tar.gz`, undefined, auth);
85575+ if (!verifyChecksum(downloadPath, true, variant, "linux", "bravo")) {
85576+ return false;
85577+ }
85578+ const extractPath = yield tool_cache.extractTar(downloadPath);
85579+ external_child_process_.execFileSync("cp", [external_path_.join(extractPath, "agent"), "/home/agent/agent"]);
85580+ external_child_process_.execSync("chmod +x /home/agent/agent");
85581+ external_fs_.writeFileSync("/home/agent/agent.json", configStr);
85582+ const logStream = external_fs_.openSync("/home/agent/agent.stdout", "a");
85583+ const agentProcess = external_child_process_.spawn("sudo", ["/home/agent/agent"], {
85584+ cwd: "/home/agent",
85585+ detached: true,
85586+ stdio: ["ignore", logStream, logStream],
85587+ });
85588+ agentProcess.unref();
85589+ const agentStatus = "/home/agent/agent.status";
85590+ const deadline = Date.now() + 10000;
85591+ while (true) {
85592+ if (!external_fs_.existsSync(agentStatus)) {
85593+ if (Date.now() >= deadline) {
85594+ console.log("timed out waiting for bravo agent");
85595+ if (external_fs_.existsSync("/home/agent/agent.stdout")) {
85596+ console.log(external_fs_.readFileSync("/home/agent/agent.stdout", "utf-8"));
85597+ }
85598+ if (external_fs_.existsSync("/home/agent/agent.log")) {
85599+ console.log(external_fs_.readFileSync("/home/agent/agent.log", "utf-8"));
85600+ }
85601+ break;
85602+ }
85603+ yield new Promise((resolve) => setTimeout(resolve, 300));
85604+ }
85605+ else {
85606+ console.log(external_fs_.readFileSync(agentStatus, "utf-8"));
85607+ break;
85608+ }
85609+ }
85610+ return true;
85611+ });
85612+ }
8554585613function installMacosAgent(configStr) {
8554685614 return install_agent_awaiter(this, void 0, void 0, function* () {
8554785615 const token = lib_core.getInput("token", { required: true });
@@ -85557,7 +85625,7 @@ function installMacosAgent(configStr) {
8555785625 external_fs_.writeFileSync("/opt/step-security/agent.json", configStr);
8555885626 lib_core.info("✓ Successfully created agent.json at /opt/step-security/agent.json");
8555985627 // Download installer package
85560- const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.4 -mac/macos-installer-0.0.4 .tar.gz";
85628+ const downloadUrl = "https://github.com/step-security/agent-releases/releases/download/v0.0.5 -mac/macos-installer-0.0.5 .tar.gz";
8556185629 lib_core.info(`Downloading macOS installer.. : ${downloadUrl}`);
8556285630 const downloadPath = yield tool_cache.downloadTool(downloadUrl, undefined, auth);
8556385631 lib_core.info(`✓ Successfully downloaded installer to: ${downloadPath}`);
@@ -85622,7 +85690,7 @@ function installWindowsAgent(configStr) {
8562285690 encoding: "utf8",
8562385691 });
8562485692 const agentExePath = external_path_.join(agentDir, "agent.exe");
85625- const downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-releases/releases/download/v1.0.0 -win/harden-runner-agent-windows_1.0.0_windows_amd64 .tar.gz`, undefined, auth);
85693+ const downloadPath = yield tool_cache.downloadTool(`https://github.com/step-security/agent-releases/releases/download/v1.0.2 -win/harden-runner-agent-windows_1.0.2_windows_amd64 .tar.gz`, undefined, auth);
8562685694 // validate the checksum
8562785695 if (!verifyChecksum(downloadPath, false, variant, process.platform)) {
8562885696 return false;
@@ -85662,6 +85730,27 @@ function installWindowsAgent(configStr) {
8566285730 });
8566385731}
8566485732
85733+ ;// CONCATENATED MODULE: ./src/bravo-config.ts
85734+ function buildBravoConfig(confg) {
85735+ return {
85736+ repo: confg.repo,
85737+ run_id: confg.run_id,
85738+ correlation_id: confg.correlation_id,
85739+ working_directory: confg.working_directory,
85740+ api_url: confg.api_url,
85741+ telemetry_url: confg.telemetry_url,
85742+ one_time_key: confg.one_time_key,
85743+ allowed_endpoints: confg.allowed_endpoints,
85744+ egress_policy: confg.egress_policy,
85745+ disable_telemetry: confg.disable_telemetry,
85746+ disable_sudo: confg.disable_sudo,
85747+ disable_sudo_and_containers: confg.disable_sudo_and_containers,
85748+ disable_file_monitoring: confg.disable_file_monitoring,
85749+ private: confg.private,
85750+ is_github_hosted: true,
85751+ };
85752+ }
85753+
8566585754;// CONCATENATED MODULE: ./src/setup.ts
8566685755var setup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
8566785756 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -85703,6 +85792,7 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
8570385792
8570485793
8570585794
85795+
8570685796
8570785797
8570885798(() => setup_awaiter(void 0, void 0, void 0, function* () {
@@ -85896,6 +85986,19 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
8589685986 const runnerName = process.env.RUNNER_NAME || "";
8589785987 lib_core.info(`RUNNER_NAME: ${runnerName}`);
8589885988 if (!isGithubHosted()) {
85989+ const thirdPartyProvider = detectThirdPartyRunnerProvider();
85990+ if (thirdPartyProvider) {
85991+ const providerLabel = thirdPartyProvider.charAt(0).toUpperCase() + thirdPartyProvider.slice(1);
85992+ if (process.platform !== "linux") {
85993+ lib_core.info(`Detected ${providerLabel} runner on ${process.platform}. Bravo agent is Linux-only, skipping install.`);
85994+ return;
85995+ }
85996+ lib_core.info(`Detected ${providerLabel} runner environment. Installing agent-bravo.`);
85997+ confg.correlation_id = runnerName || confg.correlation_id;
85998+ yield callMonitorEndpoint(api_url, confg);
85999+ yield installAgentForBravo(github.context.repo.owner, confg);
86000+ return;
86001+ }
8589986002 external_fs_.appendFileSync(process.env.GITHUB_STATE, `selfHosted=true${external_os_.EOL}`, {
8590086003 encoding: "utf8",
8590186004 });
@@ -86041,6 +86144,33 @@ function setup_sleep(ms) {
8604186144 setTimeout(resolve, ms);
8604286145 });
8604386146}
86147+ function callMonitorEndpoint(api_url, confg) {
86148+ return setup_awaiter(this, void 0, void 0, function* () {
86149+ const _http = new lib.HttpClient();
86150+ _http.requestOptions = { socketTimeout: 3 * 1000 };
86151+ let statusCode;
86152+ let addSummary = "false";
86153+ try {
86154+ const monitorRequestData = {
86155+ correlation_id: confg.correlation_id,
86156+ job: process.env["GITHUB_JOB"],
86157+ };
86158+ const resp = yield _http.postJson(`${api_url}/github/${process.env["GITHUB_REPOSITORY"]}/actions/runs/${process.env["GITHUB_RUN_ID"]}/monitor`, monitorRequestData);
86159+ statusCode = resp.statusCode;
86160+ if (resp.statusCode === 200 && resp.result) {
86161+ console.log(`Runner IP Address: ${resp.result.runner_ip_address}`);
86162+ confg.one_time_key = resp.result.one_time_key;
86163+ addSummary = resp.result.monitoring_started ? "true" : "false";
86164+ }
86165+ }
86166+ catch (e) {
86167+ console.log(`error in connecting to ${api_url}: ${e}`);
86168+ }
86169+ external_fs_.appendFileSync(process.env.GITHUB_STATE, `monitorStatusCode=${statusCode}${external_os_.EOL}`, { encoding: "utf8" });
86170+ external_fs_.appendFileSync(process.env.GITHUB_STATE, `addSummary=${addSummary}${external_os_.EOL}`, { encoding: "utf8" });
86171+ external_fs_.appendFileSync(process.env.GITHUB_STATE, `correlation_id=${confg.correlation_id}${external_os_.EOL}`, { encoding: "utf8" });
86172+ });
86173+ }
8604486174function installAgentForSelfHosted(owner, confg) {
8604586175 return setup_awaiter(this, void 0, void 0, function* () {
8604686176 try {
@@ -86097,6 +86227,25 @@ function installAgentForSelfHosted(owner, confg) {
8609786227 }
8609886228 });
8609986229}
86230+ function installAgentForBravo(owner, confg) {
86231+ return setup_awaiter(this, void 0, void 0, function* () {
86232+ try {
86233+ console.log("Installing Harden Runner bravo agent for third-party runner");
86234+ let isTLS = yield isTLSEnabled(owner);
86235+ if (!isTLS) {
86236+ console.log("TLS is not enabled for this organization. Bravo agent installation skipped.");
86237+ return;
86238+ }
86239+ const bravoConfigStr = JSON.stringify(buildBravoConfig(confg));
86240+ external_child_process_.execSync("sudo mkdir -p /home/agent");
86241+ chownForFolder(process.env.USER, "/home/agent");
86242+ yield installAgentBravo(bravoConfigStr);
86243+ }
86244+ catch (error) {
86245+ console.log(`Failed to install bravo agent: ${error.message}`);
86246+ }
86247+ });
86248+ }
8610086249
8610186250})();
8610286251
0 commit comments