Skip to content

Instantly share code, notes, and snippets.

@bskinner
Last active April 5, 2024 16:20
Show Gist options
  • Save bskinner/74f3861c502c5c477a1cda8e8b439949 to your computer and use it in GitHub Desktop.
Save bskinner/74f3861c502c5c477a1cda8e8b439949 to your computer and use it in GitHub Desktop.
git-secrets pattern provider
#!/usr/bin/env bash
set -eu
# Patterns
patterns=(
# SSH private keys
"[-]----BEGIN\\sRSA\\sPRIVATE\\sKEY-----"
"[-]----BEGIN\\sDSA\\sPRIVATE\\sKEY-----"
"[-]----BEGIN\\sEC\\sPRIVATE\\sKEY-----"
"[-]----BEGIN\\sPGP\\sPRIVATE\\sKEY\\sBLOCK-----"
# Docker access tokens
"dckr_[A-Za-z0-9_]{20,48}"
# Github access tokens
"(^|\\W)gh[pousr]_[A-Za-z0-9_]{30,255}"
# Google API key
"(^|\\W)AIza[_0-9A-Za-z-]{35}"
# Google Credential file
"(\"type\":\\s\"service_account\"|\"privateKeyType\":\\s\"TYPE_GOOGLE_CREDENTIALS_FILE\",)"
"(^|\\W)ya29\\.[_0-9A-Za-z-]+"
"[h|H][e|E][r|R][o|O][k|K][u|U].*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}"
# Slack webhooks
"https://hooks.slack.com/services/T[_0-9A-Za-z]{8}/B[_0-9A-Za-z]{8,10}/[_0-9A-Za-z]{24}"
# Slack access tokens
"(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})"
# Stripe API keys
"sk_live_[0-9a-z]{32}"
"sk_live_[0-9a-zA-Z]{24}"
"rk_live_[0-9a-zA-Z]{24}"
"sk_test_[0-9a-z]{32}"
"sk_test_[0-9a-zA-Z]{24}"
"rk_test_[0-9a-zA-Z]{24}"
# Square access tokens
"sq0atp-[_0-9A-Za-z-]{22}"
"sq0csp-[_0-9A-Za-z-]{43}"
"(^|\\W)SK[0-9a-fA-F]{32}"
# SendGrid
# SG.<base64url>.<base64url>
"[Ss][Gg]\.[0-9A-Za-z-_]{22}\.[0-9A-Za-z-_]{43}"
# Auth0 Client Secret
# base64url encoded
"[0-9A-Za-z-_]{65}"
)
for pattern in ${patterns[@]}; do
echo "$pattern"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment