Skip to content

fix(hooks): add -- to grep for private key pattern#1197

Closed
John-David Dalton (jdalton) wants to merge 2 commits intomainfrom
fix/hooks-grep-dash-fix
Closed

fix(hooks): add -- to grep for private key pattern#1197
John-David Dalton (jdalton) wants to merge 2 commits intomainfrom
fix/hooks-grep-dash-fix

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

@jdalton John-David Dalton (jdalton) commented Apr 13, 2026

The private key grep pattern starts with dashes which grep interprets as options. Add -- to signal end of options.


Note

Medium Risk
Changes pre-push secret scanning behavior by inspecting binary files via strings and reworking all checks to operate on extracted content, which could introduce new false positives/negatives and unexpectedly block pushes.

Overview
Improves the .git-hooks/pre-push secret scanner by normalizing file inspection: it now detects binary files and scans strings output instead of grepping raw bytes, while keeping text files scanned directly.

Updates all secret/path detectors to operate on the extracted file_text, and hardens the private-key check by using grep -- so the -----BEGIN ... pattern isn’t treated as an option.

Reviewed by Cursor Bugbot for commit fa4ebfd. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fa4ebfd. Configure here.


# Check for private keys.
if grep -E '-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----' "$file" 2>/dev/null | grep -q .; then
if echo "$file_text" | grep -qE -- '-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----'; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Companion security-checks.sh not kept in sync as required

Medium Severity

Line 5 of this file states "Security checks parallel .husky/security-checks.sh — keep in sync." The -- fix for the private key grep pattern and the binary file handling were only applied here, but .husky/security-checks.sh (line 110) still uses the old grep -E '-----BEGIN ...' pattern without --. This means the pre-commit hook still has the original bug where the dash-prefixed pattern can be misinterpreted as grep options.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fa4ebfd. Configure here.

@jdalton
Copy link
Copy Markdown
Contributor Author

Merged into #1196

@jdalton John-David Dalton (jdalton) deleted the fix/hooks-grep-dash-fix branch April 14, 2026 01:02
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.

1 participant