원클릭으로
security-audit
// Pre-release / open-source security audit. Scans for hardcoded credentials, dependency vulnerabilities, .gitignore gaps, and missing required files. Produces phased interactive results with a final archivable report.
// Pre-release / open-source security audit. Scans for hardcoded credentials, dependency vulnerabilities, .gitignore gaps, and missing required files. Produces phased interactive results with a final archivable report.
| name | security-audit |
| description | Pre-release / open-source security audit. Scans for hardcoded credentials, dependency vulnerabilities, .gitignore gaps, and missing required files. Produces phased interactive results with a final archivable report. |
Activate when the user mentions any of: "安全检查", "security audit", "pre-release", "准备开源", "密钥泄漏", "open source check", "上线前检查", "security scan", "有没有泄漏".
Check for the following files to determine tech stack (multiple may apply):
pyproject.toml, requirements.txt, setup.py → Pythonpackage.json → Node.jsgo.mod → GoCargo.toml → Rustpom.xml, build.gradle → Java/KotlinAnnounce before starting:
检测到项目类型:[Python / Node.js / ...]
开始安全扫描,共两个自动阶段 + 一份人工自查清单...
Run all checks below sequentially. Output results per check as they complete — do not wait until all checks finish.
Critical interrupt rule: When a CRITICAL issue is found, pause and ask:
发现 CRITICAL 问题,是否先修复再继续,还是扫描完成后统一处理?[先修复 / 继续扫描]
Only interrupt once per phase — batch multiple CRITICAL findings together if they appear close in sequence.
Use Grep to search the entire codebase with these patterns:
(API_KEY|SECRET|PASSWORD|TOKEN|PRIVATE_KEY|api_key|secret_key|access_key|ak|sk)\s*[=:]\s*["'][^"']{8,}["']
Exclude from search: *.example, *.md, node_modules/, __pycache__/, .git/, dist/, build/
For each match, determine if the value looks like a real credential vs a placeholder:
YOUR_KEY, <your-key>, xxx, ..., CHANGE_ME, sk-xxxsk-, ghp_, AKIA)Output format:
CRITICAL 硬编码密钥
config.yaml:17 DashScope API Key (sk-4a26...)
embedding.py:22 SiliconFlow API Key (sk-hgmm...)
If clean:
PASS 硬编码密钥扫描:未发现
Run:
git log --all -p | grep -iE "(api_key|secret|password|token|private_key)\s*[=:]\s*['\"][^'\"]{8,}"
PASS Git 历史扫描:未发现密钥残留
Read .gitignore and check for the following patterns. Report each missing one as WARNING:
| Pattern | Purpose |
|---|---|
.env, .env.*, .env.local | 环境变量文件 |
*.pem, *.key, *.p12, *.cer | 证书与私钥 |
*.log | 运行时日志 |
*.db, *.sqlite | 本地数据库 |
node_modules/ | Node 依赖(Node.js 项目) |
__pycache__/, *.pyc | Python 缓存(Python 项目) |
dist/, build/ | 构建产物 |
.idea/, .vscode/settings.json | IDE 个人配置 |
If all present:
PASS .gitignore 配置:完整
Check existence of:
.env.example — WARNING if missing(应提供变量名模板)LICENSE or LICENSE.md — WARNING if missingREADME.md — WARNING if missingCONTRIBUTING.md — WARNING if missing(对外开源项目)Output each as one line:
PASS LICENSE 存在(AGPL-3.0)
WARNING .env.example 缺失,建议提供变量名模板
Glob .github/workflows/*.yml and Grep for:
${{ secrets.xxx }} syntaxPASS GitHub Actions:凭证引用规范
or:
CRITICAL GitHub Actions:发现硬编码凭证
.github/workflows/deploy.yml:14 API_KEY = "sk-..."
Grep the entire codebase (excluding *.md, node_modules/, .git/) for:
192\.168\., 10\.\d+\., 172\.(1[6-9]|2\d|3[01])\.localhost, 127\.0\.0\.1 (flag only if in non-test, non-config-example files)postgresql://, mysql://, mongodb://, redis://, jdbc:\.internal, \.local, \.corp, \.intraFor each match, judge whether it belongs in source code or should be in config/env:
.env.example: skipWARNING 发现内网地址或连接串
src/db/client.py:8 postgresql://admin:pass@192.168.1.10:5432/prod
→ 移至环境变量,避免暴露内部网络结构
If clean:
PASS 内网地址 / 连接串扫描:未发现
Grep comments (lines starting with #, //, /*, *) for patterns suggesting sensitive technical information:
password, passwd, pwd followed by actual valuesNote: Only flag technically sensitive content (credentials, addresses). Do NOT attempt to judge whether business logic in comments is "sensitive" — that requires human review and will be noted in the manual checklist.
WARNING 代码注释中发现技术敏感信息
src/api/auth.py:42 # default password is Abc123!
→ 移除注释中的凭证信息
If clean:
PASS 代码注释扫描:未发现技术敏感信息
Run the appropriate tool based on detected project type:
pip-licenses --format=markdown (install via pip install pip-licenses if not available)npx license-checker --summaryCompare detected licenses against the project's own license using this compatibility reference:
| Project License | Incompatible dependency licenses |
|---|---|
| MIT / Apache 2.0 | GPL-2.0-only, GPL-3.0-only, AGPL-3.0 |
| GPL-2.0 | Apache-2.0 (one-way), AGPL-3.0 |
| AGPL-3.0 | generally compatible with GPL/LGPL/MIT, flag proprietary licenses |
| Proprietary | GPL, AGPL, LGPL (copyleft licenses) |
Flag any dependency whose license is potentially incompatible as WARNING. If pip-licenses is unavailable, note it and skip.
WARNING License 兼容性风险
somelib 1.2.0 GPL-3.0-only
→ 项目为 MIT 协议,GPL 依赖可能引入传染性约束,建议法务确认或替换依赖
PASS 其余 42 个依赖 License 兼容(MIT / Apache-2.0 / BSD)
Run the appropriate tool based on detected project type:
pip-auditnpm auditgovulncheck ./... (if installed, else skip with note)cargo audit (if installed, else skip with note)Filtering rules — do not dump raw output. Classify and present:
| Severity | Action |
|---|---|
| Critical / High + fix available | CRITICAL,说明受影响路径,给出升级版本 |
| High + no fix | WARNING,说明无可用修复 |
| Medium | WARNING,一句话说明影响范围 |
| Low / Info | 忽略,不展示 |
| Dev-only dependency | 降一级处理(High → Warning,Medium → 忽略) |
For ambiguous cases where impact depends on usage (e.g., proxy auth, specific API endpoints), ask one targeted yes/no question before classifying.
Example output:
WARNING pip-audit 发现 2 个需关注的漏洞
cryptography 41.0.0 CVE-2024-xxxx 高危
影响:RSA 解密路径,建议升级到 42.0.0
setuptools 65.0.0 CVE-2022-xxxx 低危(构建期依赖,运行时不影响,已过滤)
If no actionable issues:
PASS 依赖漏洞扫描:无需关注的漏洞
After automated scan completes, output this section as a static recommendation list — do not ask questions interactively:
MANUAL 以下项目需团队人工自查(AI 无法自动验证)
[ ] 图片、截图等静态资源中无内网地址、内部邮箱、未公开数据
[ ] 代码注释中无业务敏感逻辑(技术性敏感信息已自动扫描)
[ ] GitHub Collaborators 列表已清理,移除不再参与项目的成员
[ ] 代码中无来自前公司或其他雇主的专有代码
[ ] 若涉及用户数据,README 中已说明数据处理方式
[ ] 已在全新环境按 README 步骤完整运行一遍,确认可正常启动
Output a consolidated archivable report at the end:
## 安全审查报告 · [项目名] · [YYYY-MM-DD]
结论:[一句话总结,例如"发现 2 个严重问题,建议修复后再发布"或"未发现严重问题,可以开源/上线"]
---
### 严重问题(必须修复)
[若无则写"无"]
1. [问题标题]
[文件路径或具体位置]
→ [具体操作建议]
### 警告(建议修复)
[若无则写"无"]
- [问题描述] → [建议操作]
### 通过项
[所有 PASS 项合并为一行逗号分隔,不展开细节]
### 人工自查清单
[ ] 图片、截图等静态资源中无内网地址、内部邮箱、未公开数据
[ ] 代码注释中无业务敏感逻辑(技术性敏感信息已自动扫描)
[ ] GitHub Collaborators 列表已清理,移除不再参与项目的成员
[ ] 代码中无来自前公司或其他雇主的专有代码
[ ] 若涉及用户数据,README 中已说明数据处理方式
[ ] 已在全新环境按 README 步骤完整运行一遍,确认可正常启动