summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/tests/test_git_index_locks.py
AgeCommit message (Collapse)Author
2026-10-27security-guidance: take the turn baseline without git stash createmhegazy/sg-prompt-snapshotMohamed Hegazy
stash create checks the work tree on one thread. add -u into the throwaway index copy, write-tree and commit-tree produce the same commit and use git's index preload instead, which matters where each file status is slow. See #6854.
2026-10-07security-guidance: stop a killed hook from leaving index copies behind ↵Mohamed Hegazy
(2.0.10 → 2.0.11) In a clone with a very large git index, 2.0.10 could still fill the disk. It copies the index for each git call that might write it, and a hook that Claude Code cancels (SIGTERM, then SIGKILL) never reached its cleanup, so every cancelled hook left index-sized files in the temp directory for up to 30 minutes. With several agents in one clone the live copies alone could take many GB. - A hook told to terminate removes its copies before it exits. - A copy's name records the hook's pid; the next run deletes copies whose hook is gone instead of waiting for the age limit. - Diffs no longer need a copy: diff.autoRefreshIndex is off, so they only read the index. Only `git stash create` and `git add -N` get one. - The copy is a hard link where the filesystem allows it. - Only so many hooks hold a copy at once, fewer as the disk fills. A hook that gets no slot within 5 s goes without: the baseline falls back to HEAD, or new untracked files are left out of that review. Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05security-guidance: leave nothing behind when git is killed (2.0.9 → 2.0.10)mhegazy/sg-temp-index-cleanupMohamed Hegazy
With a very large git index the hook's git calls hit their time limits and are killed, so git cannot clean up. Each kill could leave an index-sized file in the temp directory, index.stash.<pid> files in .git, and a dead .git/index.lock that fails the user's next git add or commit. - `git stash create` and the work-tree diff run on a throwaway index copy. - Every git the hook spawns gets GIT_OPTIONAL_LOCKS=0. - Copies live in a private per-user folder and are removed together with the files git writes next to them. - Leftovers older than 30 minutes are swept, including existing ones. Co-Authored-By: Claude <noreply@anthropic.com>