ops-code-review

Code Review 安全扫描工具,自动化代码审计,支持 Django/Python、React+TypeScript、PHP 多语言。 自动识别 SVN 提交变更,调用 bandit/pylint/eslint/phpcs 进行安全扫描和代码规范检查, 报告推送飞书群。支持 post-commit hook 增量扫描和定时全量扫描。 关键词:Code Review SVN security scan Django React PHP bandit pylint eslint phpcs 代码审计 代码扫描 安全检测 CI/CD 自动化

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "ops-code-review" with this command: npx skills add freepengyang/ops-code-review

Code Review Skill

首次使用前配置(必读)

1. 设置环境变量

Linux/Mac(加到 ~/.bashrc~/.zshrc):

export CODE_REVIEW_SVN_USER="你的SVN用户名"
export CODE_REVIEW_SVN_PASS="你的SVN密码"
export CODE_REVIEW_FEISHU_CHAT_ID="飞书群机器人chat_id"

OpenClaw 配置(推荐,写入 OpenClaw 环境变量): 在 OpenClaw 配置文件中添加:

{
  "env": {
    "CODE_REVIEW_SVN_USER": "你的SVN用户名",
    "CODE_REVIEW_SVN_PASS": "你的SVN密码",
    "CODE_REVIEW_FEISHU_CHAT_ID": "飞书群机器人chat_id"
  }
}

2. 配置仓库信息

创建配置文件(完整示例包含所有支持的仓库):

cat > config.json << 'EOF'
{
  "repos": {
    "ops_api": {
      "url": "http://your-svn/ops/dev/branches/branch_dev/ops_api",
      "lang": "django",
      "type": "incremental",
      "local": "/tmp/svn_repos/ops_api"
    },
    "ops_web": {
      "url": "http://your-svn/ops/dev/branches/branch_dev/ops_web",
      "lang": "react",
      "type": "incremental",
      "local": "/tmp/svn_repos/ops_web"
    },
    "ops_api_trunk": {
      "url": "http://your-svn/ops/dev/trunk/ops_api",
      "lang": "django",
      "type": "full",
      "local": "/tmp/svn_repos/ops_api_trunk"
    },
    "ops_web_trunk": {
      "url": "http://your-svn/ops/dev/trunk/ops_web",
      "lang": "react",
      "type": "full",
      "local": "/tmp/svn_repos/ops_web_trunk"
    },
    "gm": {
      "url": "http://your-svn/gm/trunk",
      "lang": "mixed",
      "type": "both",
      "local": "/tmp/svn_repos/gm"
    }
  }
}
EOF

将配置复制到运行时目录(必须):

cp -f config.json /tmp/code_review_config.json

注意config.json 不随 skill 上传,请根据实际 SVN 地址修改各仓库的 url 字段。

3. 检查工具依赖

python3 scripts/code_review.py check-deps

如有缺失工具,自动安装:

python3 scripts/code_review.py install-deps

能力概览

功能说明
🔍 增量扫描post-commit 触发,只扫本次提交的文件
📋 全量扫描每周定时,扫描整个仓库
🛠️ 多语言支持Django / React+TS / PHP
🔴 问题分级ERROR / WARNING / INFO 三级
🛠️ 修复建议具体代码修改方案,不只是说"有问题"
📤 飞书推送报告发送到配置的飞书群

环境变量说明

变量名必填说明
CODE_REVIEW_SVN_USERSVN 只读用户名
CODE_REVIEW_SVN_PASSSVN 密码
CODE_REVIEW_FEISHU_CHAT_ID飞书群 chat_id(机器人 webhook 或群 ID)
CODE_REVIEW_CONFIGconfig.json 路径,默认为 /tmp/code_review_config.json

使用方式

手动触发扫描

审计代码 incremental ops_api    # 增量扫描(只扫变更)
审计代码 full gm                 # 全量扫描指定仓库
审计代码 fullall                 # 全量扫描所有仓库
审计代码 sync                   # 同步所有 SVN 仓库
审计代码 check-deps             # 检查工具依赖

增量扫描流程(post-commit hook)

用户提交代码
    ↓
SVN post-commit hook 触发
    ↓
code_review.py incremental <repo_name>
    ↓
SVN Manager 获取本次变更文件
    ↓
Analyzer 逐语言分析
    ↓
Report Generator 生成飞书格式报告
    ↓
推送到飞书群

全量扫描流程(定时任务)

每周定时触发
    ↓
code_review.py fullall
    ↓
遍历所有仓库,checkout 全量代码
    ↓
按语言全量扫描
    ↓
生成报告推送飞书

工具依赖

工具用途安装命令
svnSVN 客户端apt-get install subversion
banditPython 安全扫描pip install --break-system-packages bandit
pylintPython 代码检查pip install --break-system-packages pylint
npx执行 ESLintnpm install -g npx
composerPHP 包管理器`curl -sS https://getcomposer.org/installer
phpcsPHP 代码规范composer global require squizlabs/php_codesniffer
@typescript-eslint/*ESLint 的 TypeScript 解析器npm install -g @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript-eslint

首次使用前必须运行工具检查,确保所有依赖就绪。

SVN Hook 部署

生成 hook 脚本

code_review.py setup-hooks

部署步骤

  1. 在 SVN 服务器上找到仓库路径
  2. 将生成的 post-commit 脚本放到 hooks/ 目录
  3. 赋予执行权限:chmod +x hooks/post-commit
  4. 确保 SVN 服务器能访问本 skill 的 scripts 目录

定时任务配置(OpenClaw Cron)

推荐使用 OpenClaw 内置 cron,比服务器 crontab 更方便管理:

{
  "schedule": { "kind": "cron", "expr": "0 3 * * 1", "tz": "Asia/Shanghai" },
  "payload": { "kind": "agentTurn", "message": "执行全量代码审计:\ncd /root/.openclaw/workspace/skills/code-review && python3 scripts/code_review.py fullall" },
  "sessionTarget": "isolated"
}

创建方式:告诉 OpenClaw "帮我创建一个每周一凌晨3点执行全量代码审计的定时任务"

报告示例

📊 代码审计报告
━━━━━━━━━━━━━━━━━━
🏷️ 仓库:运维后台后端 (Django)
📅 时间:2026-04-14 10:00
🔍 方式:🔄 增量扫描
📁 扫描文件:5
🐛 问题总数:3
  🔴 严重/错误:1
  🟡 警告:1
  🟢 提示:1
━━━━━━━━━━━━━━━━━━

🔴 严重 | models/user.py:45
   └ B105: Hardcoded password(s) detected
   └ 🛠️ 修复:使用环境变量或密钥管理服务,不要硬编码

🟡 警告 | views/order.py:88
   └ Possible SQL Injection
   └ 🛠️ 修复:使用参数化查询,避免字符串拼接 SQL

🟢 提示 | utils/helper.py:12
   └ Consider using 'secrets' module for cryptographic random numbers
   └ 🛠️ 修复:使用 secrets 模块替代 random

━━━━━━━━━━━━━━━━━━
⚙️ 由 OpenClaw 代码审计 Skill 自动生成

注意事项

  1. 敏感信息:SVN 账密和飞书群 ID 通过环境变量注入,不随 skill 上传
  2. 首次使用:先配置环境变量 → 创建 config.json → 复制到 /tmp/code_review_config.json → 运行 check-deps → 运行 install-deps → 运行 sync
  3. 工具缺失:记录在 /tmp/code_review_missing_tools.json,运行 install-deps 自动安装
  4. 扫描效率:全量扫描较慢,建议放在低峰时段
  5. 误报处理:如果某类问题确认为可接受的惯用写法,可以在报告中注明

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Moss Skill-9

Give your AI agent eyes to see the entire internet. Install and configure upstream tools for Twitter/X, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu, Douyi...

Registry SourceRecently Updated
Coding

Codex Deep Search

Deep web search using Codex CLI for complex queries that need multi-source synthesis. Use when web_search (Brave) returns insufficient results, when the user...

Registry SourceRecently Updated
Coding

Matz Swarm

Orchestrate OpenClaw Agent Swarm workflows for multi-project coding automation with Obsidian task intake, Claude coding, Codex review, GitLab MR flow, merge+...

Registry SourceRecently Updated
4610matzoh
Coding

xfetch

Use xfetch CLI to fetch X/Twitter data - tweets, user profiles, search results, timelines, lists, DMs, and notifications. Use this skill whenever you need to...

Registry SourceRecently Updated