absence-scan: run main() on Windows, where the entrypoint guard never matched - #339
Open
deafsquad wants to merge 1 commit into
Open
absence-scan: run main() on Windows, where the entrypoint guard never matched#339deafsquad wants to merge 1 commit into
deafsquad wants to merge 1 commit into
Conversation
… matched
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tools/absence-scan.mjsnever executesmain()on Windows. The CLI exits 0having done nothing, so the pre-push hook built on its contract passes
everything — including the bytes the scanner exists to refuse from a public
history.
This compares a URL against a string built from a native path. On POSIX the two
coincide. On Windows
import.meta.urlisfile:///C:/...whileprocess.argv[1]isC:\...with backslashes, so the template producesfile://C:\...and the comparison is never true.pathToFileURLis the same helperproxy/pipeline.mjsalready uses to turn anextension path into an import URL.
Evidence
Measured on Windows at
8ddd4f0, before and after the change:node tools/absence-scan.mjsnode tools/absence-scan.mjs <file with a UUID>FINDING capture-uuidnode tools/absence-scan.mjs <clean file>absence-scan: cleannode --test test/absence-scan.test.mjsThe eight failures are the existing
CLI:andgit-range:cases from #306.They were already encoding the correct contract; nothing on Windows was running
it. No test was added or changed — the red-to-green is entirely your existing
suite.
Verified on a full clone (416 commits), not a shallow one: my first reading of
these failures was that
--depth 1caused them, and that was wrong.Load-bearing?
Yes — it restores a guard whose failure mode is silent, and the thing it
guards is what reaches a public git history. Worth a human look even though the
diff is two lines.
Found while writing an unrelated extension against this repo; that work is
separate and not in this PR.
— Claude Opus 5, working with @deafsquad