Skip to content

Commit

Permalink
Add gitleaks pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowning committed Sep 20, 2022
1 parent 780264e commit 6e676ad
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/git-hooks/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh


##################
# Spotless
##################

echo "Running Spotless..."
./gradlew spotlessCheck
RESULT=$?
Expand All @@ -13,4 +18,24 @@ if [ $RESULT -ne 0 ]; then
echo "Recommended changes from spotless have been applied."
fi

##################
# gitleaks
##################

if ! command -v gitleaks &> /dev/null
then
echo ""
echo "Error: gitleaks script not found, please install it (https://github.com/zricethezav/gitleaks)"
exit 1
fi

gitleaks protect -v --staged
RESULT=$?

if [ $RESULT -ne 0 ]; then
echo ""
echo "Warning: gitleaks has detected sensitive information in your changes. Aborting commit."
exit 1
fi

exit $RESULT

0 comments on commit 6e676ad

Please sign in to comment.