Skip to content
Snippets Groups Projects
Commit 988ede13 authored by Francisco Perez's avatar Francisco Perez
Browse files

Merge branch 'a_small_pre-commit-script_to_check_out_secrets' into 'main'

Adding a small pre-commit script to check out a presence of secrets using...

See merge request !17
parents 7c3b09f8 6eed1885
No related branches found
No related tags found
1 merge request!17Adding a small pre-commit script to check out a presence of secrets using...
#!/bin/sh
### This is a small pre-commit script that checks for the presence of secrets using ggshield.
### If ggshield is not installed, it will run a custom list of grep expressions to perform the secret check
set -ep
# Function to check if a command is available
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if ggshield is installed
if command_exists ggshield; then
# Run ggshield to scan for sensitive information
ggshield secret scan pre-commit "$@"
else
# Display a warning if ggshield is not installed
echo "WARNING: ggshield is not installed."
echo
echo "INFO: Please consider to installing by following the steps below:"
echo "pip install --user -U ggshield"
echo "ggshield auth login"
echo
echo "INFO: Running a custom lit of grep to check for common passwords patterns."
# Run grep to search for potential passwords (modify this command as needed)
if grep -r -I -E '(?:ghp|gho|ghu|ghs|ghr)_[0-9a-zA-Z]{36,}' . >/dev/null; then
echo "WARNING: Potential Github passwords found. Commit blocked."
exit 1
fi
fi
# If everything is fine, allow the commit to proceed
echo
echo "INFO: No issues found out"
exit 0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment