# Create monitoring scriptcat > /usr/local/bin/trufflehog-monitor.sh << 'EOF'#!/bin/bashREPOS_DIR="/opt/repositories"REPORT_DIR="/var/log/trufflehog"DATE=$(date +%Y%m%d)mkdir -p $REPORT_DIRfor repo in $REPOS_DIR/*; do if [ -d "$repo/.git" ]; then repo_name=$(basename $repo) echo "Scanning $repo_name..." cd $repo git pull --quiet trufflehog git file://. --only-verified --json \ > $REPORT_DIR/${repo_name}-${DATE}.json # Alert if secrets found if [ $(jq length $REPORT_DIR/${repo_name}-${DATE}.json) -gt 0 ]; then echo "⚠️ Secrets found in $repo_name" | \ mail -s "TruffleHog Alert: $repo_name" security@company.com fi fidoneEOFchmod +x /usr/local/bin/trufflehog-monitor.sh# Add to crontab (daily at 2 AM)echo "0 2 * * * /usr/local/bin/trufflehog-monitor.sh" | crontab -```### CI/CD 통합 구성`--only-verified`#### GitHub Actions`trufflehog git file://.``.trufflehogignore`#### GitLab CI`--filter-entropy`코드베이스를 기반으로 비밀 정보 감지와 거짓 양성(false positive) 최소화 사이의 균형을 맞추기 위해 (기본값 3.0이 대부분의 경우에 적합합니다).- **스캔 결과 보관 및 분석**: 규정 준수 감사, 추세 분석, 시간에 따른 보안 태세 개선 입증을 위해 타임스탬프와 함께 스캔 결과를 저장합니다.## 문제 해결| 문제 | 솔루션 ||-------|----------|| **"No git repository found"** | Ensure you're in a git repository directory or use `git init` to initialize. For remote repos, check URL syntax and network connectivity. || **High number of false positives** | Use `--only-verified` to show only active secrets, increase `--filter-entropy` threshold (e.g., `--filter-entropy=4.5`), or create custom exclude patterns in `.trufflehogignore`. || **Scan is very slow on large repositories** | Use `--max-depth` to limit commit history depth, `--since-commit` to scan recent changes only, or increase `--concurrency` value (e.g., `--concurrency=16`). || **"Rate limit exceeded" for GitHub** | Provide authentication token with `--token=ghp_xxxxx`, wait for rate limit reset, or use GitHub Enterprise endpoint if available. || **Docker scan fails with permission errors** | Run Docker commands with `sudo`, add user to docker group (`sudo usermod -aG docker $USER`), or use `docker run --rm -v $(pwd):/scan trufflesecurity/trufflehog:latest`. || **Secrets not being verified** | Check internet connectivity for verification requests, use `--allow-verification-overlap` if multiple detectors should verify, or disable verification with `--no-verification` for offline scanning. || **Out of memory errors on large scans** | Reduce `--concurrency` value, scan in smaller commit ranges using `--since-commit` and `--until-commit`, or increase system memory allocation. || **GitLab/GitHub Enterprise connection fails** | Verify custom endpoint URL with `--endpoint` flag, check token permissions (needs read access to repos), and ensure SSL certificates are valid. || **JSON output is malformed** | Ensure you're using latest TruffleHog version, redirect stderr separately (`2>/dev/null`), or use `jq` to validate and format output (`trufflehog ... --json \ | jq`). || **Pre-commit hook not triggering** | Verify hook is executable (`chmod +x .git/hooks/pre-commit`), check shebang line is correct (`#!/bin/bash`), and ensure TruffleHog is in PATH. || **S3 scan authentication fails** | Set AWS credentials via environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`), use `--key` and `--secret` flags, or configure AWS CLI profile. || **사용자 정의 탐지기 작동 안 함** | YAML 구성 파일의 구문을 확인하고, 정규식 패턴이 제대로 이스케이프되었는지 확인하며, 탐지기 이름이 고유한지 검증하고, 정규식 패턴을 별도로 테스트하세요. |
This site uses cookies for analytics and to improve your experience.
See our Privacy Policy for details.