Carlos-Projects/threatlens

GitHub: Carlos-Projects/threatlens

面向 AI/MCP 安全生态的威胁情报聚合与关联引擎,从多种安全工具统一摄取信号并生成可操作的告警和威胁报告。

Stars: 0 | Forks: 0

# ThreatLens [![Python](https://img.shields.io/badge/python-3.11%20|%203.12%20|%203.13-blue.svg)](https://python.org) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/Carlos-Projects/threatlens/actions/workflows/ci.yml) [![PyPI](https://img.shields.io/pypi/v/threatlens-ai.svg)](https://pypi.org/project/threatlens-ai/) [![Downloads](https://img.shields.io/pypi/dm/threatlens-ai.svg)](https://pypi.org/project/threatlens-ai/) [![Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/Carlos-Projects/threatlens) [![Docs](https://img.shields.io/badge/docs-github.io-blue.svg)](https://carlos-projects.github.io/threatlens/) **ThreatLens** 是一个专为 **AI/MCP 安全生态系统** 设计的威胁情报聚合与关联引擎。它从多个工具摄取安全信号,跨时间和攻击向量进行关联,结合外部威胁情报进行丰富,并生成可操作的告警和威胁报告。 ## 快速开始 ``` pip install threatlens-ai threatlens init # Create default config threatlens aggregate # Fetch signals from all sources threatlens serve # Start web dashboard at http://127.0.0.1:8080 ``` 或者使用 Docker: ``` docker compose up -d ``` ## 生态系统集成 | 来源 | 工具 | 信号 | |--------|------|---------| | MCPGuard | [mcpguard](https://github.com/Carlos-Projects/mcpguard) | Prompt injection、越狱、工具投毒、隐写、异常 | | MCPwn | [mcpwn](https://github.com/Carlos-Projects/mcpwn) | 注入测试、模糊测试、SSRF、SQLi、RCE、A2A 扫描器 | | Palisade Scanner | [palisade-scanner](https://github.com/Carlos-Projects/palisade-scanner) | 隐藏文本、隐写术、编码、数据泄露、指令分类器 | | AgentGate | [agentgate](https://github.com/Carlos-Projects/agentgate) | AI 用户代理、请求异常、蜜罐、策略违规 | | Reverse-Abliterate | [reverse-abliterate](https://github.com/Carlos-Projects/reverse-abliterate) | 模型安全扫描、abliteration 检测、权重清单 | | 外部 | CVEs、MITRE ATLAS、NVD | CVE 数据库、ATLAS 技术、安全公告 | ## 功能 - **信号聚合** — 从 5+ 个安全工具统一摄取 - **TTP 提取** — 基于证据的 TTP 提取 (arXiv:2605.25836) - **威胁关联** — 跨源事件关联以识别攻击活动 - **外部丰富** — CVE 查找、MITRE ATLAS 映射、IOC 丰富 - **告警生成** — 可配置的规则、去重和通知 - **威胁报告** — 定期(每日/每周/每月)和高管摘要报告 - **威胁情报源 API** — 用于消费丰富后威胁情报的 RESTful API - **Web 仪表盘** — 基于 HTMX 并具有实时更新功能的仪表盘 - **MCP 分类法** — 通过 [mcp-taxonomy](https://github.com/Carlos-Projects/mcp-taxonomy) 进行规范化分类 ## 安装 ``` pip install threatlens-ai ``` ### 从源码安装 ``` git clone https://github.com/Carlos-Projects/threatlens cd threatlens pip install -e ".[dev,web]" ``` ## 快速开始 ``` # 初始化 database 和 config threatlens init # 从所有已配置的 source 摄取 signal threatlens aggregate # 运行 correlation engine threatlens correlate # 生成 threat 报告 threatlens report --type daily # 启动 web dashboard threatlens serve --port 8080 # Consume threat feed threatlens feed --format json ``` ## 仪表盘 ![ThreatLens 仪表盘](https://static.pigsec.cn/wp-content/uploads/repos/cas/3a/3ae81c51936a270d0a1a1d19738266273ec616c6830bdf2f1fb631d7fe62fd6c.png) *仪表盘概览,显示系统统计数据、近期信号和告警。* ![信号浏览器](https://static.pigsec.cn/wp-content/uploads/repos/cas/cb/cbef44590dd6ed5ddf70f1cd711531a93152f5a6280e857d791c765f713b4c14.png) *浏览并过滤威胁信号,支持按严重程度、来源和类别进行标记。* ## CLI 参考 | 命令 | 描述 | |---------|-------------| | `threatlens init` | 初始化数据库和配置 | | `threatlens aggregate` | 从所有来源聚合信号 | | `threatlens correlate` | 运行关联引擎 | | `threatlens report` | 生成威胁报告 | | `threatlens serve` | 启动 Web 仪表盘 | | `threatlens feed` | 导出威胁情报源 | | `threatlens enrich` | 使用外部源丰富信号 | | `threatlens status` | 显示系统状态 | ## 架构 ``` ┌─────────────┐ ┌──────────┐ ┌────────────────┐ │ MCPGuard │ │ MCPwn │ │ Palisade Scan │ ├─────────────┤ ├──────────┤ ├────────────────┤ │ Events API │ │ Findings │ │ Scan Results │ └──────┬──────┘ └────┬─────┘ └───────┬────────┘ │ │ │ ▼ ▼ ▼ ┌──────────────────────────────────────────────┐ │ ThreatLens Engine │ │ │ │ ┌──────────┐ ┌───────────┐ ┌──────────┐ │ │ │ Aggregate │─▶│ Correlate │─▶│ Enrich │ │ │ └──────────┘ └───────────┘ └────┬─────┘ │ │ │ │ │ ┌──────────┐ ┌───────────┐ │ │ │ │ Alerts │◀─│ Reports │◀──────┘ │ │ └──────────┘ └───────────┘ │ └──────────────────────────────────────────────┘ │ │ │ ▼ ▼ ▼ ┌─────────────┐ ┌──────────┐ ┌────────────────┐ │ Dashboard │ │ Threat │ │ Notifications │ │ (FastAPI) │ │ Feed API │ │ (Email,TG,WH) │ └─────────────┘ └──────────┘ └────────────────┘ ``` ## 配置 ``` # ~/.threatlens/config.yaml database: path: ~/.threatlens/threatlens.db sources: mcpguard: enabled: true url: http://localhost:8081 mcpwn: enabled: true results_dir: ~/.mcpwn/results palisade: enabled: true url: http://localhost:8082 agentgate: enabled: true log_path: /var/log/agentgate/access.log abliterate: enabled: true scan_dir: ~/.reverse-abliterate/scans enrichment: cve: enabled: true nvd_api_key: "" atlas: enabled: true advisories: enabled: true alerts: rules: - name: critical-rce severity: critical correlation_min: 2 notify: [email, telegram] notifiers: email: smtp_host: smtp.gmail.com smtp_port: 587 telegram: bot_token: "" chat_id: "" reports: schedule: daily: true weekly: true monthly: true ``` ## API 启动服务器: ``` threatlens serve --host 0.0.0.0 --port 8080 ``` ### REST API 在服务器运行时,可在 [/docs](http://localhost:8080/docs) 查看交互式 API 文档(由 FastAPI OpenAPI/Swagger 提供支持)。 #### Endpoints | 方法 | 路径 | 描述 | |--------|------|-------------| | GET | `/api/v1/health` | 健康检查 | | GET | `/api/v1/signals` | 列出信号(分页) | | GET | `/api/v1/signals/{id}` | 获取信号详情 | | GET | `/api/v1/alerts` | 列出告警(分页) | | GET | `/api/v1/alerts/{id}` | 获取告警详情 | | GET | `/api/v1/campaigns` | 列出检测到的攻击活动 | | GET | `/api/v1/reports` | 列出生成的报告 | | GET | `/api/v1/reports/{id}` | 下载报告 | | GET | `/api/v1/feed` | 威胁情报源 (STIX/JSON) | | GET | `/api/v1/stats` | 聚合统计数据 | | POST | `/api/v1/ingest` | 摄取外部信号 | ## 开发 ``` # Lint ruff check src/ # Type check mypy src/ # Test with coverage python -m pytest tests/ -v --cov=threatlens # 运行所有检查 ruff check src/ && python -m pytest tests/ -v --cov=threatlens ``` ## 学术参考 - **TTPrint** — 通过“先发散后收敛”验证进行基于证据的 TTP 提取 ([arXiv:2605.25836](https://arxiv.org/abs/2605.25836)) - **CALIBURN** — 操作校准流式入侵检测的态势敏感性研究 ([arXiv:2605.24696](https://arxiv.org/abs/2605.24696)) - **KYA** — 面向自治系统的框架不可知信任层 ([arXiv:2605.25376](https://arxiv.org/abs/2605.25376)) ## License MIT
标签:AI安全, Chat Copilot, Python, 关联分析, 威胁情报, 安全规则引擎, 开发者工具, 无后门, 请求拦截, 逆向工具