Git 安全扫描器 - 检查提交中的敏感信息泄露(API keys、密码、token)
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install git-secrets-scanner或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install git-secrets-scanner⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/git-secrets-scanner/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: git-secrets-scanner description: Git 安全扫描器 - 检查提交中的敏感信息泄露(API keys、密码、token) metadata: openclaw: emoji: "🔒" category: "security" tags: ["security", "git", "secrets", "scanner", "gitleaks", "trufflehog"] requires: bins: ["git"] ---
检查提交中的敏感信息泄露。
| 工具 | Stars | 特点 | |------|-------|------| | Gitleaks | 24,958 | 最流行,Go 编写,快速 | | TruffleHog | 24,612 | 验证 secrets,支持多种格式 | | git-secrets | 13,173 | AWS 官方,pre-commit hook |
# macOS
brew install gitleaks
# Linux
# 从 https://github.com/gitleaks/gitleaks/releases 下载
# 或使用 Go
go install github.com/gitleaks/gitleaks/v8@latest
# macOS
brew install trufflehog
# Linux
# 从 https://github.com/trufflesecurity/trufflehog/releases 下载
# 或使用 Docker
docker pull trufflesecurity/trufflehog:latest
# macOS
brew install git-secrets
# Linux
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets
sudo make install
# Gitleaks
gitleaks detect --source . -v
# TruffleHog
trufflehog git file://. --only-verified
# git-secrets(需要先设置 hook)
git secrets --scan-history
# Gitleaks
gitleaks detect --source . --log-opts="HEAD~1..HEAD"
# TruffleHog
trufflehog git file://. --commit=HEAD
# Gitleaks
gitleaks detect --source . --log-opts="--all"
# TruffleHog
trufflehog git file://. --no-deletion
# git-secrets
cd your-repo
git secrets --install
git secrets --register-aws
# .github/workflows/security.yml
name: Security Scan
on: [push, pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Finding: moltbook_sk_jX64MWE_yirqMSihBqb2B7slL64EygBt
Secret: moltbook_sk_jX64MWE_yirqMSihBqb2B7slL64EygBt
RuleID: generic-api-key
Entropy: 4.562345
File: memory/moltbook-art-of-focus-post.md
Line: 45
Commit: abc1234
Author: [email protected]
Date: 2026-02-19T03:11:00Z
Fingerprint: abc123...
# 添加到 .git/hooks/pre-commit
#!/bin/bash
gitleaks protect --staged
# 每周扫描
crontab -e
0 0 * * 0 cd /path/to/repo && gitleaks detect --source .
#!/bin/bash
for repo in ~/projects/*; do
echo "Scanning $repo..."
gitleaks detect --source "$repo" -v
done
如果发现泄露:
git push --force(谨慎使用)# 安装 BFG
brew install bfg
# 清理敏感文件
bfg --delete-files .env
# 清理敏感字符串
bfg --replace-text passwords.txt
# 强制推送
git push --force
title = "Custom Gitleaks Config"
[extend]
useDefault = true
[[rules]]
id = "moltbook-api-key"
description = "Moltbook API Key"
regex = '''moltbook_sk_[a-zA-Z0-9]{32}'''
tags = ["api-key", "moltbook"]
[allowlist]
paths = [
'''example\.txt''',
'''test/.*'''
]
---
版本: 1.0.0 工具: Gitleaks, TruffleHog, git-secrets
安装 Git Secrets Scanner 后,可以对 AI 说这些话来触发它
Help me get started with Git Secrets Scanner
Explains what Git Secrets Scanner does, walks through the setup, and runs a quick demo based on your current project
Use Git Secrets Scanner to git Security Scanner - Check commits for sensitive information leak...
Invokes Git Secrets Scanner with the right parameters and returns the result directly in the conversation
What can I do with Git Secrets Scanner in my developer & devops workflow?
Lists the top use cases for Git Secrets Scanner, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/git-secrets-scanner/ 目录(个人级,所有项目可用),或 .claude/skills/git-secrets-scanner/(项目级)。重启 AI 客户端后,用 /git-secrets-scanner 主动调用,或让 AI 根据上下文自动发现并使用。
Git Secrets Scanner 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Git Secrets Scanner 可免费安装使用。请查阅仓库了解许可证信息。
Git 安全扫描器 - 检查提交中的敏感信息泄露(API keys、密码、token)
Git Secrets Scanner 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Git Secrets Scanner
Identifies repetitive steps in your workflow and sets up Git Secrets Scanner to handle them automatically