git push hook regex false-positives on branch names containing "main"
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Find the git push PreToolUse hook and inspect its current branch-name regex, then compare its matching rules with the rm hook referenced in #33. Update the matching behavior so the listed protected refs are blocked while the allowed branch names and bare push remain allowed.
Written by the indexing model from the issue text.
Description
The git push PreToolUse hook matches main/master anywhere in the command string, blocking pushes to branches that contain these as substrings:
git push -u origin deps/aiohttp-3.13.5-remaining # blocked — "main" in "remaining"
git push origin feature/maintain-state # blocked — "main" in "maintain"
git push origin fix/mainframe-bug # blocked — "main" in "mainframe"
The fix requires main/master to appear as a standalone ref target by checking the preceding character is a whitespace, colon (refspec), slash (fully-qualified ref), or + (force-push prefix):
-git[[:space:]]+push.*(main|master)
+git[[:space:]]+push[[:space:]].*([[:space:]]|:|/|\+)(main|master)([[:space:]]|$)
This matches the rigor level applied to the rm hook in #33.
Blocked:
git push origin maingit push -u origin maingit push origin feature:main(refspec)git push origin refs/heads/main(fully-qualified)git push origin +main(force prefix)git push origin HEAD:refs/heads/main
Allowed:
git push -u origin deps/aiohttp-3.13.5-remaininggit push origin feature/maintain-stategit push origin fix/mainframe-buggit push(bare push to tracking branch)
- Dominant language
- Shell
- Stars
- 2.1k
- Forks
- 161
- Avg merge
- 3d 59m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from trailofbits/claude-code-config
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in trailofbits/claude-code-config
Similar issues
-
docs(agents): strengthen the no-backslash-escaped-backticks rule with an issue-creation example Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
package-update
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
oSoWoSo/vOid_Community_repOsitory#148 · 1 comment ·
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 91/100
alunduil/alunduil-chezmoi#792 ·
-
area: compat bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
zenhub-dev
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OpenLiberty/ci.docker#747 ·