Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

code-hardcode-audit代码 hardcode 审核

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

2,424

周安装

102

GitHub Stars

37

下载量

849
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:code-hardcode-audit(代码 hardcode 审核)
来源仓库:https://github.com/terrylica/cc-skills
仓库路径:skills/code-hardcode-audit
安装命令:
npx skills add https://github.com/terrylica/cc-skills --skill code-hardcode-audit
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/terrylica/cc-skills --skill code-hardcode-audit

简介

code-hardcode-audit 自动检测硬编码值、魔法数字与重复常量,识别潜在的安全与可维护性问题。

  • 适用于代码审计、秘密扫描与 DRY 原则合规检查,支持多种工具如 semgrep、gitleaks、ast-grep。
  • 输出为详细报告而非直接修改文件,提供替换建议与 SSoT(单一事实来源)违规说明。
  • 涉及密钥或令牌时应先脱敏处理,避免泄露敏感信息;生产环境使用前务必验证最小权限范围。
  • 本技能为辅助工具,不能替代人工安全评审,建议结合 CI 流水线定期运行以持续监控风险。

SKILL.md

Code Hardcode Audit

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use This Skill

Use this skill when the user mentions:

  • "hardcoded values", "hardcodes", "magic numbers"
  • "constant detection", "find constants"
  • "duplicate constants", "DRY violations"
  • "code audit", "hardcode audit"
  • "PLR2004", "semgrep", "jscpd", "gitleaks", "ast-grep", "SSoT violations"
  • "secret scanning", "leaked secrets", "API keys", "bandit", "trufflehog", "whispers"
  • "passwords in code", "credential leaks", "entropy detection"
  • "config file secrets", "hardcoded credentials"

Quick Start

# Preflight — verify all tools installed and configured
uv run --python 3.13 --script scripts/preflight.py -- .

# Full audit (all 9 tools, preflight + both outputs)
uv run --python 3.13 --script scripts/audit_hardcodes.py -- src/

# Individual tools (all respect .gitignore):

# Python credential detection (passwords, tokens, API keys in variable names)
uv run --python 3.13 --script scripts/run_bandit.py -- src/

# Entropy-based secret detection (catches secrets regex can't)
uv run --python 3.13 --script scripts/run_trufflehog.py -- src/

# Config file secrets (YAML, JSON, Dockerfile, .env, .properties)
uv run --python 3.13 --script scripts/run_whispers.py -- src/

# AST-based hardcode detection (numeric args, URLs, paths, sleep)
uv run --python 3.13 --script scripts/run_ast_grep.py -- src/

# Python magic numbers only (fastest)
uv run --python 3.13 --script scripts/run_ruff_plr.py -- src/

# Pattern-based detection (URLs, ports, paths, sleep, circuit breaker)
uv run --python 3.13 --script scripts/run_semgrep.py -- src/

# Env-var coverage audit (BaseSettings cross-reference)
uv run --python 3.13 --script scripts/audit_env_coverage.py -- src/

# Copy-paste detection
uv run --python 3.13 --script scripts/run_jscpd.py -- src/

# Regex-based secret scanning (API keys, tokens, passwords)
uv run --python 3.13 --script scripts/run_gitleaks.py -- src/

Tool Overview

ToolDetection FocusLanguage SupportSpeed
PreflightTool availability + config validationN/AInstant
BanditHardcoded passwords, tokens in Python (B105-7)PythonFast
TruffleHogEntropy-based secret + API verificationAny (file-based)Medium
WhispersConfig file secrets (YAML, JSON, Docker,.env)Config filesMedium
ast-grepHardcoded literals in args, sleep, URLs, pathsMulti-languageFast
Ruff PLR2004Magic value comparisonsPythonFast
SemgrepURLs, ports, paths, credentials, retry configMulti-languageMedium
Env-coverageBaseSettings cross-reference, coverage gapsPythonFast
jscpdDuplicate code blocksMulti-languageSlow
gitleaksRegex-based secrets, API keys, passwordsAny (file-based)Fast

Output Formats

JSON (--output json)

{
  "summary": {
    "total_findings": 42,
    "by_tool": { "ruff": 15, "semgrep": 20, "jscpd": 7 },
    "by_severity": { "high": 5, "medium": 25, "low": 12 }
  },
  "findings": [
    {
      "id": "MAGIC-001",
      "tool": "ruff",
      "rule": "PLR2004",
      "file": "src/config.py",
      "line": 42,
      "column": 8,
      "message": "Magic value used in comparison: 8123",
      "severity": "medium",
      "suggested_fix": "Extract to named constant"
    }
  ],
  "refactoring_plan": [
    {
      "priority": 1,
      "action": "Create constants/ports.py",
      "finding_ids": ["MAGIC-001", "MAGIC-003"]
    }
  ]
}

Compiler-like Text (--output text)

src/config.py:42:8: PLR2004 Magic value used in comparison: 8123 [ruff]
src/probe.py:15:1: hardcoded-url Hardcoded URL detected [semgrep]
src/client.py:20-35: Clone detected (16 lines, 95% similarity) [jscpd]

Summary: 42 findings (ruff: 15, semgrep: 20, jscpd: 7)

CLI Options

--output {json,text,both}  Output format (default: both)
--tools {all,ast-grep,ruff,semgrep,jscpd,gitleaks,env-coverage,bandit,trufflehog,whispers}  Tools to run
--severity {all,high,medium,low}  Filter by severity (default: all)
--exclude PATTERN  Glob pattern to exclude (repeatable)
--no-parallel  Disable parallel execution
--skip-preflight  Skip tool availability check

References

Related

  • ADR-0046: Semantic Constants Abstraction
  • ADR-0047: Code Hardcode Audit Skill
  • code-clone-assistant - PMD CPD-based clone detection (DRY focus)

Troubleshooting

IssueCauseSolution
Ruff PLR2004 zero outputPLR2004 globally suppressedRun preflight: uv run --python 3.13 --script scripts/preflight.py --.
Ruff PLR2004 not foundRuff not installed or olduv tool install ruff or upgrade
ast-grep not foundBinary not installedcargo install ast-grep or brew install ast-grep
Semgrep timeoutLarge codebase scanUse --exclude to limit scope
jscpd memory errorToo many filesIncrease Node heap: NODE_OPTIONS=--max-old-space-size=4096
gitleaks false positivesTest data flaggedAdd patterns to .gitleaks.toml allowlist
Env-coverage missesNot using BaseSettingsOnly detects pydantic BaseSettings; other config patterns skipped
No findings in outputWrong directory specifiedVerify path exists and contains source files
JSON parse errorTool output malformedRun tool individually with --output text
Missing tool in PATHTool not installed globallyRun preflight first, then install missing tools
Bandit false positivespassword = '' in initFilter B105 by confidence: --confidence HIGH
TruffleHog timeoutScanning.venv/node_modulesAll tools respect .gitignore; ensure large dirs are gitignored
TruffleHog regex errorGlob patterns in.gitignoreComplex globs (**/*.rs.bk) are auto-skipped; only simple names used
Whispers slow scanLarge directoriesExclude via .gitignore; whispers config auto-generated from it
Whispers zero findingsNo config files in scopeWhispers targets YAML/JSON/Docker/INI; use on project root, not src/
Severity filter emptyNo findings at that levelUse --severity all to see all findings

Post-Execution Reflection

After this skill completes, check before closing:

  1. Did the command succeed? — If not, fix the instruction or error table that caused the failure.
  2. Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
  3. Was a workaround needed? — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.

Only update if the issue is real and reproducible — not speculative.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

25.01%
按下载量换算212

OpenCode

24.4%
按下载量换算207

Antigravity

17.34%
按下载量换算147

Codex

13.23%
按下载量换算112

Gemini CLI

8.16%
按下载量换算69

windsurf

3.77%
按下载量换算32

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills