Skip to content

Commit 75251bb

Browse files
committed
test(service): pin the file mode on POSIX only, not on Windows
The Windows CI shard reported these three as failures: Bun on Windows returns 0666 from statSync for an ordinary file no matter what mode the write asked for, because Windows does not implement POSIX permission bits at all. The assertion was testing the emulation layer, not the security property. The real boundary on Windows is the NTFS ACL, which hardenSecretPath applies and which the credential-detection tests already cover — those decide whether that ACL is required or best-effort, which is the question that actually matters there. So these three skip on win32 and keep asserting the octal everywhere the octal means something. Refs #2107 Worth being precise about what this does and does not fix: three of the 25 Windows shard-4 failures were mine, and they are gone. The other 22 are not — Log Guard, WP13 composed toggle, /api/keys, and the anthropic 413 retry were already failing on run 32147924436 (e446607, 2026-08-18), before any of this work landed, and none of them touch files in this range.
1 parent 15527f8 commit 75251bb

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎tests/service.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,15 @@ describe("service serving confirmation", () => {
21782178
describe("service definitions are not world-readable", () => {
21792179
const modeOf = (path: string): string => (statSync(path).mode & 0o777).toString(8);
21802180

2181-
test("a freshly written definition is owner-only", () => {
2181+
// Windows does not implement POSIX permission bits — Bun reports 0666 for an ordinary
2182+
// file regardless of what `mode` asked for, and the real boundary there is the NTFS ACL
2183+
// applied by hardenSecretPath. Asserting the octal on Windows tests the emulation layer
2184+
// rather than the security property, so these three pin the POSIX half only. The Windows
2185+
// half is covered by the credential-detection tests below, which decide whether that ACL
2186+
// is applied strictly.
2187+
const posixOnly = process.platform === "win32" ? test.skip : test;
2188+
2189+
posixOnly("a freshly written definition is owner-only", () => {
21822190
const dir = mkdtempSync(join(tmpdir(), "ocx-service-mode-"));
21832191
try {
21842192
const path = join(dir, "unit");
@@ -2192,7 +2200,7 @@ describe("service definitions are not world-readable", () => {
21922200
}
21932201
});
21942202

2195-
test("an install over a loose definition from an older version tightens it", () => {
2203+
posixOnly("an install over a loose definition from an older version tightens it", () => {
21962204
// `mode` applies only on creation, so a reinstall would otherwise leave 0644 standing.
21972205
const dir = mkdtempSync(join(tmpdir(), "ocx-service-mode-"));
21982206
try {
@@ -2208,7 +2216,7 @@ describe("service definitions are not world-readable", () => {
22082216
}
22092217
});
22102218

2211-
test("utf16le scheduler assets take the same mode", () => {
2219+
posixOnly("utf16le scheduler assets take the same mode", () => {
22122220
const dir = mkdtempSync(join(tmpdir(), "ocx-service-mode-"));
22132221
try {
22142222
const path = join(dir, "task.xml");

0 commit comments

Comments
 (0)