gitleaks-scan
Run gitleaks against the working tree to detect committed secrets, API keys, tokens, and credentials. Use whenever a file has been written, before any git commit, before any push, and as part of the tiered security gate. Catches the most common cause of credential leaks - accidental commits.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- gitleaks-scan
- description
- Run gitleaks against the working tree to detect committed secrets, API keys, tokens, and credentials. Use whenever a file has been written, before any git commit, before any push, and as part of the tiered security gate. Catches the most common cause of credential leaks - accidental commits.
02 资源文件 1
- 其他SKILL.md.bundle9.3 KB
03 SKILL.md 正文
Gitleaks Scan
Catches secrets before they hit the remote, wherever it is wired in: a CI step, the pre-commit hook
init-project.shinstalls, or the post-tool hook script once a harness registers it (nothing registers it by default).
Tradeoff: ~2-5s scan time on file change. Worth it: a leaked secret is a P0 incident and takes hours to rotate + audit.
When to invoke
- After writing a file that may hold a credential: run
gitleaks detect --no-git --source <file> --no-banneryourself.hooks/universal/post-tool/gitleaks-scan.shruns that command, but only once the harness registers it as a post-tool hook with a wrapper that passes the written file's path as its first argument (for Claude Code, in.claude/settings.json);analyzer/install.tscopies hooks without registering them. - Pre-commit: in
.git/hooks/pre-commit(installed byinit-project.sh) - Pre-push: in
.git/hooks/pre-push - CI: on every PR
Install
brew install gitleaks
# or
go install github.com/gitleaks/gitleaks/v8@latest
The post-tool hook gitleaks-scan.sh emits a "missing" warning once per
session and skips gracefully if gitleaks isn't installed.
Configure
Project-level: .gitleaks.toml. Inherit defaults and add custom rules:
[extend]
useDefault = true
[[rules]]
id = "internal-client-id"
description = "Internal client ID format"
regex = '''CL-[A-Z0-9]{16}'''
tags = ["client-id", "PII"]
Allowlist false positives:
[allowlist]
description = "Test fixtures"
paths = [
'''fixtures/test-keys/.*''',
]
Tiered usage
See docs/SECURITY.md for the full tiered pentest stack. Gitleaks fits at:
- Tier 1 (every file write): post-tool hook, once the harness registers it; until then secrets are caught at commit (pre-commit hook, where installed) or at PR (the CI step)
- Tier 2 (every PR): CI step blocking merge on findings
- Tier 3 (pre-release): full history scan with
gitleaks detect
On finding
The post-tool hook, once registered, exits 2; the pre-commit hook, where installed, blocks the commit; the CI step blocks the PR. The user must:
- Remove the secret from the file
- Rotate it if it was real
- Add to a vault (Doppler, 1Password, Vault, Infisical)
- Reference via env var
If a secret has ALREADY been committed (caught by Tier 2/3):
- Rotate immediately
- Use
git filter-repoor BFG to scrub history - Force-push with team coordination
- Open a postmortem in
docs/postmortems/
This skill is working when: zero secrets reach the remote. The intended
record is governance/telemetry/secret-findings.jsonl. Nothing writes it yet, so check by hand.
04 同仓库更多 Skills
karpathy-guidelines
Behavioral guidelines that reduce common LLM coding mistakes. Apply whenever writing, modifying, or reviewing code. Don't assume requirements, don't overcomplicate, don't refactor unrelated code, and define success criteria before implementing. Use this skill on every non-trivial coding task to avoid bloat, silent assumptions, and completion-bias.
unsigned-missing-sig-fixture
Test fixture (F.09) — SKILL.md without an accompanying .sig file. Default install rejects with exit 2; --allow-unsigned --rationale="..." proceeds.
unsigned-mismatched-sig-fixture
Test fixture (F.09) — SKILL.md whose accompanying .sig signs different content. NFR-F3 hash check catches this even with --allow-unsigned.
karpathy-guidelines
Behavioral guidelines that reduce common LLM coding mistakes. Apply whenever writing, modifying, or reviewing code. Don't assume requirements, don't overcomplicate, don't refactor unrelated code, and define success criteria before implementing. Use this skill on every non-trivial coding task to avoid bloat, silent assumptions, and completion-bias.
webhook-idempotency
Defend against double-processing of webhook events across every provider (Stripe, GitHub, Slack, Twilio, SendGrid). Idempotency-key pattern + replay-window enforcement + dedupe-storage strategy. Triggers on any webhook handler authoring (route matching /webhook(s)?/, Stripe-Signature / X-Hub-Signature-256 header references). Defense against OWASP ASI02 (Tool Misuse) -- a replayed webhook that re-triggers a destructive tool is the canonical control-flow-level replay attack. Universal across providers; stack-specific signature verification lives in stack-specific skills.
semgrep-scan
Run Semgrep static analysis to detect insecure code patterns - SQL injection, XSS, path traversal, weak crypto, broken auth, OWASP Top 10 issues. Use on every file change touching security-sensitive code and as part of the tiered security gate. Complements gitleaks (which catches secrets) by catching insecure logic.