False positive: harmless `git -C <dir>` commands that mention `.env` are blocked

Open Beginner friendly
#24 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, python
Domain
security, testing

Research direction

Start with safe_file_operation in scripts/paths.py and compare its command parsing with the Git checks referenced in #19. Update the handling of -C <dir> so the four listed non-printing commands are allowed while git -C app show HEAD:.env remains blocked. Add coverage for all five cases in tests/test_redteam.py and run that test file to verify the behavior.

Written by the indexing model from the issue text.

Description

bug

Plain-git versions of these are allowed because they never print the file's contents. With -C <dir> they are blocked:

  • git -C app rm --cached .env
  • git -C app commit -m "chore: stop tracking .env"
  • git -C app check-ignore -v .env
  • git -C app log --oneline -- .env

(git -C app show HEAD:.env prints the file, so it should stay blocked.)

Cause: safe_file_operation in scripts/paths.py only recognises these when the subcommand comes straight after git.

Done when

  • safe_file_operation uses the same -C handling as the Git checks (see #19), so the four commands above are allowed and git -C app show HEAD:.env is still blocked.
  • tests/test_redteam.py covers all five.

Generated by Claude Code

Dominant language
Python
Stars
1
Forks
1
Avg merge
2h 28m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JTHCode/secretguard

All issues in JTHCode/secretguard

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.