Last active
March 21, 2016 15:42
-
-
Save stevendanna/4db970716cabb8f5def4 to your computer and use it in GitHub Desktop.
Pre-commit hook to help prevent key leakage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Warn about possible cloud access keys before committing | |
# | |
exec </dev/tty | |
unset possible_keys | |
possible_keys=$(git diff --cached | egrep '^[+\-].*(AKIA|AWS_ACCESS|AWS_SECRET|OS_PASSWORD|OS_USERNAME)') | |
if [[ -n "$possible_keys" ]];then | |
echo -e "WARNING: Diff contains possible access keys:\n" | |
echo "${possible_keys}" | |
echo "" | |
read -p "Continue to commit? (y/n)" answer | |
case $answer in | |
y*) | |
echo "OK. Committing." | |
exit 0 | |
;; | |
n*) | |
echo "OK. Not Committing." | |
exit 1 | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment