forked from security-deriv/deployment_Precommit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pre-commit
19 lines (17 loc) · 797 Bytes
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Use `filesystem` if the git repo does not have any commits i.e its a new git repo.
if git log -1 > /dev/null 2>&1; then
trufflehog git file://. --no-update --since-commit HEAD --fail > /tmp/trufflehog_output_$(whoami) 2>&1
trufflehog_exit_code=$?
echo $trufflehog_exit_code > /tmp/trufflehog_exit_code_$(whoami)
else
trufflehog filesystem . --no-update --fail > /tmp/trufflehog_output_$(whoami) 2>&1
trufflehog_exit_code=$?
echo $trufflehog_exit_code > /tmp/trufflehog_exit_code_$(whoami)
fi
# Only display results to stdout if trufflehog found something.
if [ $trufflehog_exit_code -eq 183 ]; then
cat /tmp/trufflehog_output_$(whoami)
echo "TruffleHog found secrets. Aborting commit. use --no-verify to bypass it"
exit $trufflehog_exit_code
fi