implementing-secrets-scanning-in-ci-cd skill (Anthropic-Cybersecurity-Skills)
- Install
- SKILL.md (verbatim)
- Overview
- When to Use
- Prerequisites
- Steps
- Expected Output
- Other files in this skill
- references/api-reference.md (verbatim)
- Gitleaks CLI
- Subcommands
- Key Flags
- Pre-commit Hook
- Protect Staged Files
- TruffleHog CLI
- Subcommands
- Key Flags
- GitHub Secret Scanning API
- List Alerts
- Update Alert State
- GitHub Actions Integration
What it does. Integrate gitleaks and trufflehog into CI/CD pipelines to detect leaked Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).
| Upstream | mukul975/Anthropic-Cybersecurity-Skills |
| Skill file | skills/implementing-secrets-scanning-in-ci-cd/SKILL.md |
| License | Apache-2.0 (skill folder LICENSE) |
| Author | mukul975 |
| Fetched | 2026-09-10 |
Install
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill implementing-secrets-scanning-in-ci-cd, or copy the skill folder into~/.claude/skills/implementing-secrets-scanning-in-ci-cd/.- Raw file:
curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/implementing-secrets-scanning-in-ci-cd/SKILL.md
SKILL.md (verbatim)
name: implementing-secrets-scanning-in-ci-cd
description: Integrate gitleaks and trufflehog into CI/CD pipelines to detect leaked
secrets before deployment
domain: cybersecurity
subdomain: devsecops
tags:
- secrets-scanning
- gitleaks
- trufflehog
- ci-cd
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.PS-01
- GV.SC-07
- ID.IM-04
- PR.PS-04
mitre_attack:
- T1195
- T1554
- T1059.004
Implementing Secrets Scanning in CI/CD
Overview
This skill covers implementing automated secrets scanning in CI/CD pipelines using gitleaks and trufflehog. It enables security teams to detect API keys, tokens, passwords, and other credentials that have been accidentally committed to source code repositories, providing a CI gate that blocks deployments containing high-severity findings.
Gitleaks scans git repositories and directories for hardcoded secrets using regex patterns and entropy analysis. TruffleHog performs filesystem and git history scans with optional secret verification against live services. Together they provide comprehensive coverage for secrets detection.
When to Use
- When deploying or configuring implementing secrets scanning in ci cd capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
- Python 3.9 or later
- gitleaks v8.x installed and available on PATH
- trufflehog v3.x installed and available on PATH
- A git repository or directory to scan
- Access to CI/CD platform (GitHub Actions, GitLab CI, Jenkins)
Steps
Install scanning tools: Install gitleaks via package manager or binary download. Install trufflehog via
brew install trufflehogor download from GitHub releases.Configure gitleaks: Create a
.gitleaks.tomlconfiguration file in the repository root to define custom rules, allowlists, and path exclusions. Use--configflag to point to custom configs.Run gitleaks directory scan: Execute
gitleaks dir --source . --report-format json --report-path gitleaks-report.jsonto scan the working directory and generate a JSON report.Run trufflehog filesystem scan: Execute
trufflehog filesystem /path/to/repo --json > trufflehog-report.jsonto scan files and output JSON findings to a report file.Parse and filter findings: Use the agent script to parse both JSON reports, filter findings by severity (critical, high, medium, low), and determine whether the CI pipeline should pass or fail.
Integrate into CI pipeline: Add the scanning step to your GitHub Actions workflow, GitLab CI config, or Jenkins pipeline as a pre-deployment gate. Use
--exit-codeflag in gitleaks to control pipeline behavior.Configure pre-commit hooks: Set up gitleaks as a pre-commit hook using
gitleaks protect --stagedto catch secrets before they are committed.Review and triage findings: Examine the JSON output for false positives, add legitimate entries to
.gitleaksignore, and rotate any confirmed leaked credentials immediately.
Expected Output
The agent script produces a JSON report containing:
- Total findings count from each scanner
- Findings grouped by severity level
- Individual finding details including file path, line number, rule ID, and redacted secret
- A CI gate verdict (pass/fail) based on the configured severity threshold
- Execution metadata including scan duration and tool versions
{
"scan_summary": {
"tool": "both",
"total_findings": 3,
"critical": 1,
"high": 1,
"medium": 1,
"low": 0,
"ci_gate": "FAIL",
"fail_reason": "Found 1 critical and 1 high severity findings"
},
"findings": [...]
}
Other files in this skill
references/api-reference.md (verbatim)
Secrets Scanning API Reference
Gitleaks CLI
Subcommands
gitleaks git # Scan git repositories
gitleaks dir # Scan directories or files
gitleaks stdin # Detect secrets from stdin
Key Flags
| Flag | Description |
|---|---|
--source, -s |
Path to source directory or repository |
--config, -c |
Path to .gitleaks.toml config file |
--report-format, -f |
Output format: json, csv, junit, sarif, template |
--report-path, -r |
File path to write report |
--exit-code |
Exit code when leaks found (default: 1) |
--redact |
Redact secrets from output (0-100%, default: 100) |
--baseline-path, -b |
Path to baseline report to ignore known findings |
--no-banner |
Suppress banner output |
--verbose, -v |
Show verbose scan details |
--log-level, -l |
Log level: trace, debug, info, warn, error, fatal |
--max-target-megabytes |
Skip files larger than specified MB |
--enable-rule |
Only enable specific rule IDs |
--gitleaks-ignore-path, -i |
Path to .gitleaksignore file |
Pre-commit Hook
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
Protect Staged Files
gitleaks protect --staged --report-format json --report-path staged-report.json
TruffleHog CLI
Subcommands
trufflehog git <repo-url> # Scan git repository
trufflehog filesystem <path> # Scan local filesystem
trufflehog github --org=<org> # Scan GitHub org
trufflehog gitlab --token=<token> # Scan GitLab instance
trufflehog s3 --bucket=<name> # Scan S3 bucket
trufflehog docker --image=<img> # Scan Docker image
Key Flags
| Flag | Description |
|---|---|
--json, -j |
Output in JSON format (one object per line) |
--no-verification |
Skip live secret verification |
--concurrency |
Number of concurrent workers (default: 20) |
--results |
Filter: verified, unknown, unverified, filtered_unverified |
--force-skip-binaries |
Skip binary files during scan |
--force-skip-archives |
Skip archive files during scan |
--include-paths |
Path to file with include path patterns |
--exclude-paths |
Path to file with exclude path patterns |
--log-level |
Verbosity: 0 (info) to 5 (trace) |
GitHub Secret Scanning API
List Alerts
curl -H "Authorization: Bearer $TOKEN" \
https://api.github.com/repos/{owner}/{repo}/secret-scanning/alerts
Update Alert State
curl -X PATCH \
-H "Authorization: Bearer $TOKEN" \
https://api.github.com/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number} \
-d '{"state": "resolved", "resolution": "revoked"}'
GitHub Actions Integration
- name: Gitleaks Scan
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: TruffleHog Scan
uses: trufflesecurity/trufflehog@main
with:
extra_args: --results verified,unknown
Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.