2626ERRORS=0
2727
2828# Check for .DS_Store files.
29- echo " Checking for .DS_Store files..."
29+ printf " Checking for .DS_Store files...\n "
3030if echo " $STAGED_FILES " | grep -q ' \.DS_Store' ; then
3131 echo " ${RED} ✗ ERROR: .DS_Store file detected!${NC} "
3232 echo " $STAGED_FILES " | grep ' \.DS_Store'
3333 ERRORS=$(( ERRORS + 1 ))
3434fi
3535
3636# Check for log files.
37- echo " Checking for log files..."
37+ printf " Checking for log files...\n "
3838if echo " $STAGED_FILES " | grep -E ' \.log$' | grep -v ' test.*\.log' ; then
3939 echo " ${RED} ✗ ERROR: Log file detected!${NC} "
4040 echo " $STAGED_FILES " | grep -E ' \.log$' | grep -v ' test.*\.log'
4141 ERRORS=$(( ERRORS + 1 ))
4242fi
4343
4444# Check for .env files.
45- echo " Checking for .env files..."
45+ printf " Checking for .env files...\n "
4646if echo " $STAGED_FILES " | grep -E ' ^\.env(\.local)?$' ; then
4747 echo " ${RED} ✗ ERROR: .env or .env.local file detected!${NC} "
4848 echo " $STAGED_FILES " | grep -E ' ^\.env(\.local)?$'
49- echo " These files should never be committed. Use .env.example instead."
49+ printf " These files should never be committed. Use .env.example instead.\n "
5050 ERRORS=$(( ERRORS + 1 ))
5151fi
5252
5353# Check for hardcoded user paths (generic detection).
54- echo " Checking for hardcoded personal paths..."
54+ printf " Checking for hardcoded personal paths...\n "
5555for file in $STAGED_FILES ; do
5656 if [ -f " $file " ]; then
5757 # Skip test files and hook scripts.
@@ -63,26 +63,26 @@ for file in $STAGED_FILES; do
6363 if grep -E ' (/Users/[^/\s]+/|/home/[^/\s]+/|C:\\Users\\[^\\]+\\)' " $file " 2> /dev/null | grep -q . ; then
6464 echo " ${RED} ✗ ERROR: Hardcoded personal path found in: $file ${NC} "
6565 grep -n -E ' (/Users/[^/\s]+/|/home/[^/\s]+/|C:\\Users\\[^\\]+\\)' " $file " | head -3
66- echo " Replace with relative paths or environment variables."
66+ printf " Replace with relative paths or environment variables.\n "
6767 ERRORS=$(( ERRORS + 1 ))
6868 fi
6969 fi
7070done
7171
7272# Check for Socket API keys.
73- echo " Checking for API keys..."
73+ printf " Checking for API keys...\n "
7474for file in $STAGED_FILES ; do
7575 if [ -f " $file " ]; then
7676 if grep -E ' sktsec_[a-zA-Z0-9_-]+' " $file " 2> /dev/null | grep -v " $ALLOWED_PUBLIC_KEY " | grep -v ' your_api_key_here' | grep -v ' SOCKET_SECURITY_API_KEY=' | grep -v ' fake-token' | grep -v ' test-token' | grep -q . ; then
7777 echo " ${YELLOW} ⚠ WARNING: Potential API key found in: $file ${NC} "
7878 grep -n ' sktsec_' " $file " | grep -v " $ALLOWED_PUBLIC_KEY " | grep -v ' your_api_key_here' | grep -v ' fake-token' | grep -v ' test-token' | head -3
79- echo " If this is a real API key, DO NOT COMMIT IT."
79+ printf " If this is a real API key, DO NOT COMMIT IT.\n "
8080 fi
8181 fi
8282done
8383
8484# Check for common secret patterns.
85- echo " Checking for potential secrets..."
85+ printf " Checking for potential secrets...\n "
8686for file in $STAGED_FILES ; do
8787 if [ -f " $file " ]; then
8888 # Skip test files, example files, and hook scripts.
@@ -113,9 +113,9 @@ for file in $STAGED_FILES; do
113113done
114114
115115if [ $ERRORS -gt 0 ]; then
116- echo " "
116+ printf " \n "
117117 echo " ${RED} ✗ Security check failed with $ERRORS error(s).${NC} "
118- echo " Fix the issues above and try again."
118+ printf " Fix the issues above and try again.\n "
119119 exit 1
120120fi
121121
0 commit comments