fix(artifacts): mark Windows host executables by extension (#1823)
Windows has no POSIX execute bit; Node reports file modes from the read-only attribute alone, so every host file, including PE images, reported `executable: false` while the same occurrence reported `artifact_kind: executable`. Derive the host executable marking once: POSIX permission bits stay authoritative, and Windows marks regular files with the CreateProcess/cmd launchable extensions. Fixes #1819 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
76e4153d34
commit
91f843bf38
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { hostExecutableMarking } from "./hostExecutableMarking.js";
|
||||
|
||||
const file = (mode: number) => ({ mode, isFile: () => true });
|
||||
const directory = (mode: number) => ({ mode, isFile: () => false });
|
||||
|
||||
describe("hostExecutableMarking", () => {
|
||||
it("marks Windows launchable files by extension because NTFS has no execute bit", () => {
|
||||
expect(
|
||||
hostExecutableMarking("C:\\scratch\\whoami.exe", file(0o666), "win32"),
|
||||
).toBe(true);
|
||||
expect(
|
||||
hostExecutableMarking("C:\\scratch\\SETUP.CMD", file(0o444), "win32"),
|
||||
).toBe(true);
|
||||
expect(
|
||||
hostExecutableMarking("C:\\scratch\\library.dll", file(0o666), "win32"),
|
||||
).toBe(false);
|
||||
expect(
|
||||
hostExecutableMarking(
|
||||
"C:\\scratch\\tools.exe",
|
||||
directory(0o666),
|
||||
"win32",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps POSIX permission bits authoritative regardless of extension", () => {
|
||||
expect(hostExecutableMarking("/scratch/tool", file(0o755), "linux")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
hostExecutableMarking("/scratch/whoami.exe", file(0o644), "darwin"),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user