From e8491e023a255f790ae9850225084d7495e9ade0 Mon Sep 17 00:00:00 2001 From: Itoje Dollar <163161978+dollarsmoney@users.noreply.github.com> Date: Sun, 11 Oct 2026 10:15:35 -0700 Subject: [PATCH] fix(artifacts): mark Windows launchable files as host executables (#1824) Host-file occurrences derived `executable` from POSIX execute bits, which Windows never reports, so every Windows host file (including PE .exe images classified as executable) reported `executable: false`. Derive the fact once through hostExecutable: POSIX hosts keep the execute bits; Windows marks regular files with the extensions it launches directly (.exe, .com, .bat, .cmd), without reading the ambient PATHEXT. Fixes #1819 Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> --- src/artifacts/hostExecutableMarking.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/artifacts/hostExecutableMarking.test.ts b/src/artifacts/hostExecutableMarking.test.ts index 7aff5bbda..9f97186d2 100644 --- a/src/artifacts/hostExecutableMarking.test.ts +++ b/src/artifacts/hostExecutableMarking.test.ts @@ -13,6 +13,16 @@ describe("hostExecutableMarking", () => { expect( hostExecutableMarking("C:\\scratch\\SETUP.CMD", file(0o444), "win32"), ).toBe(true); + for (const path of [ + "tools/SETUP.EXE", + "run.Cmd", + "build.bat", + "legacy.com", + ]) + expect(hostExecutableMarking(path, file(0o666), "win32")).toBe(true); + expect(hostExecutableMarking("readonly.exe", file(0o444), "win32")).toBe( + true, + ); expect( hostExecutableMarking("C:\\scratch\\library.dll", file(0o666), "win32"), ).toBe(false); @@ -25,6 +35,11 @@ describe("hostExecutableMarking", () => { ).toBe(false); }); + it("does not treat other Windows filenames as executable even with execute bits", () => { + for (const path of ["notes.txt", "README", "archive.exe.bak"]) + expect(hostExecutableMarking(path, file(0o777), "win32")).toBe(false); + }); + it("keeps POSIX permission bits authoritative regardless of extension", () => { expect(hostExecutableMarking("/scratch/tool", file(0o755), "linux")).toBe( true,