magifd2/ai-ir

GitHub: magifd2/ai-ir

基于AI的Slack事件响应对话分析工具,自动生成事件摘要、活动报告和可复用的调查知识文档。

Stars: 0 | Forks: 0

# ai-ir:AI 驱动的 Incident Response 分析工具集 `ai-ir` 分析通过 [scat](https://github.com/magifd2/scat) 或 [stail](https://github.com/magifd2/stail) 导出的 Incident Response Slack 对话历史,以生成可操作的报告和可复用的知识。 ## 功能特性 - **事件摘要 (Incident Summary)** — AI 生成的时间线、根本原因和执行摘要 - **活动分析** — 针对每个参与者的方法、工具和发现的细分 - **角色推断** — 推断 IR 角色(Incident Commander、SME 等)及其关系 - **知识提取** — 将可复用的调查战术提取为 YAML 文档 - **翻译** — 将报告 JSON 翻译成另一种语言,同时保留技术内容 - **本地 Web UI** — 使用 `aiir serve` 浏览分析输出(只读,仅限 localhost) - **安全优先** — 内置 IoC 去敏(defanging)和 prompt 注入防御 ## 安装 需要 Python 3.11+ 和 [uv](https://docs.astral.sh/uv/)。 ``` git clone https://github.com/magifd2/ai-ir cd ai-ir uv sync ``` ## 配置 将 `.env.example` 复制到 `.env` 并配置你的 LLM endpoint: ``` cp .env.example .env # 编辑 .env 配置您的设置 ``` ``` AIIR_LLM_BASE_URL=https://api.openai.com/v1 AIIR_LLM_API_KEY=sk-... AIIR_LLM_MODEL=gpt-4o ``` 也可以直接设置环境变量,无需 `.env` 文件。 ## 使用方法 ### 导出 Slack 频道历史 ``` # 使用 stail stail export -c "#incident-response" --output incident.json # 使用 scat scat export log --channel "#incident-response" --output incident.json ``` ### 步骤 1:摄取与预处理 解析导出文件,对 IoC 进行去敏(defang),并检测 prompt 注入风险: ``` uv run aiir ingest incident.json -o incident.preprocessed.json ``` 默认输出到标准输出(支持管道操作): ``` uv run aiir ingest incident.json | uv run aiir summarize - ``` ### 步骤 2:生成分析 每个分析命令都接受原始导出文件或预处理后的文件: ``` # 生成事件摘要 (Markdown) uv run aiir summarize incident.json # 生成事件摘要 (JSON) uv run aiir summarize incident.json --format json -o summary.json # 分析每位参与者的活动 uv run aiir activity incident.json -o activity.md # 推断参与者角色与关系 uv run aiir roles incident.json -o roles.md # 生成完整报告 (JSON) 并同时将 tactics 保存为 YAML knowledge docs uv run aiir report incident.json --format json -o report.json -k ./knowledge/ # 生成完整报告 (Markdown) uv run aiir report incident.json -o report.md # 仅提取 tactics (无完整报告) uv run aiir report incident.json --knowledge-only -k ./knowledge/ ``` ### 完整流程示例 ``` # 预处理一次,然后运行所有分析 uv run aiir ingest incident.json -o preprocessed.json uv run aiir summarize preprocessed.json -o summary.md uv run aiir activity preprocessed.json -o activity.md uv run aiir roles preprocessed.json -o roles.md # 一步完成完整报告 + knowledge docs uv run aiir report preprocessed.json --format json -o report.json -k ./knowledge/ ``` ### 步骤 3:翻译报告(可选) 分析始终以英语执行以确保最大准确性。使用 `aiir translate` 生成报告 JSON 的本地化版本。技术内容(工具名称、命令、IOC、ID、标签)将保留英文。 ``` # 翻译为日语 — 将 report.ja.json 保存在 report.json 旁 uv run aiir translate report.json --lang ja # 支持的语言代码:ja, zh, ko, de, fr, es # 对于内置列表中没有的语言,接受任何 BCP-47 代码 uv run aiir translate report.json --lang zh -o report.zh.json ``` ### 在 Web UI 中浏览结果 生成报告和知识文档后,启动本地 Web UI: ``` # 提供当前目录服务 (递归扫描 report JSON 和 tactic YAML 文件) uv run aiir serve # 在自定义端口上提供特定目录服务 uv run aiir serve ./output --port 9000 # 启动时不自动打开浏览器标签页 uv run aiir serve --no-browser ``` 服务器仅绑定到 `127.0.0.1` 且为只读模式。在浏览器中打开 http://localhost:8765 查看仪表板。 ## 安全性 - **无外部传输**:仅配置的 LLM endpoint 接收数据 - **IoC 去敏 (Defanging)**:IPv4 地址、URL、域名、电子邮件和哈希值在传输到 LLM 之前会进行去敏处理 - **Prompt 注入防御**:所有 Slack 消息文本都包裹在 XML 标签中,并扫描注入模式 - **本地处理**:所有解析和预处理均在本地运行 有关详细的安全注意事项,请参阅 [docs/en/security.md](docs/en/security.md)。 ## 文档 - [Architecture](docs/en/architecture.md) / [アーキテクチャ](docs/ja/architecture.md) - [Data Format](docs/en/data-format.md) / [データフォーマット](docs/ja/data-format.md) - [Knowledge Format](docs/en/knowledge-format.md) / [ナレッジフォーマット](docs/ja/knowledge-format.md) - [Security](docs/en/security.md) / [セキュリティ](docs/ja/security.md) - [Maintenance](docs/en/maintenance.md) / [メンテナンス](docs/ja/maintenance.md) ## 开发 ``` # 安装 dev dependencies uv sync # 运行 tests uv run pytest tests/ -v # 运行 tests 并包含 coverage uv run pytest tests/ --cov=aiir --cov-report=term-missing ``` ## 许可证 MIT License
标签:DNS 反向解析, GPT-4, Homebrew安装, IoC脱敏, IR, PB级数据处理, Python, Slack导出, Web报告查看器, 人工智能, 协作安全, 大模型安全, 威胁情报, 子域名变形, 安全报告, 安全运维, 开发者工具, 摘要生成, 数据泄露, 无后门, 用户模式Hook绕过, 知识提取, 角色推断, 逆向工具