Skip to content

Commit 78ca948

Browse files
authored
absence-scan: run main() on Windows, where the entrypoint guard never matched (#339)
The CLI exits 0 having done nothing on Windows, so the pre-push hook built on it passes everything — including the bytes the scanner exists to refuse. `import.meta.url === \`file://${process.argv[1]}\`` compares a URL against a string built from a native path. On POSIX those coincide. On Windows import.meta.url is file:///C:/... while process.argv[1] is C:\... with backslashes, so the template produces file://C:\... and the comparison is never true. main() is never called. pathToFileURL is the same helper proxy/pipeline.mjs already uses to turn an extension path into an import URL. Measured on Windows at 8ddd4f0, before and after: node tools/absence-scan.mjs exit 0, no output -> exit 1 + usage node tools/absence-scan.mjs <file with a UUID> exit 0, no output -> exit 2 + FINDING capture-uuid node tools/absence-scan.mjs <clean file> exit 0, no output -> exit 0 + "absence-scan: clean" node --test test/absence-scan.test.mjs 11 pass / 8 fail -> 19 pass / 0 fail The eight failures are the existing CLI: and git-range: cases. They were already encoding the correct contract; nothing on Windows was running it.
1 parent 02ea227 commit 78ca948

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tools/absence-scan.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import { readFileSync } from "node:fs";
3535
import { execFileSync } from "node:child_process";
3636
import { basename } from "node:path";
37+
import { pathToFileURL } from "node:url";
3738

3839
// --- Allowlist ---------------------------------------------------------------
3940
//
@@ -467,7 +468,12 @@ function main(argv) {
467468
return 0;
468469
}
469470

470-
if (import.meta.url === `file://${process.argv[1]}`) {
471+
// Entrypoint guard. pathToFileURL, NOT `file://${argv[1]}`: on Windows
472+
// import.meta.url is file:///C:/... while argv[1] is C:\... with backslashes,
473+
// so the template form never matches and main() never runs — the CLI becomes a
474+
// silent exit-0 no-op, and the pre-push hook that depends on it passes
475+
// everything. Same helper proxy/pipeline.mjs already uses for its loader.
476+
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
471477
let code;
472478
try {
473479
code = main(process.argv);

0 commit comments

Comments
 (0)