仓库安全扫描工具

Orcorus是一款针对GitHub仓库的安全扫描工具,提供静态分析、密钥检测、构建验证和AI驱动的安全代码审查功能,生成评分报告。

  • by ceilingduster
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ceilingduster/mcp_security_scanner

使用说明

Orcorus存储库扫描程序

GitHub存储库的存储库安全扫描程序,既可作为MCP服务器使用,也可作为CLI工具使用。Orcorus克隆一个仓库,运行静态分析,检测硬编码的秘密,验证构建,并执行基于人工智能的OWASP对齐的安全代码审查——产生评分 SECURITY.md 报告。

特性

  • 静态分析 --跑步 匪徒 Python代码检测常见漏洞
  • 秘密检测 -基于模式的API密钥、令牌、私钥和凭据扫描
  • 构建验证 --尝试构建/安装项目(支持Python、Node、Go、Rust)
  • 试验检测 --确定测试框架(pytest、jest、mocha、vitest、unittest)
  • 人工智能安全审查 --使用与OpenAI兼容的LLM进行代理、多轮代码审查,该LLM使用工具(读取文件、搜索代码、列表目录)探索代码库,并生成与OWASP Top 10对齐的报告
  • 评分和平局 --分配0-100的安全评分,并将回购分类为金/银/铜/拒绝
  • MCP服务器 --暴露 scan_repo, get_report,以及 list_reports 工具通过 FastMCP

项目结构

src/                   # Core library
  __init__.py          # Public API: Scanner, ScanConfig, ScanResult
  models.py            # Data models (ScanConfig, ScanResult)
  scanner.py           # Main scanning pipeline
  analyzers.py         # Bandit, secrets, build, test, and quality checks
  ai_review.py         # Agentic AI security review loop
  report.py            # SECURITY.md report generation
server.py              # MCP server (FastMCP)
scan_repo.py           # CLI client

快速开始

命令行界面

# With AI review (GitHub repo)
python scan_repo.py https://github.com/owner/repo --api-key sk-...

# Without AI review
python scan_repo.py https://github.com/owner/repo --skip-ai

# Scan a local directory in-place (absolute --subdir path)
python scan_repo.py --name SSH-Command \
  --subdir /srv/docker/orcorus-integrations/ssh-command \
  --api-key sk-... --model gpt-5.4 --base-url https://api.cometapi.com/v1

# Scan current directory
python scan_repo.py .

# Custom model / provider
python scan_repo.py https://github.com/owner/repo \
  --model gpt-5.2 \
  --base-url https://api.openai.com/v1 \
  --api-key sk-...

MCP服务器

python server.py
# or
fastmcp run server.py

服务器公开了三个工具:

工具 说明
scan_repo 扫描GitHub仓库(作为后台任务运行)
get_report 按名称检索已完成的SECURITY.md报告
list_reports 列出所有可用的扫描报告及其分数

MCP客户端设置

VS代码/克劳德代码(settings.json)

将以下内容添加到您的MCP中 settings.json 将Orcorus作为Docker容器运行:

{
  "mcpServers": {
    "scanner": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "OPENAI_API_KEY=sk-your-api-key-here",
        "-e", "ORCORUS_MODEL=gpt-5.2",
        "-e", "OPENAI_BASE_URL=https://api.openai.com/v1",
        "-e", "ORCORUS_REPORTS_DIR=/app/reports",
        "-e", "ORCORUS_WORK_DIR=/app/repos",
        "-e", "ORCORUS_AI_TIMEOUT=300",
        "-e", "ORCORUS_MAX_TURNS=40",
        "orcorus/security_scanner:latest"
      ]
    }
  }
}

要在运行之间持久化报告,请装载一个卷:

{
  "mcpServers": {
    "scanner": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "OPENAI_API_KEY=sk-your-api-key-here",
        "-e", "ORCORUS_MODEL=gpt-5.2",
        "-e", "OPENAI_BASE_URL=https://api.openai.com/v1",
        "-v", "/path/to/local/reports:/app/reports",
        "orcorus/security_scanner:latest"
      ]
    }
  }
}

要跳过AI审查(仅限静态分析),请添加 -e, "ORCORUS_SKIP_AI=true" 到args。

配置

CLI参数

参数 默认值 描述
repo_url . GitHub存储库URL或本地路径(在以下情况下忽略 --subdir 是绝对的)
--name 自动检测 报告的显示名称
--commit HEAD 具体结账承诺
--subdir (无) 子目录范围, 或绝对路径 在不进行克隆的情况下就地扫描目录
--api-key $OPENAI_API_KEY LLM提供程序的API密钥
--model gpt-5.2 用于AI审查的模型
--base-url https://api.openai.com/v1 与OpenAI兼容的API基础URL
--reports-dir ./reports 保存报告的目录
--ai-timeout 300 每次AI呼叫超时(秒)
--max-turns 40 最大代理审核次数
--skip-ai false 跳过AI审查步骤
--keep-repo false 扫描后保留克隆的仓库

环境变量(MCP服务器)

变量 默认值 描述
OPENAI_API_KEY (无) 人工智能审查的API关键
ORCORUS_MODEL gpt-5.2 LLM型号名称
OPENAI_BASE_URL https://api.openai.com/v1 API基本URL
ORCORUS_REPORTS_DIR ./reports 报告输出目录
ORCORUS_WORK_DIR ./repos 临时克隆目录
ORCORUS_AI_TIMEOUT 300 每次AI呼叫超时(秒)
ORCORUS_MAX_TURNS 40 最大代理审核次数
ORCORUS_SKIP_AI false 设置为 1 或 true 跳过AI审查
ORCORUS_ALLOW_LOCAL_PATHS false 设置为 1 或 true 允许通过MCP扫描本地文件系统路径

评分

分数 等级
90–100 黄金
75–89 银色
60–74 青铜
0–59 拒绝

扣减适用于高/中/低Bandit发现、硬编码秘密、构建失败、缺少测试、缺少README、缺少依赖文件以及AI审查期间发现的关键/高严重性问题。

依赖项

  • Python 3.10+
  • 开放人工智能 --LLM客户端
  • fastmcp --MCP服务器框架
  • 强盗 --Python静态分析(可选,用于安全扫描)
  • git——用于克隆存储库