Skip to content

Commit ef891c3

Browse files
committed
feat: add support for custom vm image
1 parent 1fa8c8a commit ef891c3

File tree

9 files changed

+39
-7
lines changed

9 files changed

+39
-7
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27698,7 +27698,7 @@ function addSummary() {
2769827698
});
2769927699
}
2770027700
const STATUS_HARDEN_RUNNER_UNAVAILABLE = "409";
27701-
const CONTAINER_MESSAGE = "This job is running in a container. Harden Runner does not run in a container as it needs sudo access to run. This job will not be monitored.";
27701+
const CONTAINER_MESSAGE = "This job is running in a container. Such jobs can be monitored by installing Harden Runner in a custom VM image for GitHub-hosted runners.";
2770227702
const UBUNTU_MESSAGE = "This job is not running in a GitHub Actions Hosted Runner Ubuntu VM. Harden Runner is only supported on Ubuntu VM. This job will not be monitored.";
2770327703
const SELF_HOSTED_RUNNER_MESSAGE = "This job is running on a self-hosted runner.";
2770427704
const HARDEN_RUNNER_UNAVAILABLE_MESSAGE = "Sorry, we are currently experiencing issues with the Harden Runner installation process. It is currently unavailable.";

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27705,7 +27705,7 @@ function addSummary() {
2770527705
});
2770627706
}
2770727707
const STATUS_HARDEN_RUNNER_UNAVAILABLE = "409";
27708-
const CONTAINER_MESSAGE = "This job is running in a container. Harden Runner does not run in a container as it needs sudo access to run. This job will not be monitored.";
27708+
const CONTAINER_MESSAGE = "This job is running in a container. Such jobs can be monitored by installing Harden Runner in a custom VM image for GitHub-hosted runners.";
2770927709
const UBUNTU_MESSAGE = "This job is not running in a GitHub Actions Hosted Runner Ubuntu VM. Harden Runner is only supported on Ubuntu VM. This job will not be monitored.";
2771027710
const SELF_HOSTED_RUNNER_MESSAGE = "This job is running on a self-hosted runner.";
2771127711
const HARDEN_RUNNER_UNAVAILABLE_MESSAGE = "Sorry, we are currently experiencing issues with the Harden Runner installation process. It is currently unavailable.";
@@ -27867,6 +27867,9 @@ var cleanup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
2786727867
if (process.env.STATE_selfHosted === "true") {
2786827868
return;
2786927869
}
27870+
if (process.env.STATE_customVMImage === "true") {
27871+
return;
27872+
}
2787027873
if (process.env.STATE_isTLS === "false" && process.arch === "arm64") {
2787127874
return;
2787227875
}

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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85248,7 +85248,7 @@ function addSummary() {
8524885248
});
8524985249
}
8525085250
const STATUS_HARDEN_RUNNER_UNAVAILABLE = "409";
85251-
const CONTAINER_MESSAGE = "This job is running in a container. Harden Runner does not run in a container as it needs sudo access to run. This job will not be monitored.";
85251+
const CONTAINER_MESSAGE = "This job is running in a container. Such jobs can be monitored by installing Harden Runner in a custom VM image for GitHub-hosted runners.";
8525285252
const UBUNTU_MESSAGE = "This job is not running in a GitHub Actions Hosted Runner Ubuntu VM. Harden Runner is only supported on Ubuntu VM. This job will not be monitored.";
8525385253
const SELF_HOSTED_RUNNER_MESSAGE = "This job is running on a self-hosted runner.";
8525485254
const HARDEN_RUNNER_UNAVAILABLE_MESSAGE = "Sorry, we are currently experiencing issues with the Harden Runner installation process. It is currently unavailable.";
@@ -85764,6 +85764,17 @@ var setup_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _ar
8576485764
}
8576585765
return;
8576685766
}
85767+
if (isGithubHosted() && process.env.STEP_SECURITY_HARDEN_RUNNER === "true") {
85768+
external_fs_.appendFileSync(process.env.GITHUB_STATE, `customVMImage=true${external_os_.EOL}`, {
85769+
encoding: "utf8",
85770+
});
85771+
lib_core.info("This job is running on a custom VM image with Harden Runner installed.");
85772+
if (confg.egress_policy === "block") {
85773+
sendAllowedEndpoints(confg.allowed_endpoints);
85774+
yield setup_sleep(5000);
85775+
}
85776+
return;
85777+
}
8576785778
let _http = new lib.HttpClient();
8576885779
let statusCode;
8576985780
_http.requestOptions = { socketTimeout: 3 * 1000 };

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/cleanup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import { isGithubHosted } from "./tls-inspect";
2525
return;
2626
}
2727

28+
if (process.env.STATE_customVMImage === "true") {
29+
return;
30+
}
31+
2832
if (process.env.STATE_isTLS === "false" && process.arch === "arm64") {
2933
return;
3034
}

src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function addSummary() {
126126
export const STATUS_HARDEN_RUNNER_UNAVAILABLE = "409";
127127

128128
export const CONTAINER_MESSAGE =
129-
"This job is running in a container. Harden Runner does not run in a container as it needs sudo access to run. This job will not be monitored.";
129+
"This job is running in a container. Such jobs can be monitored by installing Harden Runner in a custom VM image for GitHub-hosted runners.";
130130

131131
export const UBUNTU_MESSAGE =
132132
"This job is not running in a GitHub Actions Hosted Runner Ubuntu VM. Harden Runner is only supported on Ubuntu VM. This job will not be monitored.";

src/setup.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ interface MonitorResponse {
243243
return;
244244
}
245245

246+
if (isGithubHosted() && process.env.STEP_SECURITY_HARDEN_RUNNER === "true") {
247+
fs.appendFileSync(process.env.GITHUB_STATE, `customVMImage=true${EOL}`, {
248+
encoding: "utf8",
249+
});
250+
251+
core.info("This job is running on a custom VM image with Harden Runner installed.");
252+
253+
if (confg.egress_policy === "block") {
254+
sendAllowedEndpoints(confg.allowed_endpoints);
255+
await sleep(5000);
256+
}
257+
return;
258+
}
259+
246260
let _http = new httpm.HttpClient();
247261
let statusCode: number | undefined;
248262
_http.requestOptions = { socketTimeout: 3 * 1000 };

0 commit comments

Comments
 (0)