Skip to content

fix(test-all): scan only tracked files via git grep#185

Open
matkatmusic wants to merge 1 commit intosantifer:mainfrom
matkatmusic:fix-test-scan-untracked-files
Open

fix(test-all): scan only tracked files via git grep#185
matkatmusic wants to merge 1 commit intosantifer:mainfrom
matkatmusic:fix-test-scan-untracked-files

Conversation

@matkatmusic
Copy link
Copy Markdown

Closes #184.

Summary

The personal-data-leak check and absolute-path check in `test-all.mjs` use bare `grep -rn .`, which walks the entire working directory and only excludes a few hardcoded paths. This causes two opposite-sign bugs documented in #184:

  1. False positives on untracked files — local-only debate artifacts, plan drafts, AI scratch dirs, etc. fail the test even though they can never reach a commit.
  2. Silent misses on tracked files — brace expansion in `--include="*.{md,...}"` apparently fails to match i18n README files added in v1.3.0, so the leak check has been running green while 36+ matches in those files went unscanned.

Approach

Replace `grep -rn` with `git grep -n` in both checks. `git grep` only sees files in the index, so:

  • Untracked files can never false-positive
  • `.gitignore` is honored automatically
  • The manual `| grep -v node_modules | grep -v .git/ | grep -v go.sum` pipeline becomes dead code
  • Native pathspec syntax replaces brace expansion that wasn't working
  • The i18n READMEs (`README.es.md`, `README.ja.md`, `README.ko-KR.md`, `README.pt-BR.md`, `README.ru.md`) get scanned for the first time

Side effect: 36+ previously-hidden matches surfaced

The more thorough scan picks up legitimate maintainer credits in v1.3.0 community files. Added them to `allowedFiles`:

  • All 5 localized READMEs
  • `CODE_OF_CONDUCT.md`, `GOVERNANCE.md`, `SECURITY.md`, `SUPPORT.md`, `.github/SECURITY.md`
  • `dashboard/internal/ui/screens/pipeline.go` (credit string)

These are all legitimate references to Santiago / santifer.io as the maintainer, so they're correctly classified as allowed rather than suppressed.

Verification

Test Before fix After fix
`node test-all.mjs --quick` (clean tree) 64 pass / 6 fail / 0 warn 63 pass / 0 fail / 0 warn
Plant `/Users/santifer/test` in tracked `doctor.mjs` Caught ✅ Caught ✅ (no regression)
Plant `/Users/foo` in untracked `debates/test/test.md` Failed ❌ (false positive) Not flagged ✅
Untracked file with "Santiago" (would false-positive) Not flagged ✅

Diff stats: `+25 -6` in a single file. No new dependencies.

Test plan

  • `node test-all.mjs --quick` → all green on a clean working tree
  • Regression test: planted abs path in tracked file still fails
  • False-positive test: planted abs path in untracked file does not fail
  • Manual: confirmed git grep honors .gitignore
  • (Reviewer) verify on a different OS / git version if concerned about portability

Notes

  • This is independent of feat: filter expired and stale job postings by posting date #181 (filter-expired-results). They touch different parts of test-all.mjs and don't conflict.
  • I would have had to bake the `debates/` exclusion into my other PR otherwise; this fix is the cleaner solution and benefits any future contributor running AI tools that drop artifacts in the working tree.

🤖 Generated with Claude Code

The personal-data-leak and absolute-path checks used bare `grep -rn .`
which walks the entire working directory, only excluding 3 hardcoded
paths. This produced two problems:

1. False positives on untracked files. Any local-only file with a
   `/Users/` path or a stray "Santiago" — debate artifacts from
   /octo:debate, AI scratch dirs, plan drafts, Todos/ — would fail the
   test even though they could never reach a commit. The test exists
   to block bad commits, but it was punishing files git would never
   ship.

2. Silent misses on tracked files. Brace expansion in
   `--include="*.{md,yml,...}"` apparently failed to match the i18n
   READMEs santifer added in v1.3.0 (README.es.md, README.ja.md,
   README.ko-KR.md, README.pt-BR.md), so the leak check was running
   green while 36+ legitimate matches in those files went unscanned.

Fix: replace `grep -rn` with `git grep -n`. git grep only sees files
in the index, so:
  - untracked files can never false-positive
  - .gitignore is honored automatically
  - the manual `| grep -v node_modules | grep -v .git/ | grep -v go.sum`
    pipeline disappears (git grep already excludes these)
  - the i18n READMEs get scanned for the first time

Side effect: surfaces the previously-hidden matches in localized
READMEs and v1.3.0 community files (CODE_OF_CONDUCT, SECURITY,
SUPPORT, dashboard credits). Added these to `allowedFiles` so they
warn-clean — they all legitimately credit the maintainer.

Verification:
- node test-all.mjs --quick → 63 passed, 0 failed, 0 warnings
- Planted /Users/santifer/test in tracked doctor.mjs → still fails ✅
- Planted /Users/foo in untracked debates/test/test.md → no false positive ✅

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-all.mjs scans untracked files, causing false positives + silent misses

1 participant