abhinavteja123/codemore
GitHub: abhinavteja123/codemore
CodeMore 是一款面向 AI 编程 agent 的静态分析器,通过机器可读报告让 agent 自行修复代码缺陷。
Stars: 1 | Forks: 0

# CodeMore
### 你的 AI agent 专属静态分析器。
AI agent 写代码很快——写 bug 也很快。CodeMore 扫描代码,然后向**编写它的 agent** 提供一份机器可读的报告,其中包含确切的修复方案和验证标准。agent 随后自行处理这些发现的问题。
[**官网**](https://codemore.tech) · [**文档**](https://codemore.tech/docs) · [**规则目录**](docs/rules) · [**报告 Schema**](docs/schema.md) · [**更新日志**](CHANGELOG.md)
[](https://www.npmjs.com/package/codemore)
[](LICENSE)
[](docs/rules)
[](docs/external-tools.md)
[](accuracy-report-2026-07-07.md)
[](accuracy-report-2026-07-07.md)
```
npx codemore@latest scan .
```
**59 条原生规则 · 8 个外部 adapter · CLI · MCP server · VS Code 扩展 · GitHub Action —— 一份报告,在任何终端上都保持字节级一致。**
## 目录
- [为什么选择 CodeMore](#why-codemore)
- [快速开始](#quick-start) — [CLI](#cli) · [MCP server](#mcp-server--cursor-claude-code-codex-claude-desktop) · [VS Code](#vs-code-extension) · [GitHub Action](#github-action) · [托管版](#web-scanner-hosted)
- [它能检测什么](#what-it-catches)
- [报告即是产品](#the-report-is-the-product)
- [Agentic 修复循环](#agentic-fix-loop)
- [如实衡量的准确率](#accuracy-measured-honestly)
- [CodeMore *不*检测什么](#what-codemore-does-not-catch)
- [架构](#architecture)
- [开发](#development) · [贡献](#contributing) · [许可证](#license)
## 为什么选择 CodeMore
AI 辅助编程正以可衡量且不断增长的速度发布漏洞:
| 发现 | 来源 |
|---|---|
| **45%** 的 AI 生成代码包含 OWASP Top-10 漏洞 | Veracode 2025/26 |
| **98%** 的 1,072 个被扫描的 vibe-coded 网站包含 ≥ 1 个安全缺陷 | Symbiotic |
| **70%** 经过审计的 Lovable 应用在发布时禁用了 Supabase RLS | DEV |
| 在 AI 工具辅助的提交中,密钥泄露率达到基准线的 **2×** | GitGuardian SOSS 2026 |
| 归因于 AI 生成代码的 **35 个 CVE/月**(一月份为 6 个/月) | 2026 年 3 月 |
现有的扫描器(SonarQube、DeepSource、Snyk)的目标受众是**坐在仪表盘前的人工审查者**。但这些代码不是人写的——而且编写它的 LLM 完全有能力修复自己的 bug,*前提是报告的格式要适合机器阅读者*。
这就是切入点。CodeMore 不是又一个 SAST 仪表盘。**它是扫描器和编码 agent 之间的报告契约**:每个发现都包含一个带有补丁模板的 `suggestedFix` 和明确的 `verificationCriteria`——不仅仅是“这里有一个问题”,而是“这里是如何确切地知道你已经修复了它。”
## 快速开始
### CLI
```
npx codemore@latest scan .
```
在终端打印摘要。添加 `--json` 以将完整的[报告](docs/schema.md)输出到 stdout,或者使用 `--out codemore-report.json` 将其写入磁盘:每个发现都精确锚定到 `file:line:column`,并附带规则引用、修复模板和验证标准。将其通过管道传递给你的 agent,看着发现的问题被逐一修复。
```
npm install -g codemore # once — or prefix each command below with `npx codemore@latest`
codemore scan . --fail-on BLOCKER # CI gate: non-zero exit on any BLOCKER
codemore scan . --external-tools ruff,biome # opt in to external tools
codemore scan . --external-tools all # ruff · golangci-lint · clippy · biome · bandit · gitleaks · npm-audit · pip-audit
codemore scan . --format sarif --out codemore.sarif # GitHub code scanning (upload-sarif)
codemore fix . --rule
--write # agentic fix loop from the CLI (needs an LLM API key)
codemore baseline create # adopt on an existing repo without drowning in legacy findings
```
### MCP server — Cursor、Claude Code、Codex、Claude Desktop
```
npx codemore mcp # print config snippet + every client's config path
npx codemore mcp install --client cursor # merge into existing config (backs up first, --dry-run supported)
```
手动配置代码片段
```
{
"mcpServers": {
"codemore": {
"command": "npx",
"args": ["-y", "codemore@latest", "serve-mcp"]
}
}
}
```
公开了六个工具:`scan_project` · `scan_file` · `explain_issue` · `suggest_fix` · `apply_fix` · `validate_fix`。
### VS Code 扩展
从 [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=codemore.codemore) 安装 **CodeMore**(扩展 → 搜索 “CodeMore” → 安装),或者自行构建 VSIX:
```
npm run vsce:package # builds codemore-.vsix
code --install-extension codemore-.vsix
```
内联诊断;代码操作的快速修复会触发 agentic 循环(计划 → 生成 → 验证 → 重试,最多尝试 3 次)。
### GitHub Action
```
# .github/workflows/codemore.yml
on:
pull_request:
branches: [main]
jobs:
scan:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: abhinavteja123/codemore@v1
with:
fail-on: BLOCKER
```
PR 评论机器人;仅在发现的问题是**新出现的**(相较于已提交的 `.codemore-baseline.json`)时才会导致构建失败。一个完整的可复制粘贴的安全门,串联了 CodeMore + Ruff + Biome + Bandit + Gitleaks + npm-audit + pip-audit + Checkov,位于 [`templates/.github/workflows/codemore-security-gate.yml`](templates/.github/workflows/codemore-security-gate.yml)([操作指南](docs/security-gate.md))。
### Web 扫描器(托管版)
登录 [**codemore.tech**](https://codemore.tech),粘贴公开的 GitHub URL 或上传 ZIP 文件——相同的报告,相同的指纹,零安装。
## 它能检测什么
涵盖 **6 个 pack** 的 **59 条原生规则**,每条规则都映射到*有据可查的真实事件类别*——而不是假设:
| Pack | 规则数 | 亮点 |
|---|---:|---|
| `core-security` | 22 | SQL injection(字符串拼接)、路径遍历、弱加密、不安全的反序列化、`eval`、shell injection、关闭 TLS、硬编码的密钥模式、硬编码的密码(B105 类)、SSRF、日志中的密钥、LLM 输出 → eval/exec/SQL sink、prompt injection sink、缺少 WHERE 的 DB 写入、幻觉 import |
| `core-quality` | 21 | 未使用的 vars/imports/exports、圈复杂度、死条件、遗留的 console/prints、无 await 的 async、不可达代码、非严格相等(loose equality)、`as any`、滥用非空断言 |
| `vibe-frontend` | 6 | XSS (`dangerouslySetInnerHTML`)、带凭证的 CORS、缺少频率限制、缺少 cookie 标志、文件上传验证、缺少输入验证 |
| `vibe-secrets` | 4 | 公共环境变量泄露(`NEXT_PUBLIC_*` / `VITE_*` / `REACT_APP_*`)、硬编码的 JWT、MCP config 密钥、CI/CD YAML 密钥 |
| `vibe-auth` | 3 | BOLA、缺少会话检查、反向认证 |
| `vibe-supabase` | 3 | 关闭 RLS、宽松的 RLS(`USING (true)`)、将 anon-key 打包到客户端 |
**8 个外部 adapter**(默认关闭,通过 `--external-tools` 启用):`ruff` · `golangci-lint` · `clippy` · `biome` · `bandit` · `gitleaks` · `npm-audit` · `pip-audit`。发现的问题使用命名空间 `ext::` —— 与原生规则没有冲突;缺少二进制文件时会静默跳过,而不会崩溃。
**Walker 能抓到 `.gitignore` 隐藏的内容。** 当开发者通过 gitignore “隐藏”泄露的密钥文件时,大多数扫描器就再也看不见它了——但它仍然存在于磁盘、tar 包和 Docker 镜像中。CodeMore 始终会扫描符合密钥特征的文件名(`.env*`、`*.pem`、`*.key`、`firebase-adminsdk*.json`、`credentials.json`、`.npmrc`、`.pypirc` 等),即使它们被 gitignore 忽略了。这正是审计中发现真实的生产环境 OpenAI 密钥、Google API 密钥和 Firebase admin SDK 凭证的方式,而其他工具却悄悄漏掉了它们。可以通过 `--respect-gitignore-fully` 选项禁用此行为。
各规则文档:[`docs/rules`](docs/rules) —— 59 个页面,每条规则一个。
## 报告即是产品
每个终端都会生成相同的 schema 稳定的 [`codemore-report.json`](docs/schema.md) —— 在每次发布时均通过 [`test/parity.test.ts`](test/parity.test.ts) 验证其**字节级一致性**(除时间戳和实例 ID 外):
```
CLI : issues=224 BLOCKER=5 fingerprint=sha256:7f95f2c62e0d3ecea6f23…
MCP : issues=224 BLOCKER=5 fingerprint=sha256:7f95f2c62e0d3ecea6f23…
Daemon : issues=224 BLOCKER=5 fingerprint=sha256:7f95f2c62e0d3ecea6f23…
```
**一个大脑,四层外衣。** Schema 就是 API;各个终端可以互换使用。
完整报告示例 —— codemore-report.json v1.0.0
```
{
"schemaVersion": "1.0.0",
"tool": { "name": "codemore", "version": "0.2.8" },
"project": { "root": ".", "framework": "next.js", "language": "typescript",
"fingerprint": "sha256:7f95f2c62e0d3ecea6f23…" },
"summary": {
"issuesTotal": 42,
"bySeverity": { "BLOCKER": 2, "CRITICAL": 5, "MAJOR": 15, "MINOR": 18, "INFO": 2 },
"byCategory": { "security": 12, "bug": 7, "…": "…" },
"filesAnalyzed": 87,
"linesOfCode": 12450,
"technicalDebtMinutes": 1840
},
"issues": [
{
"id": "vibe-supabase-rls-disabled",
"ruleVersion": "1.2.0",
"instanceId": "01HZ…",
"severity": "BLOCKER",
"confidence": 0.95,
"category": "security",
"title": "Supabase table has no RLS policy",
"evidence": {
"file": "supabase/migrations/001_init.sql",
"line": 14, "column": 1, "endLine": 14, "endColumn": 60,
"snippet": "create table profiles (id uuid primary key, …);",
"matchedPattern": "create-table-without-rls"
},
"whyItMatters": "Public Supabase client can read/write all rows. 70 % of Lovable apps leak data through this.",
"citation": "https://codemore.tech/rules/vibe-supabase-rls-disabled",
"suggestedFix": {
"type": "code-patch",
"instructions": "Add `ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;` plus at least one policy scoped to authenticated users.",
"patchTemplate": "…",
"verificationCriteria": [
"Migration contains ALTER TABLE … ENABLE ROW LEVEL SECURITY",
"At least one CREATE POLICY exists for the table",
"Re-scan no longer reports vibe-supabase-rls-disabled for this file"
]
},
"suppression": {
"available": true,
"directive": "// codemore-ignore: vibe-supabase-rls-disabled",
"scope": "same-line | next-line | file"
}
}
],
"agentInstructions": {
"preamble": "You are fixing issues found by CodeMore. Apply patches one issue at a time. After each, request re-scan via validate_fix.",
"orderingHint": "blockers → criticals → majors",
"doNotTouch": ["node_modules/**", "*.lock", ".env*"],
"stopOn": "first-validator-failure"
},
"meta": {
"rulesEnabled": 59,
"packsLoaded": ["core-security", "core-quality", "vibe-supabase", "…"],
"scanDurationMs": 4321
}
}
```
Schema 的唯一事实来源:[`shared/report/schema.json`](shared/report/schema.json)。破坏性变更会增加 `schemaVersion` 的主版本号,并附带迁移指南。
## Agentic 修复循环
`apply_fix` 运行一个四阶段循环,每个发现的问题最多重试 3 次——它会在首次通过(PASS)时终止,并且**绝不会静默保留一个失败的补丁**:
```
detect ──► plan ──► generate ──► validate
│
├──► (fail) → re-plan, retry (≤ 3)
└──► (pass) → apply patch · next finding
```
- [`agenticFixer.ts`](daemon/services/agenticFixer.ts) —— 协调器;读取发现的问题 + 规则引用 + 框架上下文
- [`validatorHarness.ts`](daemon/services/validatorHarness.ts) —— 在 tempdir 副本中应用补丁,重新运行规则,重新运行文件范围内的测试,返回 `pass | fail` + 诊断信息
- LLM provider 插件:OpenAI · Anthropic · Gemini · 本地模型,可通过工作区设置(VS Code)或 `CODEMORE_LLM_PROVIDER` 环境变量(CLI)进行配置
## 如实衡量的准确率
合成的基准测试会撒谎;真实的代码库不会。每次发布都会针对真实项目进行审计,并公布这些数字——包括那些难看的数据。
**2026-07-07 审计**([完整报告](accuracy-report-2026-07-07.md))—— 7 个代码库(Python 应用、135 万行代码的 TS monorepo、多语言 Rust、真实的合成基准应用、自身扫描):**100% 检测到了植入的漏洞**,在生产环境的 `.env` 中抓到了一个真实的 OpenAI 密钥,**~90% 的 BLOCKER 真阳性率**,在修复了四类误报后,自身扫描的噪音减少了 85%。
**2026-06-12 审计**([完整报告](accuracy-report-2026-06-12.md))—— 10 个真实的代码库,总体**~85% 的 BLOCKER 真阳性率**,高于 DeepSource 要求的生产环境 ≥ 75% 的标准:
各项目结果
| 项目 | 发现的问题 | BLOCKER | 真阳性率 | 备注 |
|---|---:|---:|---:|---|
| EchoVault | 122 | 10 | **100%** | 真实的 Supabase RLS 漏洞 |
| ProofSnap | 134 | 4 | **100%** | |
| AImentor | 224 | 5 | **100%** | 被 `.gitignore` 隐藏的真实 OpenAI 密钥 |
| Hackathonnn | 129 | 3 | **100%** | |
| shopsec | 113 | 5 | **100%** | |
| Senti | 155 | 8 | **100%** | |
| open-design | 8,615 | 101 | ~80% | |
| Gen ai | 63 | 4 | 75% | 真实的 Firebase admin SDK 凭证 |
| codemore self | 282 | 6 | 17% | 专用的演示页面数据 |
| **总计(不含自身)** | **9,755** | **140** | **~85%** | |
### 质量门禁,在 CI 中强制执行
- 在包含 118 个 fixture 的语料库回归测试套件中达到 **100% 真阳性 / 100% 假阳性** —— 每条规则在 `corpus/rules//{tp,fp}/` 下至少附带一个真阳性(TP)和一个假阳性(FP)fixture
- 生命周期门禁:规则的生命周期为 `experimental` → `beta` → `stable`,升级需要 fixture 对,以及通过选择性启用的遥测数据提供的真实世界的误报率证据;未达到准确率标准的规则会被限制在 `--enable-experimental` 后,或者在发布时降低置信度,以便 agent 降低对它们的权重
| 生命周期 | 默认 | 升级标准 |
|---|---|---|
| `experimental` | 默认关闭 | 一对 fixture |
| `beta` | 默认开启 ≥ 3 对 fixture + 14 天误报率 < 15% |
| `stable` | 包含在默认 pack 中 | 30 天误报率 < 5% + 参考应用无误报 |
| `deprecated` | 发出警告,在下一个主版本中移除 | — |
## CodeMore *不*检测什么
根据设计**不在范围内** —— 静态分析无法判断这些问题,而且 agent 无法通过源码 diff 自动修复它们。我们的原则是*“如果 agent 无法处理,它就构不成一条规则”*:
弱密码策略 · 审计日志完整性 · 业务逻辑缺陷 · 竞态条件 · 开放的 S3/GCS 存储桶 · DAST 发现的问题 · 是否存在 MFA。
带有原因的完整列表:[`docs/limitations.md`](docs/limitations.md)。针对这些问题,请将 CodeMore 与 OWASP ZAP、Burp Suite、`checkov` 或你 IdP 的合规仪表盘结合使用。
## 遥测 —— 仅限选择性启用
默认关闭。通过 `--telemetry` 按次扫描启用。收集的数据:工具版本、哈希后的项目指纹、终端、规则触发事件。**绝不收集:** 文件路径、内容、代码片段、证据文本 —— endpoint 强制执行 Zod `strict()` schema,并以 HTTP 400 拒绝任何包含这些键的 payload。64 KB payload 限制,按指纹进行速率限制,RLS 拒绝所有读取操作。
## 架构
```
codemore/
├── shared/ ← one brain, shared across all surfaces
│ ├── packs/ ← 59 rule modules across 6 packs
│ ├── rules/ ← registry, lifecycle gating, suppression, AST helpers (TS + Python)
│ └── report/ ← codemore-report.json v1.0.0 schema + types + writer
├── daemon/
│ ├── cli/ ← CLI entry · walker · ignore resolver · baseline diff
│ ├── mcp/ ← MCP server (6 tools)
│ ├── external/ ← 8 opt-in adapters, fail-loud parsers
│ ├── services/ ← agentic fixer · validator harness · scan orchestrator
│ └── llm/ ← OpenAI · Anthropic · Gemini · local provider plug-ins
├── src/ ← VS Code extension (forks daemon, renders diagnostics)
├── web/ ← Next.js: landing · dashboard · docs · /api/telemetry
├── corpus/rules//{tp,fp}/ ← 59 TP/FP fixture pairs, 1:1 with the rule catalog
├── docs/ ← schema · limitations · security-gate · 59 per-rule pages
└── templates/ ← copy-paste GitHub Action workflows
```
**一个大脑 (`shared/`),四层外衣 (CLI、MCP、扩展、Action),一个报告 schema** —— 靠一致性测试来保证诚实,而不是靠一句口号。
## 开发
```
git clone https://github.com/abhinavteja123/codemore
cd codemore
npm ci # postinstall skips binary downloads in dev automatically
npx tsc -p tsconfig.publish.json # type-check the publishable surface
npm run test:unit # unit tests (mocha + ts-node)
npx mocha --require ts-node/register test/parity.test.ts # surface-parity proof
node cli.js scan corpus/rules/vibe-no-rate-limit/tp --json --enable-experimental
cd web && npm ci && npm run dev # landing + dashboard + docs → localhost:3000
```
VS Code 扩展:在 VS Code 中按 `F5`,或者运行 `npm run watch` + `code --extensionDevelopmentPath=.`
## 路线图
- MCP registry 列表(VS Code Marketplace:已上线)
- 演示视频:打开一个真实的 vibe-coded 应用,扫描,将报告交给 Claude Code,看着每一个 BLOCKER 被解决
- 包含已发布数据集的 50 款应用基准测试研究
- 遥测驱动的规则自动降级(夜间工作流)
- JetBrains 插件 · 跨语言污点分析(研究中)
详情:[`docs/roadmap.md`](docs/roadmap.md)。
## 许可证
MIT —— 详见 [LICENSE](LICENSE)。CodeMore 从第一行代码起就是开源的,并将一直保持下去。我们的切入点是报告契约,而不是技术封锁。
**你的 AI agent 专属静态分析器。**
[官网](https://codemore.tech) · [文档](https://codemore.tech/docs) · [规则](https://codemore.tech/docs/rules) · [Schema](https://codemore.tech/docs/schema) · [npm](https://www.npmjs.com/package/codemore) · [行为准则](CODE_OF_CONDUCT.md)
标签:AI编程辅助, IDE插件, MITM代理, SOC Prime, 安全专业人员, 开发工具, 暗色界面, 自定义脚本, 错误基检测, 静态代码分析