YitzhakMaimon/intelligent-cyber-incident-analyst

GitHub: YitzhakMaimon/intelligent-cyber-incident-analyst

基于 n8n 与 Google Gemini 构建的自动化流水线,通过解析和富化网络安全日志文档来加速事件分诊与响应流程。

Stars: 0 | Forks: 0

# 智能云端文档分析师 🤖 一个 n8n + Google Gemini 自动化 pipeline,用于监控 Google Drive 文件夹中的传入文档,提取其文本,使用 Gemini AI 进行分析,通过自定义 FastAPI 微服务丰富结果,并将输出发布到 Google Sheets 和 Gmail。 **场景:** 网络安全事件日志 — 告警报告、SIEM 导出、漏洞扫描和事件工单。 ## 架构 ``` Google Drive n8n (Google Drive text extraction (PDF/DOCX) "incoming_docs" → Trigger/router) → folder │ ▼ Gemini API (summary, classification, sentiment, entities, action items) │ ▼ Metadata API (FastAPI enrichment) │ ┌─────────────────────────┼─────────────────────────┐ ▼ ▼ ▼ Google Sheets Google Drive "output_docs" Gmail (results database) (JSON + Markdown) (notification) ``` ## 组件 | 组件 | 描述 | |---|---| | **n8n workflow** (`n8n.json`) | 负责编排文件检测、路由、Gemini 调用、丰富处理和输出 | | **Metadata API** (`main.py`) | 用于文本提取和丰富逻辑的 FastAPI 微服务 | | **Google Gemini** | 用于摘要、分类、情感和实体提取的 LLM | | **Google Sheets** | 云端结果数据库(每个处理过的文档占一行) | | **Gmail** | 在文档处理完成时发送通知邮件 | ## Metadata API Endpoints | Endpoint | 描述 | |---|---| | `GET /health` | 健康检查 — 返回 `{"status": "ok"}` | | `GET /categories` | 列出可用的文档类别 | | `POST /sensitivity` | 基于关键词扫描将文本标记为 `confidential` 或 `internal` | | `POST /enrich` | 接收 Gemini 的输出并返回部门、敏感度、路由标签以及调整后的置信度分数 | | `POST /extract-pdf` | 从上传的 PDF 中提取文本 (PyMuPDF) | | `POST /extract-docx` | 从上传的 DOCX 中提取文本 (python-docx) | | `POST /delete-file` | 从本地 `incoming_docs/` 暂存目录中移除已处理的文件 | ## 设置 1. **安装依赖** python -m venv .venv .venv\Scripts\activate pip install -r requirements.txt 2. **运行 metadata API** uvicorn main:app --host 0.0.0.0 --port 8000 --reload 3. **启动 n8n (Docker)** docker run -d --name n8n --restart unless-stopped -p 5678:5678 \ -v n8n_data_fresh:/home/node/.n8n \ n8nio/n8n 然后在浏览器中打开 [http://localhost:5678](http://localhost:5678)。 4. **导入 n8n workflow** - 在 n8n UI 中,导入 `n8n.json` - 配置凭据:Gemini API key (HTTP Header Auth)、Google Drive OAuth2、Google Sheets OAuth2、Gmail OAuth2 - 将 Google Drive Trigger 指向您 Google Drive 中的 `incoming_docs` 文件夹 5. **将文档放入** Google Drive 中的 `incoming_docs` 文件夹,观察其流经 Gemini 分析、丰富处理、Google Sheets 和邮件通知的完整流程。 ## 技术栈 - **AI:** Google Gemini (`gemini-2.5-flash`) - **自动化:** n8n - **微服务:** Python 3.10+、FastAPI、PyMuPDF、python-docx - **存储:** Google Drive + Google Sheets API - **通知:** Gmail API (OAuth2)
标签:AI自动化, AV绕过, FastAPI, Gemini大模型, n8n, 请求拦截, 逆向工具