name: Secret Scanning on: push: branches: [main] pull_request: branches: [main] # Run weekly on schedule for ongoing monitoring schedule: - cron: '0 6 * * 1' # Mondays at 06:00 UTC permissions: contents: read security-events: write jobs: trufflehog: name: Trufflehog Secret Scanning runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: # Fetch full history for thorough scanning fetch-depth: 0 - name: Install TruffleHog run: | # The trufflesecurity/trufflehog GitHub Action uses a Docker image # whose :latest CLI (v3.97.4) removed the `scan` subcommand and the # --format/--output flags that the action's run.sh still passes. # Install the binary directly instead. curl -sSL https://github.com/trufflesecurity/trufflehog/releases/download/v3.97.4/trufflehog_3.97.4_linux_amd64.tar.gz | tar -xz -C /usr/local/bin/ trufflehog --help | head -1 - name: Run TruffleHog # --sarif outputs SARIF to stdout; redirect to file (no --output flag) # --fail exits 183 if secrets found; continue-on-error makes non-blocking # --exclude-paths uses .trufflehog-exclude.txt to skip files/paths # that routinely produce false positives (e.g. .git/ metadata, # Pi-hole blocklists with domain-name patterns matching secret detectors) run: | trufflehog filesystem . --sarif --fail --no-update -x .trufflehog-exclude.txt > results.sarif continue-on-error: true - name: Upload TruffleHog results to GitHub Security tab # Only upload if the SARIF file was created if: always() && hashFiles('results.sarif') != '' uses: github/codeql-action/upload-sarif@v4 with: sarif_file: results.sarif checkout_path: .