code-security-audit by leonmelamud/claude-code-security-review
npx skills add https://github.com/leonmelamud/claude-code-security-review --skill code-security-audit基于人工智能的代码变更安全审计,具备误报过滤功能。基于 claude-code-security-review。
claude-code-security-review/
├── SKILL.md # 本文件 — 工作流程和说明
├── action.yml # GitHub Actions 复合操作定义
├── claudecode/ # Python 包 (导入: from claudecode.*)
│ ├── __init__.py # 包初始化 — 重新导出主要入口点
│ ├── audit.py # 入口点 — 包装 github_action_audit
│ ├── github_action_audit.py # GitHub Action 审计运行器 (PR 获取, Claude 运行器, 过滤管道)
│ ├── prompts.py # 安全审计提示模板
│ ├── findings_filter.py # 硬性排除规则 + Claude API 误报过滤
│ ├── claude_api_client.py # 用于单条发现项分析的 Claude API 客户端
│ ├── json_parser.py # 从文本中稳健提取 JSON (代码块, 嵌套花括号)
│ ├── constants.py # 配置: 模型名称, 超时时间, 令牌限制, 退出代码
│ ├── logger.py # 带 GitHub 上下文前缀的标准错误日志
│ ├── requirements.txt # Python 依赖: anthropic, requests, PyGithub
│ └── evals/ # 评估框架
│ ├── run_eval.py # CLI: python -m claudecode.evals.run_eval owner/repo#123
│ └── eval_engine.py # Git 工作树管理 + SAST 运行器
├── scripts/ # 独立脚本 (非 Python 包)
│ └── comment-pr-findings.js # 将发现项作为 PR 审查评论发布的 Node.js 脚本
├── references/ # 按需加载到上下文中的知识
│ ├── false-positive-filtering.md # 20 条硬性排除规则, 信号质量标准, 12 个先例
│ ├── custom-scan-instructions.md # 行业模板 (合规, 金融服务, 电子商务, GraphQL)
│ ├── custom-false-positive-filtering.txt # 自定义误报过滤规则示例
│ └── custom-security-scan-instructions.txt # 自定义扫描类别示例
└── assets/ # 输出中使用的文件
└── security-review-command.md # Claude Code /security-review 斜杠命令模板
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在直接审计代码变更时使用此流程 (无需 CI 脚本)。
git diff --merge-base origin/main # 分支差异
git diff --cached # 已暂存的变更
git diff HEAD~N # 最近 N 次提交
git diff --name-only origin/main... # 列出修改的文件
阶段 1 — 上下文研究: 识别代码库中的安全框架、ORM、身份验证库、清理模式和信任边界。
阶段 2 — 比较分析: 将新代码与已建立的安全模式进行比较。标记偏差、不一致之处和新的攻击面。
阶段 3 — 漏洞评估: 检查每个修改过的文件是否存在以下问题:
追踪从用户输入到敏感操作的数据流。寻找权限边界跨越。
加载 references/false-positive-filtering.md 并应用所有规则。为每个发现项分配 1-10 的置信度;仅保留置信度 ≥ 8 的发现项。
对于特定领域的类别,加载 references/custom-scan-instructions.md。
# 漏洞 N: [类别]: `file.ts:42`
* 严重性: 高 | 中
* 置信度: 8/10
* 描述: [漏洞是什么]
* 利用场景: [具体的攻击路径]
* 建议: [具体的修复方案]
通过 CI 在 PR 上运行自动化安全审计。需要 ANTHROPIC_API_KEY 和 GITHUB_TOKEN。
pip install -r claudecode/requirements.txt
| 变量 | 是否必需 | 用途 |
|---|---|---|
ANTHROPIC_API_KEY | 是 | Claude API 访问权限 |
GITHUB_TOKEN | 是 | 用于获取 PR 数据的 GitHub API 访问权限 |
GITHUB_REPOSITORY | 是 | 所有者/仓库 格式 |
PR_NUMBER | 是 | 拉取请求编号 |
EXCLUDE_DIRECTORIES | 否 | 要跳过的目录,以逗号分隔 |
ENABLE_CLAUDE_FILTERING | 否 | true 表示使用 Claude API 进行误报过滤 |
FALSE_POSITIVE_FILTERING_INSTRUCTIONS | 否 | 自定义过滤规则文件路径 |
CUSTOM_SECURITY_SCAN_INSTRUCTIONS | 否 | 自定义扫描类别文件路径 |
python claudecode/audit.py
输出为 JSON 格式,包含 findings、analysis_summary 和 filtering_summary。
name: 安全审查
permissions:
pull-requests: write
contents: read
on:
pull_request:
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- uses: anthropics/claude-code-security-review@main
with:
comment-pr: true
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}
将发现项作为内联审查评论发布:
node scripts/comment-pr-findings.js
从当前工作目录读取 findings.json。需要 GITHUB_TOKEN 和 GITHUB_EVENT_PATH。
查看 references/ 目录中的示例自定义文件:
references/custom-false-positive-filtering.txt — 自定义误报过滤规则模板references/custom-security-scan-instructions.txt — 自定义扫描类别模板针对任何公共 PR 测试审计功能:
export ANTHROPIC_API_KEY=sk-...
python -m claudecode.evals.run_eval owner/repo#123 --verbose
结果以 JSON 格式保存到 ./eval_results/,包含发现项、运行时间和成功状态。
将 assets/security-review-command.md 复制到任何项目的 .claude/commands/security-review.md 中,即可在 Claude Code 中启用 /security-review 命令。
每周安装次数
105
代码仓库
GitHub 星标数
2
首次出现
2026年2月22日
安全审计
安装于
github-copilot104
kimi-cli101
gemini-cli101
amp101
codex101
opencode101
AI-powered security audit for code changes with false positive filtering. Based on claude-code-security-review.
claude-code-security-review/
├── SKILL.md # This file — workflow and instructions
├── action.yml # GitHub Actions composite action definition
├── claudecode/ # Python package (imports: from claudecode.*)
│ ├── __init__.py # Package init — re-exports main entry points
│ ├── audit.py # Entry point — wraps github_action_audit
│ ├── github_action_audit.py # GitHub Action audit runner (PR fetch, Claude runner, filter pipeline)
│ ├── prompts.py # Security audit prompt templates
│ ├── findings_filter.py # Hard exclusion rules + Claude API false positive filtering
│ ├── claude_api_client.py # Claude API client for single-finding analysis
│ ├── json_parser.py # Robust JSON extraction from text (code blocks, nested braces)
│ ├── constants.py # Config: model name, timeouts, token limits, exit codes
│ ├── logger.py # Stderr logging with GitHub context prefix
│ ├── requirements.txt # Python deps: anthropic, requests, PyGithub
│ └── evals/ # Evaluation framework
│ ├── run_eval.py # CLI: python -m claudecode.evals.run_eval owner/repo#123
│ └── eval_engine.py # Git worktree management + SAST runner
├── scripts/ # Standalone scripts (non-Python-package)
│ └── comment-pr-findings.js # Node.js script to post findings as PR review comments
├── references/ # Knowledge loaded into context as needed
│ ├── false-positive-filtering.md # 20 hard exclusions, signal quality criteria, 12 precedents
│ ├── custom-scan-instructions.md # Industry templates (compliance, finserv, e-commerce, GraphQL)
│ ├── custom-false-positive-filtering.txt # Example custom FP filtering rules
│ └── custom-security-scan-instructions.txt # Example custom scan categories
└── assets/ # Files used in output
└── security-review-command.md # Claude Code /security-review slash command template
Use this when auditing code changes directly (without CI scripts).
git diff --merge-base origin/main # Branch diff
git diff --cached # Staged changes
git diff HEAD~N # Last N commits
git diff --name-only origin/main... # List modified files
Phase 1 — Context Research: Identify security frameworks, ORMs, auth libraries, sanitization patterns, and trust boundaries in the codebase.
Phase 2 — Comparative Analysis: Compare new code against established secure patterns. Flag deviations, inconsistencies, and new attack surfaces.
Phase 3 — Vulnerability Assessment: Check each modified file for:
Trace data flow from user inputs to sensitive operations. Look for privilege boundary crossings.
Load references/false-positive-filtering.md and apply all rules. Assign confidence 1-10 per finding; only keep findings with confidence ≥ 8.
For domain-specific categories, load references/custom-scan-instructions.md.
# Vuln N: [Category]: `file.ts:42`
* Severity: HIGH | MEDIUM
* Confidence: 8/10
* Description: [What the vulnerability is]
* Exploit Scenario: [Concrete attack path]
* Recommendation: [Specific fix]
Run automated security audits on PRs via CI. Requires ANTHROPIC_API_KEY and GITHUB_TOKEN.
pip install -r claudecode/requirements.txt
| Variable | Required | Purpose |
|---|---|---|
ANTHROPIC_API_KEY | Yes | Claude API access |
GITHUB_TOKEN | Yes | GitHub API access for PR data |
GITHUB_REPOSITORY | Yes | owner/repo format |
PR_NUMBER | Yes | Pull request number |
EXCLUDE_DIRECTORIES |
python claudecode/audit.py
Output is JSON with findings, analysis_summary, and filtering_summary.
name: Security Review
permissions:
pull-requests: write
contents: read
on:
pull_request:
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- uses: anthropics/claude-code-security-review@main
with:
comment-pr: true
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}
Post findings as inline review comments:
node scripts/comment-pr-findings.js
Reads findings.json from cwd. Requires GITHUB_TOKEN and GITHUB_EVENT_PATH.
See references/ for sample customization files:
references/custom-false-positive-filtering.txt — Template for custom FP filtering rulesreferences/custom-security-scan-instructions.txt — Template for custom scan categoriesTest the audit against any public PR:
export ANTHROPIC_API_KEY=sk-...
python -m claudecode.evals.run_eval owner/repo#123 --verbose
Results saved to ./eval_results/ as JSON with findings, runtime, and success status.
Copy assets/security-review-command.md to .claude/commands/security-review.md in any project to enable /security-review in Claude Code.
Weekly Installs
105
Repository
GitHub Stars
2
First Seen
Feb 22, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykWarn
Installed on
github-copilot104
kimi-cli101
gemini-cli101
amp101
codex101
opencode101
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
138,800 周安装
| No |
| Comma-separated dirs to skip |
ENABLE_CLAUDE_FILTERING | No | true to use Claude API for FP filtering |
FALSE_POSITIVE_FILTERING_INSTRUCTIONS | No | Path to custom filtering rules |
CUSTOM_SECURITY_SCAN_INSTRUCTIONS | No | Path to custom scan categories |