--- title: "TruffleHog" type: entity tags: [security, secrets-detection, git, open-source] sources: [self-healing-home-server] last_updated: 2026-04-22 --- ## Aliases - TruffleHog - trufflehog - Truffle Hog ## Definition TruffleHog 是一个开源的 Git secrets scanning 工具,通过正则表达式和 entropy 分析检测 Git 仓库中的硬编码凭证(API keys、tokens、passwords、private keys 等)。支持 GitHub、GitLab、Gitea 等所有 Git 服务,是 DevSecOps 和 AI Agent 安全运营的必备工具。 ## Core Features - **High-entropy 检测**:识别随机字符串形式的 API keys - **正则匹配**:识别常见凭证格式(AWS keys、Slack tokens、JWTs 等) - **Git 历史扫描**:扫描整个 Git 历史中的 secrets(og commit 检测) - **CI/CD 集成**:支持 GitHub Actions、GitLab CI、Gitea Actions 等 ## In Home Lab Context 在 [[self-healing-home-server]] 的安全 checklist 中,TruffleHog 是**第一道防线**: - **Pre-push hooks**:在 Agent commit 之前阻断包含 secrets 的代码 - 配合 [[Gitea]] CI pipeline 使用 - 与 [[1Password]] 专用 AI vault 共同构成纵深防御 ## Critical Insight > "AI assistants will happily hardcode secrets. They sometimes don't have the same instincts humans do." — Nathan([[OpenClaw]] 用户) AI Agent 在生成代码时倾向于直接写入 API keys,这是 AI Agent 基础设施安全的 #1 风险。TruffleHog pre-push hooks 是**必须配置**的防线。 ## Connections - [[Defense-in-Depth]] — TruffleHog 作为多层安全防御的第一环 - [[Local-first Git]] — 与 Gitea 配合实现安全 Git 工作流 - [[1Password]] — Agent secrets 的安全存储方案 - [[OpenClaw]] — 需要 TruffleHog 保护的 Agent 平台