← 返回
开发者工具 中文

Secret Detection

Git hook to detect secrets before commit.
在提交前检测密钥的Git钩子。
derick001
开发者工具 clawhub v1.0.0 1 版本 99859.9 Key: 无需
★ 0
Stars
📥 713
下载
💾 7
安装
1
版本
#latest

概述

Secret Detection

What This Does

This skill provides a git pre‑commit hook that scans staged files for common secret patterns (API keys, passwords, tokens) and blocks the commit if any are found. It helps prevent accidental leakage of secrets to public repositories.

Inputs: Git staged files (automatically scanned by the hook) or manual file paths.

Outputs: Detection report with line numbers; non‑zero exit code if secrets found.

When To Use

Use this skill when:

  • You work with repositories that may contain sensitive credentials
  • You want to prevent accidental commits of secrets
  • You need a lightweight, local secret scanner for git workflows
  • You want to enforce security checks before pushing to remote

Usage

Installation

# Install the hook in your git repository
./scripts/main.py install

Manual Scan

# Scan specific files
./scripts/main.py scan --file path/to/file

# Scan all staged files (like the hook does)
./scripts/main.py scan --staged

Hook Behavior

  • The hook runs automatically on git commit
  • If secrets are detected, the commit is blocked
  • The script prints the detected secrets with file names and line numbers
  • Exit code 0 = no secrets found; exit code 1 = secrets found

Examples

Example 1: Installing the Hook

$ ./scripts/main.py install
✓ Pre-commit hook installed at .git/hooks/pre-commit
✓ Hook will scan for secrets on every commit

Example 2: Secret Detection Blocking a Commit

$ git commit -m "Add config"
⚠️  Secret detected in config.yaml line 12: AWS_ACCESS_KEY_ID=AKIA...
⚠️  Secret detected in .env line 3: PASSWORD=secret123
✗ Commit blocked: 2 secrets found

Example 3: Manual Scan

$ ./scripts/main.py scan --staged
Scanning 3 staged files...
✓ config.yaml: clean
✓ .env: clean  
✓ src/main.py: clean
✓ No secrets found

Requirements

  • Git (for hook installation)
  • Python 3.6+ (for the scanner)
  • No external API keys or services needed

Limitations

  • Only detects common secret patterns (AWS keys, GitHub tokens, passwords, etc.)
  • May produce false positives (e.g., long random strings that aren't actually secrets)
  • Does not scan binary files
  • Requires manual installation per repository
  • Does not replace comprehensive secret‑management solutions
  • Prints first 20 characters of detected secrets to console for identification purposes

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 23:53 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,521
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,586
security-compliance

HTTP Request Builder

derick001
从命令行界面构建、测试和保存HTTP请求,支持自定义请求头、认证、请求体、Cookie、模板、交互模式及请求历史记录。
★ 0 📥 865