Loading...
Loading...
Secret detection and credential scanning using gitleaks. Use when scanning repositories for leaked secrets, API keys, passwords, tokens, or implementing pre-commit security checks.
npx skill4agent add vinnie357/claude-skills securitygit commitgit commit -m "message"
↓
PreToolUse hook fires
↓
Extract staged files
↓
Run gitleaks --no-git
↓
┌─ Clean ─┴─ Secrets ─┐
↓ ↓
Allow Block commit
commit (exit code 2).gitleaks-baseline.json.gitleaks.toml[gitleaks] SECRETS DETECTED in staged files!
[gitleaks] Commit blocked. Remove secrets before committing.
[gitleaks]
[gitleaks] Options:
[gitleaks] 1. Remove the secret from the file
[gitleaks] 2. Use environment variables instead
[gitleaks] 3. Add to .gitleaks-baseline.json if false positivesecurity-review| Task | Use | Use |
|---|---|---|
| Scan for secrets in code | ✓ | |
| Detect leaked API keys | ✓ | |
| Pre-commit secret scanning | ✓ | |
| STRIDE threat modeling | ✓ | |
| Security architecture review | ✓ | |
| Vulnerability assessment | ✓ | |
| Security report documentation | ✓ | |
| Risk prioritization | ✓ |
# Scan current directory
gitleaks detect --source="." -v
# Scan with JSON report
gitleaks detect --source="." -v --report-path=report.json --report-format=json
# Scan only staged changes (pre-commit)
gitleaks protect --staged
# Scan git history
gitleaks detect --source="." --log-opts="--all".gitleaks.toml[extend]
# Extend default rules
useDefault = true
[[rules]]
id = "custom-api-key"
description = "Custom API Key Pattern"
regex = '''(?i)custom[_-]?api[_-]?key['\"]?\s*[=:]\s*['\"]([a-zA-Z0-9]{32,})'''
keywords = ["custom_api_key", "custom-api-key"]
[allowlist]
paths = [
'''\.gitleaks\.toml$''',
'''(.*)?test(.*)''',
'''\.git'''
]
regexes = [
'''EXAMPLE_.*''',
'''REDACTED'''
]01# Run with auto-detected runtime
nu scripts/gitleaks.nu
# Specify runtime
nu scripts/gitleaks.nu --runtime docker
nu scripts/gitleaks.nu --runtime container # Apple Container (macOS 26+)
nu scripts/gitleaks.nu --runtime colima
# Generate report
nu scripts/gitleaks.nu --report ./report.json
# Use custom config
nu scripts/gitleaks.nu --config ./.gitleaks.toml
# Scan specific path
nu scripts/gitleaks.nu --path ./src# Run with auto-detected runtime
./scripts/gitleaks.sh
# Specify runtime
./scripts/gitleaks.sh --runtime docker
./scripts/gitleaks.sh -R container
# Generate report
./scripts/gitleaks.sh --report ./report.json
# Use custom config
./scripts/gitleaks.sh --config ./.gitleaks.toml# Check status
container system status
# Start runtime
container system start
# Run gitleaks
container run -v $(pwd):/code zricethezav/gitleaks detect --source="/code" -v# Check status
docker info >/dev/null 2>&1
# Start (macOS)
open -a Docker
# Run gitleaks
docker run -v $(pwd):/code zricethezav/gitleaks detect --source="/code" -v# Check status
mise exec colima@latest -- colima status
# Start runtime
mise exec colima@latest -- colima start
# Run gitleaks
mise exec colima@latest -- docker run -v $(pwd):/code zricethezav/gitleaks detect --source="/code" -vmise exec# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleakspre-commit install
pre-commit run gitleaks --all-filesname: Gitleaks
on: [push, pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}gitleaks:
stage: security
image: zricethezav/gitleaks:latest
script:
- gitleaks detect --source="." -v
allow_failure: false# Generate baseline
gitleaks detect --source="." -v --baseline-path=.gitleaks-baseline.json
# Scan using baseline
gitleaks detect --source="." -v --baseline-path=.gitleaks-baseline.json.gitleaks-baseline.jsongit filter-branch.gitignore.env.exampletemplates/mise.toml# Available tasks after copying template
mise gitleaks # Scan with Apple Container (default)
mise gitleaks:docker # Scan with Docker
mise gitleaks:colima # Scan with Colima
mise gitleaks:stop # Stop all runtimes
mise gitleaks:stop:container
mise gitleaks:stop:docker
mise gitleaks:stop:colima.gitleaks-baseline.json