1
0
Fork 0
mirror of synced 2026-06-05 14:08:19 +00:00
harden-runner/src/utils.ts
2026-02-24 15:14:57 -08:00

46 lines
1.2 KiB
TypeScript

import * as cp from "child_process";
import * as fs from "fs";
export function isPlatformSupported(platform: NodeJS.Platform) {
switch (platform) {
case "linux":
case "win32":
case "darwin":
return true;
default:
return false;
}
}
export function chownForFolder(newOwner: string, target: string) {
let cmd = "sudo";
let args = ["chown", "-R", newOwner, target];
cp.execFileSync(cmd, args);
}
export function isAgentInstalled(platform: NodeJS.Platform) {
switch (platform) {
case "linux":
return fs.existsSync("/home/agent/agent.status");
case "win32":
return fs.existsSync("C:\\agent\\agent.status");
case "darwin":
return fs.existsSync("/opt/step-security/agent.status");
default:
return false;
}
}
export function getAnnotationLogs(platform: NodeJS.Platform) {
switch (platform) {
case "linux":
return fs.readFileSync("/home/agent/annotation.log", "utf8");
case "win32":
return fs.readFileSync("C:\\agent\\annotation.log", "utf8");
case "darwin":
return fs.readFileSync("/opt/step-security/annotation.log", "utf8");
default:
throw new Error("platform not supported");
}
}