audit-code -- Project Code Security Review
Security-focused code review of project source code. Covers OWASP-style vulnerabilities, hardcoded secrets, dangerous function calls, and patterns relevant to AI-assisted development.
What to do
Run the auditor against the target path:
CODEBLOCK0
If $ARGUMENTS is empty, default to $PROJECT_ROOT.
What it checks
- - Hardcoded secrets -- API keys (AWS, GitHub, Stripe, OpenAI, Slack), tokens, private keys, connection strings, passwords
- Dangerous function calls -- eval, exec, subprocess with shell=True, child_process.exec, pickle deserialization, system(), gets(), etc.
- SQL injection -- String concatenation/interpolation in SQL queries
- Dependency risks -- Known hallucinated package names, unverified installations
- Sensitive files -- .env files committed to git, credential files in repo
- File permissions -- Overly permissive chmod patterns
- Exfiltration patterns -- Base64 encode + network send, DNS exfiltration, credential file reads
Output
Structured report with severity-ranked findings, file locations, and actionable remediation steps.
When to use
- - Before committing or pushing code
- When reviewing third-party contributions or PRs
- As part of a periodic security audit of the codebase
- After AI-assisted code generation to verify no secrets or vulnerabilities were introduced
Advisory hooks
The repository's .claude/settings.json includes PreToolUse hooks that warn on
dangerous Bash and Write operations. These hooks are advisory only -- they
produce warnings but do not block execution.
- - audit-code is the detection layer for source code security issues
- The hooks provide supplementary runtime warnings during agent operation
- To enforce blocking, hooks must return INLINECODE3
instead of warning messages
技能名称: audit-code
详细描述:
audit-code —— 项目代码安全审查
对项目源代码进行安全导向的代码审查。涵盖 OWASP 类型漏洞、硬编码密钥、危险函数调用以及与 AI 辅助开发相关的模式。
操作方式
对目标路径运行审查工具:
bash
python3 $SKILLDIR/scripts/auditcode.py $ARGUMENTS
如果 $ARGUMENTS 为空,则默认使用 $PROJECT_ROOT。
审查内容
- - 硬编码密钥 —— API 密钥(AWS、GitHub、Stripe、OpenAI、Slack)、令牌、私钥、连接字符串、密码
- 危险函数调用 —— eval、exec、带 shell=True 的 subprocess、child_process.exec、pickle 反序列化、system()、gets() 等
- SQL 注入 —— SQL 查询中的字符串拼接/插值
- 依赖风险 —— 已知的幻觉包名、未经验证的安装
- 敏感文件 —— 提交到 git 的 .env 文件、仓库中的凭证文件
- 文件权限 —— 过于宽松的 chmod 模式
- 数据外泄模式 —— Base64 编码加网络发送、DNS 外泄、凭证文件读取
输出
结构化报告,包含按严重程度排序的发现项、文件位置以及可操作的修复步骤。
使用时机
- - 在提交或推送代码之前
- 审查第三方贡献或拉取请求时
- 作为代码库定期安全审计的一部分
- 在 AI 辅助代码生成之后,验证是否引入了密钥或漏洞
建议性钩子
仓库的 .claude/settings.json 包含 PreToolUse 钩子,可在危险 Bash 和写入操作时发出警告。这些钩子仅作建议 —— 它们产生警告但不阻止执行。
- - audit-code 是源代码安全问题的检测层
- 这些钩子在代理操作期间提供补充性运行时警告
- 若要强制执行阻止,钩子必须返回 {decision: block} 而非警告消息