Skip to content

fix(security_guards): reject un-allowlisted .gitignore negations (fail-open on re-included personal data)#195

Merged
MadsLorentzen merged 1 commit into
MadsLorentzen:masterfrom
thejesh23:fix/aijs-001
Jul 20, 2026
Merged

fix(security_guards): reject un-allowlisted .gitignore negations (fail-open on re-included personal data)#195
MadsLorentzen merged 1 commit into
MadsLorentzen:masterfrom
thejesh23:fix/aijs-001

Conversation

@thejesh23

Copy link
Copy Markdown
Contributor

What changed and why

tools/security_guards.py check_gitignore() verified each required personal-data rule was present in .gitignore via set membership. But .gitignore is order-sensitive and supports negation (!pattern): a later !salary_data.json re-includes a file an earlier rule excluded. The required line is still physically present, so the guard reported OK while 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 existing ALLOWED_PERMISSIONS pattern: 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:

$ printf '\n!salary_data.json\n' >> .gitignore
$ python3 tools/security_guards.py; echo "guard exit: $?"
security_guards: OK (permissions allowlist, gitignore rules, package manifests)
guard exit: 0
$ git check-ignore salary_data.json; echo "check-ignore exit: $?"
check-ignore exit: 1        # 1 = NOT ignored → the file will be committed

With this change the guard exits 1 on that .gitignore and names the offending negation.

The new test GitignoreNegationTests.test_negation_reincluding_personal_data_fails fails on master (guard returns 0) and passes here; test_allowlisted_negations_pass confirms 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 0
  • python3 tools/check_framework_version.py → exit 0
  • Confirmed the new test fails against the master guard (0 != 1) and passes against the patched guard.

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.
@MadsLorentzen
MadsLorentzen merged commit 36462e3 into MadsLorentzen:master Jul 20, 2026
12 checks passed
@MadsLorentzen

Copy link
Copy Markdown
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.
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.

security_guards: .gitignore check fails open on negation rules (re-included personal data passes)

2 participants