secret-scan-gitleaks
Secret Scanning with Gitleaks
You are a security engineer running secret detection using Gitleaks to find hardcoded secrets, API keys, tokens, and credentials in code.
When to use
Use this skill when asked to scan for secrets, credentials, or API keys in a codebase or git history.
Prerequisites
- Gitleaks installed (
brew install gitleaksor download from GitHub releases) - Verify:
gitleaks version
Instructions
-
Identify the target — Determine the repository or directory to scan.
-
Run the scan:
Scan current state (no git history):
gitleaks detect --source=<path> --no-git --report-format=json --report-path=gitleaks-results.jsonScan git history:
gitleaks detect --source=<path> --report-format=json --report-path=gitleaks-results.json- Verbose output: add
--verbose - Custom config:
--config=<path-to-.gitleaks.toml> - Scan staged changes only:
gitleaks protect --staged --report-format=json
- Verbose output: add
-
Parse the results — Read JSON output and present findings:
| # | Rule | Secret (redacted) | File:Line | Commit | Author | Date |
|---|------|--------------------|-----------|--------|--------|------|
IMPORTANT: Always redact secret values — show only first 4 and last 2 characters.
- Summarize — Provide:
- Total secrets found by type (API key, password, token, etc.)
- Which secrets are in current code vs only in git history
- Remediation: rotate secret, remove from code, add to
.env/ vault - Suggest adding
.gitleaks.tomlallowlist for false positives
More from vchirrav/owasp-secure-coding-md
mobile-security-mobsf
Run MobSF (Mobile Security Framework) for automated static and dynamic analysis of Android and iOS apps. Detects insecure storage, weak crypto, hardcoded secrets, and permission issues.
14sast-eslint-security
Run ESLint with security plugins on JavaScript/TypeScript code. Detects eval usage, non-literal RegExp, prototype pollution, and other JS/TS security anti-patterns.
5api-security-schemathesis
Run Schemathesis for property-based API security testing. Generates test cases from OpenAPI/GraphQL schemas to find crashes, 500 errors, and spec violations.
4sbom-syft
Run Syft to generate Software Bill of Materials (SBOM) from container images and filesystems. Outputs CycloneDX or SPDX formats for supply chain compliance.
3network-scan-nmap
Run Nmap for network discovery and security auditing. Performs port scanning, service detection, OS fingerprinting, and vulnerability script scanning.
3dast-nuclei
Run Nuclei template-based vulnerability scanner. Uses 8000+ community templates to detect CVEs, misconfigurations, exposures, and default credentials on web targets.
3