fix(security_guards): reject un-allowlisted .gitignore negations (fail-open on re-included personal data)#195
Merged
Conversation
check_gitignore verified each required personal-data rule was present via set membership, but .gitignore is order-sensitive: a later `!salary_data.json` re-includes a file an earlier rule excluded, so the required line stays physically present while the file is no longer ignored. The guard reported OK on a .gitignore that no longer protected salary_data.json. Keep the required-rules-present check and additionally reject any negation line not in a small reviewed allowlist (ALLOWED_IGNORE_NEGATIONS), mirroring the existing ALLOWED_PERMISSIONS "make widening explicit" pattern. Add tests: a negation re-including personal data now fails (0->1 on master), the four shipped benign negations still pass.
Owner
|
Merged - thank you, and welcome. Filing the issue and the fix together, each scoped to one concern, is exactly the shape that makes a review fast. I reproduced the fail-open and ran the guard suite locally before merging - the negation test and the benign-allowlist test both hold, and the allowlist matches the four negations the template legitimately ships today. The same-PR "add an intentional negation here, explicitly" convention mirrors how ALLOWED_PERMISSIONS already works, so it reads as native to the guard. Strong first contribution - and there's a companion PR (#199) that fixes an active leak in the same area (a rooted seen_jobs.json rule that never matches the real path); your guard hardening and that fix reinforce each other well. |
MadsLorentzen
pushed a commit
that referenced
this pull request
Jul 21, 2026
…#208) job_scraper/seen_jobs.json (and notion_sync.json / *.md) were ignored by a repo-rooted pattern, but the job-scraper skill resolves job_scraper/ relative to its own directory, so the state file lands at .claude/skills/job-scraper/job_scraper/ and the rule never matched - publishing every scraped posting with fit scores and skip-reasons on a public fork. Switches to **/-prefixed patterns that match at any depth (the rooted location still matches too, so no regression), and adds documents/interview/** (interview prep names employers, quotes submitted material, and lists the candidate's weak points) - it was never ignored though documents/applications/** was. REQUIRED_IGNORE_RULES updated in lockstep so the security guard stays in sync. By @LeoWinston-9596 (split from #199). Verified: both nested and root seen_jobs.json now ignored, interview records ignored, guard suite green (17 tests incl. #195's negation checks). Rebased cleanly on current master.
simonhasselhof
pushed a commit
to simonhasselhof/ai-job-search
that referenced
this pull request
Jul 22, 2026
…MadsLorentzen#208) job_scraper/seen_jobs.json (and notion_sync.json / *.md) were ignored by a repo-rooted pattern, but the job-scraper skill resolves job_scraper/ relative to its own directory, so the state file lands at .claude/skills/job-scraper/job_scraper/ and the rule never matched - publishing every scraped posting with fit scores and skip-reasons on a public fork. Switches to **/-prefixed patterns that match at any depth (the rooted location still matches too, so no regression), and adds documents/interview/** (interview prep names employers, quotes submitted material, and lists the candidate's weak points) - it was never ignored though documents/applications/** was. REQUIRED_IGNORE_RULES updated in lockstep so the security guard stays in sync. By @LeoWinston-9596 (split from MadsLorentzen#199). Verified: both nested and root seen_jobs.json now ignored, interview records ignored, guard suite green (17 tests incl. MadsLorentzen#195's negation checks). Rebased cleanly on current master.
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 changed and why
tools/security_guards.pycheck_gitignore()verified each required personal-data rule was present in.gitignorevia set membership. But.gitignoreis order-sensitive and supports negation (!pattern): a later!salary_data.jsonre-includes a file an earlier rule excluded. The required line is still physically present, so the guard reportedOKwhile the file was no longer ignored — the guard failed open on exactly the weakening its docstring says it catches.This keeps the required-rules-present check and additionally rejects any negation line not in a small reviewed allowlist,
ALLOWED_IGNORE_NEGATIONS(the four benign negations the template already ships). It mirrors the existingALLOWED_PERMISSIONSpattern: an intentional negation must be added to the allowlist in the same PR, so the widening is explicit and reviewable.Fixes #194
Failing case / reproduction (for fixes)
On
master:With this change the guard exits 1 on that
.gitignoreand names the offending negation.The new test
GitignoreNegationTests.test_negation_reincluding_personal_data_failsfails onmaster(guard returns 0) and passes here;test_allowlisted_negations_passconfirms the four shipped negations still pass.Verification
python3 tools/security_guards.py→ OK (real repo's four live negations are allowlisted)python3 -m unittest discover -s tests -t . -v→ 17 tests OK (2 new)python3 tools/lint_skills.py→ exit 0python3 tools/check_framework_version.py→ exit 0masterguard (0 != 1) and passes against the patched guard.