Skip to content

Commit 8d3c67d

Browse files
Release v2.19.0 (#661)
1 parent 6c3c2f2 commit 8d3c67d

15 files changed

Lines changed: 691 additions & 35 deletions

dist/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31913,6 +31913,19 @@ function isAgentInstalled(platform) {
3191331913
function shouldDeployAgentOnSelfHosted(deployOnSelfHostedVm, isContainer, agentAlreadyInstalled) {
3191431914
return deployOnSelfHostedVm && !isContainer && !agentAlreadyInstalled;
3191531915
}
31916+
function detectThirdPartyRunnerProvider() {
31917+
var _a;
31918+
if (process.env["DEPOT_RUNNER"] === "1")
31919+
return "depot";
31920+
if (process.env["NAMESPACE_GITHUB_RUNTIME"])
31921+
return "namespace";
31922+
const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
31923+
if (runnerName.startsWith("warp-"))
31924+
return "warp";
31925+
if (runnerName.startsWith("blacksmith-"))
31926+
return "blacksmith";
31927+
return null;
31928+
}
3191631929
function utils_getAnnotationLogs(platform) {
3191731930
switch (platform) {
3191831931
case "linux":

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: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31919,6 +31919,19 @@ function isAgentInstalled(platform) {
3191931919
function shouldDeployAgentOnSelfHosted(deployOnSelfHostedVm, isContainer, agentAlreadyInstalled) {
3192031920
return deployOnSelfHostedVm && !isContainer && !agentAlreadyInstalled;
3192131921
}
31922+
function detectThirdPartyRunnerProvider() {
31923+
var _a;
31924+
if (process.env["DEPOT_RUNNER"] === "1")
31925+
return "depot";
31926+
if (process.env["NAMESPACE_GITHUB_RUNTIME"])
31927+
return "namespace";
31928+
const runnerName = (_a = process.env["RUNNER_NAME"]) !== null && _a !== void 0 ? _a : "";
31929+
if (runnerName.startsWith("warp-"))
31930+
return "warp";
31931+
if (runnerName.startsWith("blacksmith-"))
31932+
return "blacksmith";
31933+
return null;
31934+
}
3192231935
function getAnnotationLogs(platform) {
3192331936
switch (platform) {
3192431937
case "linux":
@@ -32205,6 +32218,7 @@ var cleanup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
3220532218
console.log(`[!] ${ARC_RUNNER_MESSAGE}`);
3220632219
return;
3220732220
}
32221+
const thirdPartyProvider = detectThirdPartyRunnerProvider();
3220832222
if (process.env.STATE_selfHosted === "true") {
3220932223
return;
3221032224
}
@@ -32218,7 +32232,12 @@ var cleanup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
3221832232
}
3221932233
switch (process.platform) {
3222032234
case "linux":
32221-
yield handleLinuxCleanup();
32235+
if (thirdPartyProvider) {
32236+
yield handleAgentBravoCleanup();
32237+
}
32238+
else {
32239+
yield handleLinuxCleanup();
32240+
}
3222232241
break;
3222332242
case "win32":
3222432243
yield handleWindowsCleanup();
@@ -32234,6 +32253,37 @@ var cleanup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
3223432253
console.log(exception);
3223532254
}
3223632255
}))();
32256+
function handleAgentBravoCleanup() {
32257+
return cleanup_awaiter(this, void 0, void 0, function* () {
32258+
external_child_process_.execFileSync("/usr/bin/echo", ["step_policy_jobend"]);
32259+
const doneFile = "/home/agent/done.json";
32260+
let counter = 0;
32261+
while (true) {
32262+
if (!external_fs_.existsSync(doneFile)) {
32263+
counter++;
32264+
if (counter > 10) {
32265+
console.log("timed out");
32266+
break;
32267+
}
32268+
yield sleep(1000);
32269+
}
32270+
else {
32271+
console.log(external_fs_.readFileSync(doneFile, "utf-8"));
32272+
break;
32273+
}
32274+
}
32275+
const log = "/home/agent/agent.log";
32276+
if (external_fs_.existsSync(log)) {
32277+
console.log("log:");
32278+
console.log(external_fs_.readFileSync(log, "utf-8"));
32279+
}
32280+
const status = "/home/agent/agent.status";
32281+
if (external_fs_.existsSync(status)) {
32282+
console.log("status:");
32283+
console.log(external_fs_.readFileSync(status, "utf-8"));
32284+
}
32285+
});
32286+
}
3223732287
function handleLinuxCleanup() {
3223832288
return cleanup_awaiter(this, void 0, void 0, function* () {
3223932289
if (process.env.STATE_isTLS === "false" && process.arch === "arm64") {

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: 162 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {
8503785038
function 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+
}
8504085054
function utils_getAnnotationLogs(platform) {
8504185055
switch (platform) {
8504285056
case "linux":
@@ -85441,29 +85455,38 @@ var external_crypto_ = __nccwpck_require__(6982);
8544185455

8544285456
const 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+
}
8554585613
function 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
8566685755
var 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+
}
8604486174
function 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

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.

0 commit comments

Comments
 (0)