安全漏洞扫描工具

GhostPatch是一款AI驱动的安全漏洞扫描工具,支持本地运行,无需额外基础设施,提供多种编程语言和漏洞检测功能。

  • by NeuralRays
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 NeuralRays/ghostpatch

使用说明

Ghostpatch

AI驱动的安全漏洞扫描程序 它通过npm在本地运行,无需任何基础设施设置。

用途 拥抱默认情况下无脸模特 (零成本),可选 安thropic克劳德 和 OpenAI GPT 以便进行更深入的分析。包括用于AI编码代理集成的CLI、库API和MCP服务器。

特性

  • 200+安全规则 涵盖OWASP Top 10、CWE等
  • 15种语言:TypeScript、JavaScript、Python、Java、Go、Rust、C、C++、C#、PHP、Ruby、Swift、Kotlin、Shell、SQL
  • 10个专用探测器:注入、身份验证、加密、机密、SSRF、路径遍历、原型污染、反序列化、依赖、配置错误
  • 人工智能驱动的零日检测 使用HuggingFace(免费)、Anthropic或OpenAI
  • 4种输出格式:终端(彩色)、JSON、SARIF(GitHub/VS代码)、HTML报告
  • MCP服务器 配备8个AI编码代理集成工具
  • 观看模式 用于开发过程中的连续扫描
  • 零配置 --开箱即用,可通过配置 .ghostpatch.json

快速开始

# Install globally
npm install -g ghostpatch

# Scan current directory
ghostpatch scan

# Scan specific path
ghostpatch scan ./src

# Short alias
gp scan

# Scan for secrets only
ghostpatch secrets

# Check dependencies
ghostpatch deps

# Generate HTML report
ghostpatch report

# Enable AI analysis
ghostpatch scan --ai
ghostpatch scan --ai --provider anthropic

CLI命令

ghostpatch scan [path]           # Full security scan
  -o, --output <format>          # json | sarif | html | terminal (default: terminal)
  -s, --severity <level>         # critical | high | medium | low | info
  --ai                           # Enable AI-enhanced analysis
  --provider <name>              # huggingface | anthropic | openai
  --fix                          # Show fix suggestions
  -q, --quiet                    # Minimal output

ghostpatch secrets [path]        # Scan for hardcoded secrets only
ghostpatch deps [path]           # Dependency vulnerability check
ghostpatch watch [path]          # Watch mode — scan on file changes
ghostpatch report [path]         # Generate HTML report
ghostpatch serve                 # Start MCP server (stdio)
ghostpatch install               # Configure MCP for Claude Code

AI提供商

提供商 成本 设置 型号
拥抱脸 (默认) 免费 可选 HF_TOKEN env var Qwen2.5编码-32B
Anthropic 已付 ANTHROPIC_API_KEY 环境变量 克劳德十四行诗4.5
开放人工智能 已付 OPENAI_API_KEY 环境变量 GPT-4o
# Use free HuggingFace (default)
ghostpatch scan --ai

# Use Anthropic Claude
export ANTHROPIC_API_KEY=sk-ant-...
ghostpatch scan --ai --provider anthropic

# Use OpenAI
export OPENAI_API_KEY=sk-...
ghostpatch scan --ai --provider openai

库API

import { scan, generateReport, Severity } from 'ghostpatch';

// Full scan
const result = await scan('./my-project', {
  severity: Severity.MEDIUM,
  ai: true,
  provider: 'huggingface',
});

// Generate report
const html = generateReport(result, 'html');
const json = generateReport(result, 'json');
const sarif = generateReport(result, 'sarif');

// Access findings
console.log(`Found ${result.summary.total} issues`);
for (const finding of result.findings) {
  console.log(`${finding.severity}: ${finding.title} at ${finding.filePath}:${finding.line}`);
}

MCP服务器(AI编码代理集成)

GhostPatch包括一个带有8个工具的MCP服务器,用于与Claude Code等AI编码代理无缝集成。

# Auto-configure for Claude Code
ghostpatch install

# Or manually start
ghostpatch serve

MCP工具

工具 说明
ghostpatch_scan 项目的全面安全扫描
ghostpatch_scan_file 扫描单个文件
ghostpatch_findings 使用过滤器获取结果
ghostpatch_finding 具体发现的详细信息
ghostpatch_secrets 扫描硬编码的秘密
ghostpatch_dependencies 检查CVE的依赖关系
ghostpatch_ai_analyze 人工智能驱动的深度分析
ghostpatch_status 扫描仪状态和统计信息

配置

创建 .ghostpatch.json 在项目根目录中:

{
  "exclude": ["node_modules/**", "dist/**", "*.min.js"],
  "severity": "medium",
  "ai": {
    "provider": "huggingface",
    "model": "auto"
  },
  "rules": {
    "disabled": ["LOG003"],
    "custom": []
  },
  "maxFileSize": 1048576,
  "languages": "auto"
}

安全类别

OWASP 类别 规则
A01 访问控制中断 BAC001–BAC010
A02 加密失败 CRYPT001–CRYPT012,SEC001–SEC014
A03 注射 INJ001–INJ018,PROT001–PROT002
A04 不安全设计 DES001–DES007
A05 安全配置错误 CFG001-CFG010
A06 易损部件 DEP001-DEP003
A07 身份验证失败 AUTH001–AUTH008
A08 数据完整性故障 SER001–SER004
A09 日志记录失败 LOG001–LOG003
.A10.SSRF.SSRF001–SSRF002。

输出格式

终端

带有严重性图标、代码片段和修复建议的彩色输出。

JSON

用于CI/CD集成的机器可读结构化输出。

萨里夫

静态分析结果交换格式——与GitHub代码扫描和VS代码兼容。

超文本标记语言

具有严重性图表、查找细节和补救建议的专业独立报告。

CI/CD集成

# GitHub Actions
- name: Security Scan
  run: |
    npx ghostpatch scan --output sarif -s medium > results.sarif

- name: Upload SARIF
  uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: results.sarif

贡献

我们欢迎捐款!以下是如何参与其中:

报告问题

发现错误或有功能请求? 打开一个问题 与:

  • 对问题或建议的清晰描述
  • 复制步骤(针对bug)
  • 预期行为与实际行为
  • 您的环境(操作系统,Node.js版本)

提交拉取请求

  1. 分叉 存储库
  2. 创建 特征分支: git checkout -b feature/my-feature
  3. 制造 您的更改和添加测试
  4. 跑 测验: npm test
  5. 构建 验证: npm run build
  6. 提交 您的更改: git commit -m "Add my feature"
  7. 推 到你的叉子: git push origin feature/my-feature
  8. 打开 一 拉取请求 反对 master

开发设置

git clone https://github.com/NeuralRays/ghostpatch.git
cd ghostpatch
npm install
npm run build
npm test

我们正在寻找什么

  • 新的安全检测规则和模式
  • 支持其他编程语言
  • 改进了人工智能提示工程,以实现更好的分析
  • 错误修复和误报减少
  • 文档改进
  • CI/CD集成示例

行为准则

请在所有互动中保持尊重和建设性。我们致力于为每个人提供热情和包容的体验。

安全

如果您在GhostPatch中发现安全漏洞,请通过电子邮件负责任地报告 neuralsoft@injectedsecurity.pro 而不是公开问题。

创建者和维护者

神经射线 — GitHub | neuralsoft@injectedsecurity.pro

许可证

MIT许可证——见 许可证 了解详情。


GhostPatch — Scan. Detect. Secure.
Built with TypeScript. Powered by AI.