fix(scripts): sanity check self-exclusion on POSIX#2
Merged
Conversation
The previous self-exclusion used `new URL(import.meta.url).pathname.replace(/^\//, "")`, which works on Windows (pathname looks like `/C:/Users/...`, stripping the leading slash yields a usable path) but breaks on POSIX (pathname is already `/abs/path/...`, and stripping the leading slash makes it relative, so the equality against `relative(ROOT, full)` never matches). Result: on Linux and macOS the script scans itself, hits the personal-token regex's own pattern definition at line 40, and reports 9 false-positive "leaks" all pointing at scripts/check-sanity.mjs:40. Windows CI passed; POSIX CI has been red on every push since the script landed. Two consequences: - Merge-to-main CI red on Mac and Ubuntu for the past several releases. - More importantly, the sanity check has not actually been running on POSIX CI. A real leak in any shipped file would never have surfaced because the script self-fails first. Fix: use Node's `fileURLToPath(import.meta.url)`, which returns a correct absolute path on every platform. Verified locally on Windows (`npm run lint` still passes). POSIX verification depends on CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes a cross-platform bug in
scripts/check-sanity.mjsthat has been silently breaking Mac and Ubuntu CI for several releases.The script's self-exclusion logic used
new URL(import.meta.url).pathname.replace(/^\//, ""), which works on Windows but breaks on POSIX. The wrong path meansSELFnever matches the actual file during the walk, the script scans itself, hits its own personal-token regex definition at line 40, and reports 9 false-positive "leaks" all pointing atscripts/check-sanity.mjs:40.Why CI looked passing
Windows CI (Node 20.x and 22.x) passed because the self-exclusion happens to work there. Mac and Ubuntu have been red on the same job since the script landed. Net effect: the sanity check has not actually been running on POSIX CI. A real personal-data leak in any shipped file would never have surfaced through POSIX, because the script self-fails before scanning anything else.
Fix
Use
fileURLToPath(import.meta.url)instead of manual pathname manipulation. It returns a correct absolute path on every platform.Test plan
npm run lintpasses locally on Windows (regression check)🤖 Generated with Claude Code