Skip to content

Commit 9da995c

Browse files
Merge pull request #638 from h0x0er/rc-35
Add mac and windows changes
2 parents 5ef0c07 + 853e846 commit 9da995c

File tree

13 files changed

+1023
-145
lines changed

13 files changed

+1023
-145
lines changed

dist/index.js

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31876,8 +31876,53 @@ var __webpack_exports__ = {};
3187631876

3187731877
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
3187831878
var lib_core = __nccwpck_require__(7484);
31879+
// EXTERNAL MODULE: external "child_process"
31880+
var external_child_process_ = __nccwpck_require__(5317);
3187931881
// EXTERNAL MODULE: external "fs"
3188031882
var external_fs_ = __nccwpck_require__(9896);
31883+
;// CONCATENATED MODULE: ./src/utils.ts
31884+
31885+
31886+
function isPlatformSupported(platform) {
31887+
switch (platform) {
31888+
case "linux":
31889+
case "win32":
31890+
case "darwin":
31891+
return true;
31892+
default:
31893+
return false;
31894+
}
31895+
}
31896+
function chownForFolder(newOwner, target) {
31897+
let cmd = "sudo";
31898+
let args = ["chown", "-R", newOwner, target];
31899+
cp.execFileSync(cmd, args);
31900+
}
31901+
function isAgentInstalled(platform) {
31902+
switch (platform) {
31903+
case "linux":
31904+
return fs.existsSync("/home/agent/agent.status");
31905+
case "win32":
31906+
return fs.existsSync("C:\\agent\\agent.status");
31907+
case "darwin":
31908+
return fs.existsSync("/opt/step-security/agent.status");
31909+
default:
31910+
return false;
31911+
}
31912+
}
31913+
function utils_getAnnotationLogs(platform) {
31914+
switch (platform) {
31915+
case "linux":
31916+
return fs.readFileSync("/home/agent/annotation.log", "utf8");
31917+
case "win32":
31918+
return fs.readFileSync("C:\\agent\\annotation.log", "utf8");
31919+
case "darwin":
31920+
return fs.readFileSync("/opt/step-security/annotation.log", "utf8");
31921+
default:
31922+
throw new Error("platform not supported");
31923+
}
31924+
}
31925+
3188131926
;// CONCATENATED MODULE: ./src/common.ts
3188231927
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
3188331928
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -31930,8 +31975,9 @@ function addSummary() {
3193031975
}
3193131976
let needsSubscription = false;
3193231977
try {
31933-
let data = fs.readFileSync("/home/agent/annotation.log", "utf8");
31934-
if (data.includes("StepSecurity Harden Runner is disabled")) {
31978+
let data = getAnnotationLogs(process.platform);
31979+
if (data !== undefined &&
31980+
data.includes("StepSecurity Harden Runner is disabled")) {
3193531981
needsSubscription = true;
3193631982
}
3193731983
}
@@ -31978,7 +32024,7 @@ function addSummary() {
3197832024
}
3197932025
const STATUS_HARDEN_RUNNER_UNAVAILABLE = "409";
3198032026
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.";
31981-
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.";
32027+
const UNSUPPORTED_RUNNER_MESSAGE = "This job is not running in a GitHub Actions Hosted Runner. Harden Runner is only supported on GitHub-hosted runners (Ubuntu, Windows, and macOS). This job will not be monitored.";
3198232028
const SELF_HOSTED_RUNNER_MESSAGE = "This job is running on a self-hosted runner.";
3198332029
const HARDEN_RUNNER_UNAVAILABLE_MESSAGE = "Sorry, we are currently experiencing issues with the Harden Runner installation process. It is currently unavailable.";
3198432030
const ARC_RUNNER_MESSAGE = "Workflow is currently being executed in ARC based runner.";
@@ -32083,6 +32129,7 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
3208332129

3208432130

3208532131

32132+
3208632133
(() => src_awaiter(void 0, void 0, void 0, function* () {
3208732134
var _a, _b;
3208832135
console.log("[harden-runner] main-step");
@@ -32091,8 +32138,8 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
3209132138
console.log("Skipping harden-runner: custom property 'skip-harden-runner' is set to 'true'");
3209232139
return;
3209332140
}
32094-
if (process.platform !== "linux") {
32095-
console.log(UBUNTU_MESSAGE);
32141+
if (!isPlatformSupported(process.platform)) {
32142+
console.log(UNSUPPORTED_RUNNER_MESSAGE);
3209632143
return;
3209732144
}
3209832145
if (isGithubHosted() && isDocker()) {

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.

0 commit comments

Comments
 (0)