跳到正文
Skillpedia
部署与云(DevOps)35k · #8115

implementing-secrets-scanning-in-ci-cd

它能做什么

这个工具可以帮助找出被意外写入项目代码中的敏感信息(比如密码或 API 密钥)。它会在代码发布到生产环境之前进行检查,防止安全泄露。

适用场景

  • ✓在设置项目安全时。
  • ✓在发布新版本软件之前。
  • ✓需要确认敏感信息没有泄露时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-secrets-scanning-in-ci-cd/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-secrets-scanning-in-ci-cd/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“在发布之前,扫描我的代码,看看是否有泄露的敏感信息。”

每周 5 个新技能,1 分钟读完。

工作原理

该工具借助其他程序(Gitleaks 和 TruffleHog)在代码中查找敏感信息的特征模式。如果发现可疑内容,它会提醒你,甚至可以阻止代码被发布。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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

  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
{
  "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": [...]
}
常见问题

什么是敏感信息?

敏感信息指密码、API 密钥、访问令牌以及其他不应在代码中公开的凭据。

什么是 CI/CD?

CI/CD 是一种自动化软件构建、测试和交付的流程。这个工具融入该流程,为其增加一层安全防护。

如果工具发现了敏感信息会怎样?

它可以阻止代码被发布,并生成详细报告,列出发现的内容,方便你修复问题。

详情

作者的原始描述

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

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#8115
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能