#!/usr/bin/env bash # Fails (exit 1, file:line on stdout) on anything that must not ship publicly: # API tokens, private keys, local absolute paths, IPv4 literals, private hostnames. set -u dir=${1:-.} pat='hf_[A-Za-z0-9]{30,}|ghp_[A-Za-z0-9]{20,}|github_pat_|sk-[A-Za-z0-9_-]{20,}|AKIA[0-9A-Z]{16}|PRIVATE KEY|/home/[a-z]|/media/[a-z]|/tmp/claude|kunix|\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b' hits=$(grep -rInE "$pat" "$dir" --exclude-dir=.git --exclude-dir=__pycache__ --exclude=scan.sh) if [ -n "$hits" ]; then echo "$hits" exit 1 fi exit 0