amittipare585858/BreakBot

GitHub: amittipare585858/BreakBot

BreakBot 是一个基于 Google Gemini 的全栈 AI 红队 Web 应用,通过自动生成并运行对抗性 pytest 测试来发现代码缺陷并提供修复建议。

Stars: 0 | Forks: 0

# BreakBot BreakBot 是一个全栈 AI 红队 Web 应用程序,它能够分析代码、生成对抗性的 pytest 测试用例,通过本地测试 pipeline 运行这些用例,并生成带有修复建议的 bug 攻击报告。 重构后的应用程序在 `api.py` 中使用 FastAPI 作为后端,并在 `index.html` 中使用纯 HTML/CSS/JS 作为前端。它不依赖于 Streamlit。 ## 技术栈 | 层级 | 技术 | | --- | --- | | 后端 | Python 3.11+ 和 FastAPI | | 前端 | 纯 HTML、CSS 和 JavaScript | | LLM | Google Gemini API | | 仓库获取 | GitHub REST API 和 raw.githubusercontent.com | | 测试运行器 | Python subprocess 和 pytest | | 报告 | Markdown 和 JSON | | 配置 | 通过 `python-dotenv` 加载的 `.env` | ## 设置 ``` cd D:\BreakBot_Complete python -m venv .venv .venv\Scripts\activate pip install -r requirements.txt ``` 在项目根目录下创建一个 `.env` 文件: ``` GEMINI_API_KEY=your_gemini_key_here ``` ## 运行 ``` uvicorn api:app --reload ``` 打开应用程序的地址: ``` http://127.0.0.1:8000 ``` ## 示例用例 1. 打开由 FastAPI 提供服务的 Web 应用程序。 2. 选择 `Paste Code`。 3. 粘贴一个脆弱的函数,例如: ``` def divide(a, b): return a / b ``` 4. 点击 `Analyze`。 5. 审查薄弱点。 6. 点击 `Generate Attack`。 7. 点击 `Run Full Report`。 8. 在 UI 中审查 Bug 攻击报告。 报告会自动保存: ``` reports/{repo_name}_{timestamp}.md reports/{repo_name}_{timestamp}.json ``` ## 架构 ``` +--------------------------+ | FastAPI api.py + index.html | +------------+-------------+ | +---------------+---------------+ | | +----------v----------+ +----------v----------+ | GitHub Repo Input | | Pasted Code Input | +----------+----------+ +----------+----------+ | | +---------------+---------------+ | +--------v--------+ | agent/ingester | +--------+--------+ | +--------v--------+ | agent/analyzer | +--------+--------+ | +--------v--------+ | agent/attacker | +--------+--------+ | +--------v--------+ | agent/runner | +--------+--------+ | +--------v--------+ | agent/reporter | +--------+--------+ | +-------------v-------------+ | reports/*.md + reports/*.json | +---------------------------+ ``` ## 项目结构 ``` agent/ analyzer.py # Gemini JSON analysis with fallback parsing attacker.py # Adversarial pytest generation fix_suggester.py # Fix suggestion generation ingester.py # GitHub repository ingestion reporter.py # Markdown/JSON reports runner.py # Subprocess pytest runner api.py # FastAPI backend index.html # Pure HTML/CSS/JS frontend requirements.txt # Runtime and dev dependencies ``` ## 安全性 BreakBot 会在 subprocess 中运行生成的测试,并且从不使用 `exec()` 或 `eval()` 来执行生成的测试代码。由于 subprocess 并不是一个完整的安全沙盒,因此在测试未知仓库时,请在一次性环境或 container 中运行 BreakBot。
标签:AI红队, AV绕过, FastAPI, Python, 多模态安全, 安全规则引擎, 数据可视化, 无后门, 逆向工具