Skip to main content
gitleaks Run Gitleaks for hardcoded secrets detection in code and git history. Use when scanning for API keys, passwords, tokens, certificates, or sensitive credentials in source code and commit history.
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/igbuend/grimbard --skill gitleaks명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... name gitleaks description Run Gitleaks for hardcoded secrets detection in code and git history. Use when scanning for API keys, passwords, tokens, certificates, or sensitive credentials in source code and commit history. allowed-tools ["Bash","Read","Glob","Grep"]
Gitleaks Secret Detection
When to Use Gitleaks
Ideal scenarios:
Scanning for hardcoded secrets in source code
Auditing git history for leaked credentials
Pre-commit hooks to prevent secret commits
CI/CD pipeline secret detection
Finding API keys, passwords, tokens, private keys
Compliance requirements for credential management
Complements other tools:
Use before manual code review to catch obvious secrets
Combine with SARIF Issue Reporter for detailed analysis
Use alongside Application Inspector for comprehensive security audit
When NOT to Use
Do NOT use this skill for:
Code vulnerability detection (use Semgrep or CodeQL)
Dependency scanning (use OSV-Scanner or Depscan)
IaC security analysis (use KICS)
Technology profiling (use Application Inspector)
Finding secrets in binary files or compiled code
Installation
brew install gitleaks
wget https://github.com/gitleaks/gitleaks/releases/latest/download/gitleaks-linux-amd64
chmod +x gitleaks-linux-amd64
gitleaks-linux-amd64 /usr/local/bin/gitleaks
docker pull ghcr.io/gitleaks/gitleaks:latest
go install github.com/gitleaks/gitleaks/v8@latest
gitleaks version
sudo
mv
Core Workflow
1. Quick Scan
gitleaks detect
gitleaks detect --source /path/to/repo
gitleaks protect
gitleaks detect --no-banner --no-color
2. SARIF Output
gitleaks detect \
--report-format sarif \
--report-path results.sarif
gitleaks detect \
--source /path/to/repo \
--report-format sarif \
--report-path results.sarif \
--no-banner \
--no-color \
--exit-code 0
gitleaks detect \
--report-format sarif \
--report-path results.sarif \
--redact
3. Scan Git History
gitleaks detect --source /path/to/repo --verbose
gitleaks detect --log-opts="--since='2024-01-01'"
gitleaks detect --source /path/to/repo --log-opts="origin/main"
4. Additional Formats
gitleaks detect --report-format json --report-path results.json
gitleaks detect --report-format csv --report-path results.csv
gitleaks detect --report-format junit --report-path results.xml
Configuration
Custom Config File title = "Gitleaks Configuration"
[extend]
useDefault = true
[[rules]]
id = "custom-api-key"
description = "Custom API Key Pattern"
regex = '''(?i)api[_-]?key['\"]?\s*[:=]\s*['\"]([a-z0-9]{32,})'''
keywords = ["apikey" , "api_key" ]
[[rules]]
id = "slack-webhook"
description = "Slack Webhook URL"
regex = '''https://hooks\.slack\.com/services/T[a-zA-Z0-9_]{8,}/B[a-zA-Z0-9_]{8,}/[a-zA-Z0-9_]{24,}'''
[[rules]]
id = "aws-access-key"
description = "AWS Access Key"
regex = '''AKIA[0-9A-Z]{16}'''
keywords = ["AKIA" ]
[allowlist]
description = "Allowlist for false positives"
regexes = [
'''EXAMPLE_API_KEY''' ,
'''placeholder-secret''' ,
'''test-token-123'''
]
paths = [
'''.gitleaks.toml''' ,
'''README.md''' ,
'''docs/'''
]
Use Custom Config gitleaks detect --config .gitleaks.toml
gitleaks detect \
--config .gitleaks.toml \
--report-format sarif \
--report-path results.sarif
Ignoring False Positives
Inline Comments
api_key = "this-is-a-test-key-not-real"
password = "example-password"
.gitleaksignore File # Ignore specific findings by fingerprint
fingerprint:abc123def456
# Ignore files
tests/fixtures/secrets.txt
docs/examples/*.py
# Ignore commits
commit:a1b2c3d4e5f6
Baseline Mode
gitleaks detect --report-path baseline.json --report-format json
gitleaks detect --baseline-path baseline.json
CI/CD Integration (GitHub Actions) name: Gitleaks
on:
push:
branches: [main ]
pull_request:
schedule:
- cron: '0 0 * * 0'
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
- name: Generate SARIF
if: always()
run: |
gitleaks detect \
--report-format sarif \
--report-path gitleaks.sarif \
--no-banner \
--no-color \
--exit-code 0
- name: Upload SARIF
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: gitleaks.sarif
category: gitleaks
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: gitleaks-results
path: gitleaks.sarif
Pre-commit Hook
Install Pre-commit
pip install pre-commit
cat > .pre-commit-config.yaml << 'EOF'
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id : gitleaks
EOF
pre-commit install
pre-commit run --all-files
Manual Git Hook
cat > .git/hooks/pre-commit << 'EOF'
gitleaks protect --staged --verbose --redact
EOF
chmod +x .git/hooks/pre-commit
Common Use Cases
1. Initial Repository Audit
gitleaks detect \
--source /path/to/repo \
--report-format sarif \
--report-path full-audit.sarif \
--verbose
sarif summary full-audit.sarif
2. Pre-deployment Scan
gitleaks protect --staged --verbose
gitleaks protect --staged --exit-code 1
3. CI/CD Pipeline Integration
gitleaks dir \
--source /workspace/src \
--report-format sarif \
--report-path /workspace/output/sarif/gitleaks.sarif \
--no-banner \
--no-color \
--ignore-gitleaks-allow \
--exit-code 0
4. Remediation Workflow
gitleaks detect --report-format json --report-path findings.json
gitleaks detect --report-path baseline.json --report-format json
gitleaks detect --baseline-path baseline.json --verbose
gitleaks detect --exit-code 1
Understanding Output
SARIF Structure Gitleaks SARIF v2.1.0 includes:
Rules : Each secret type (API key, password, token, etc.)
Results : Specific locations where secrets were found
Properties :
commit: Git commit hash (if applicable)
file: File path
startLine: Line number
endLine: Line number
match: Redacted or full secret (depending on --redact)
secret: The detected secret (if not redacted)
JSON Output Example {
"Description" : "AWS Access Key" ,
"StartLine" : 42 ,
"EndLine" : 42 ,
"StartColumn" : 15 ,
"EndColumn" : 50 ,
"Match" : "AKIA****************" ,
"Secret" : "AKIA1234567890ABCDEF" ,
"File" : "config/aws.py" ,
"SymlinkFile" : "" ,
"Commit" : "a1b2c3d4e5f6g7h8" ,
"Entropy" : 4.5 ,
"Author" : "developer@example.com" ,
"Email" : "developer@example.com" ,
"Date" : "2024-01-15T10:30:00Z" ,
"Message" : "Add AWS configuration" ,
"Tags" : [ ] ,
"RuleID" : "aws-access-token" ,
"Fingerprint" : "a1b2c3d4e5f6g7h8:config/aws.py:aws-access-token:42"
}
Advanced Features
Entropy Detection
gitleaks detect --verbose --log-level debug
Custom Rules Only
gitleaks detect --config custom-rules.toml --no-default-config
Scanning Specific Files
gitleaks detect --source /code --log-opts="--all -- '*.py'"
gitleaks detect --source /code --log-opts="--all -- . ':!vendor'"
Performance Considerations
gitleaks detect --log-opts="--max-count=1000"
gitleaks detect --log-opts="--since='1 month ago'"
gitleaks detect --source /large/repo
Limitations
Binary files : Limited detection in compiled/binary files
Obfuscation : Misses heavily obfuscated or encoded secrets
Context-aware : Can't determine if secret is actually valid/active
False positives : Regex-based, may flag test data or examples
Git required : Directory scans work, but git history scanning needs .git
Rationalizations to Reject Shortcut Why It's Wrong "Gitleaks found nothing = no secrets" Obfuscated, encrypted, or dynamically constructed secrets are missed "Only scan code, skip git history" Secrets in history can still be exploited; attackers check git logs "Disable in CI for speed" Secret leaks are critical; speed should never compromise security "Mark all as false positive" Each finding needs review; some may be valid credentials "Don't use --redact in reports" Unredacted secrets in reports can leak to logs, artifacts, or dashboards
References