Skip to content

Commit 376d25a

Browse files
devantlerCopilot
andcommitted
fix: detect ubuntu-slim runners early and bail out
ubuntu-slim runners (Hosted Compute Agent Docker containers) are GitHub-hosted but lack the standard USER environment variable set on full VM-based runners. This causes chownForFolder to fail with 'chown: invalid user: undefined'. Instead of patching chownForFolder, detect ubuntu-slim early informative message, matching the existing patterns for isDocker(), isARCRunner(), and other unsupported runner types. Fixes #627 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f808768 commit 376d25a

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/cleanup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ import { isPlatformSupported, isAgentInstalled } from "./utils";
2626
return;
2727
}
2828

29+
if (isGithubHosted() && process.platform === "linux" && !process.env.USER) {
30+
console.log(common.UBUNTU_SLIM_MESSAGE);
31+
return;
32+
}
33+
2934
if (isARCRunner()) {
3035
console.log(`[!] ${common.ARC_RUNNER_MESSAGE}`);
3136
return;

src/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,6 @@ export const ARM64_RUNNER_MESSAGE =
148148

149149
export const ARM64_WINDOWS_RUNNER_MESSAGE =
150150
"Windows ARM runners are not yet supported by Harden-Runner.";
151+
152+
export const UBUNTU_SLIM_MESSAGE =
153+
"This job is running on an ubuntu-slim runner (GitHub-hosted Linux container without a standard USER environment variable). Harden Runner is not supported on ubuntu-slim runners. This job will not be monitored.";

src/setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ interface MonitorResponse {
6464
return;
6565
}
6666

67+
if (isGithubHosted() && process.platform === "linux" && !process.env.USER) {
68+
console.log(common.UBUNTU_SLIM_MESSAGE);
69+
return;
70+
}
71+
6772
var correlation_id = uuidv4();
6873
var api_url = STEPSECURITY_API_URL;
6974
var web_url = STEPSECURITY_WEB_URL;

0 commit comments

Comments
 (0)