Agent skill

implementing-secrets-scanning-in-ci-cd

Integrate gitleaks and trufflehog into CI/CD pipelines to detect leaked secrets before deployment

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/autohandai/community-skills/tree/main/implementing-secrets-scanning-in-ci-cd

SKILL.md

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.

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

  1. Install scanning tools: Install gitleaks via package manager or binary download. Install trufflehog via brew install trufflehog or download from GitHub releases.

  2. Configure gitleaks: Create a .gitleaks.toml configuration file in the repository root to define custom rules, allowlists, and path exclusions. Use --config flag to point to custom configs.

  3. Run gitleaks directory scan: Execute gitleaks dir --source . --report-format json --report-path gitleaks-report.json to scan the working directory and generate a JSON report.

  4. Run trufflehog filesystem scan: Execute trufflehog filesystem /path/to/repo --json > trufflehog-report.json to scan files and output JSON findings to a report file.

  5. 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.

  6. 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-code flag in gitleaks to control pipeline behavior.

  7. Configure pre-commit hooks: Set up gitleaks as a pre-commit hook using gitleaks protect --staged to catch secrets before they are committed.

  8. 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
json
{
  "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": [...]
}

Expand your agent's capabilities with these related and highly-rated skills.

autohandai/community-skills

mapping-mitre-attack-techniques

Maps observed adversary behaviors, security alerts, and detection rules to MITRE ATT&CK techniques and sub-techniques to quantify detection coverage and guide control prioritization. Use when building an ATT&CK-based coverage heatmap, tagging SIEM alerts with technique IDs, aligning security controls to adversary playbooks, or reporting threat exposure to executives. Activates for requests involving ATT&CK Navigator, Sigma rules, MITRE D3FEND, or coverage gap analysis.

0 0
Explore
autohandai/community-skills

hunting-for-spearphishing-indicators

Hunt for spearphishing campaign indicators across email logs, endpoint telemetry, and network data to detect targeted email attacks.

0 0
Explore
autohandai/community-skills

analyzing-malicious-url-with-urlscan

URLScan.io is a free service for scanning and analyzing suspicious URLs. It captures screenshots, DOM content, HTTP transactions, JavaScript behavior, and network connections of web pages in an isolat

0 0
Explore
autohandai/community-skills

implementing-zero-standing-privilege-with-cyberark

Deploy CyberArk Secure Cloud Access to eliminate standing privileges in hybrid and multi-cloud environments using just-in-time access with time, entitlement, and approval controls.

0 0
Explore
autohandai/community-skills

implementing-pam-for-database-access

Deploy privileged access management for database systems including Oracle, SQL Server, PostgreSQL, and MySQL. Covers session proxy configuration, credential vaulting, query auditing, dynamic credentia

0 0
Explore
autohandai/community-skills

detecting-t1003-credential-dumping-with-edr

Detect OS credential dumping techniques targeting LSASS memory, SAM database, NTDS.dit, and cached credentials using EDR telemetry, Sysmon process access monitoring, and Windows security event correlation.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results