AdamMostofi/codesentinel

GitHub: AdamMostofi/codesentinel

一款面向 Python 项目的 AI 辅助安全扫描工具,整合 Bandit 和 Safety 进行漏洞检测,并提供智能修复建议。

Stars: 0 | Forks: 0

# CodeSentinel 一款 AI 驱动的安全漏洞扫描器,用于分析代码库并提供智能修复指导。 ![CodeSentinel](https://img.shields.io/badge/CodeSentinel-Security%20Scanner-green) ![Next.js](https://img.shields.io/badge/Next.js-14-blue) ![FastAPI](https://img.shields.io/badge/FastAPI-Python-orange) ## 🚀 概述 CodeSentinel 是一款基于 Web 的安全扫描工具,旨在帮助开发者识别其 Python 代码库中的漏洞。它结合了行业标准的工具(Bandit, Safety)与 AI 驱动的修复建议,帮助开发者快速修复安全问题。 ## 🎯 功能特性 - **自动化安全扫描** - 使用 Bandit 扫描 Python 代码中的漏洞 - **依赖分析** - 使用 Safety 检查易受攻击的依赖项 - **AI 驱动的修复建议** - 由 Groq LLM 提供支持的智能修复建议 - **风险评分** - 具有严重程度细分的可视化风险评估(0-100) - **扫描历史** - 跟踪和查看过去的扫描记录 - **现代化 UI** - 具有实时进度指示器的暗色主题界面 ## 🛠️ 技术栈 ### 前端 - **Next.js 14** - 带有 App Router 的 React 框架 - **Tailwind CSS** - 实用优先的 CSS 框架 - **Recharts** - 用于漏洞图表的数据可视化 - **Framer Motion** - 流畅的动画 - **Lucide React** - 图标库 ### 后端 - **FastAPI** - 现代化的 Python Web 框架 - **SQLAlchemy** - SQL 数据库工具包 - **SQLite** - 轻量级数据库 - **Bandit** - Python 安全 Linter - **Safety** - Python 依赖项安全检查器 - **Groq SDK** - 用于 AI 修复的 LLM 集成 ## 📸 截图 ### 着陆页 - 以安全为核心的暗色主题 UI - 拖放文件上传 - 实时连接状态 ### 结果仪表板 - 风险评分仪表(0-100) - 按严重程度划分的漏洞细分 - 带有详细信息的可展开漏洞卡片 ## 🚦 快速开始 ### 前置条件 - Node.js 18+ - Python 3.12+ - Git ### 安装说明 1. **克隆仓库** ``` git clone https://github.com/AdamMostofi/codesentinel.git cd codesentinel ``` 2. **设置后端** ``` cd backend python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt # 创建 .env file echo "GROQ_API_KEY=your_groq_api_key" > .env ``` 3. **设置前端** ``` cd frontend npm install ``` ### 运行应用程序 1. **启动后端** ``` cd backend source venv/bin/activate python -m app.main ``` 后端运行于:http://localhost:8000 2. **启动前端** ``` cd frontend npm run dev ``` 前端运行于:http://localhost:3000 3. **在浏览器中打开** 访问 http://localhost:3000 ### 使用扫描器 1. 准备一个包含您 Python 项目的 `.zip` 文件 2. 将 zip 文件拖放到上传区域 3. 等待扫描完成 4. 查看漏洞和 AI 驱动的修复建议 5. 使用扫描历史随时间跟踪改进情况 ## 📁 项目结构 ``` codesentinel/ ├── frontend/ # Next.js frontend │ ├── src/ │ │ ├── app/ # Pages and components │ │ ├── lib/ # API utilities │ │ └── styles/ # Global styles │ └── package.json │ ├── backend/ # FastAPI backend │ ├── app/ │ │ ├── api/ # API routes │ │ ├── core/ # Configuration │ │ ├── models/ # Database models │ │ └── services/ # Business logic │ └── requirements.txt │ ├── .gitignore └── README.md ``` ## 🔧 API 端点 | Method | Endpoint | Description | |--------|----------|-------------| | POST | `/api/scan` | 上传 zip 文件并开始扫描 | | GET | `/api/scans` | 列出所有扫描 | | GET | `/api/scan/{id}` | 获取扫描详情 | | DELETE | `/api/scan/{id}` | 删除扫描 | | GET | `/health` | 健康检查 | ## 🐛 已知问题 - 扫描历史最初返回了错误的数据结构(在后续提交中已修复) - AI 修复功能需要 Groq API key ## 📝 许可证 本项目仅供教育目的使用。 ## 👤 作者 - GitHub: [AdamMostofi](https://github.com/AdamMostofi) ## 🙏 致谢 - [Bandit](https://bandit.readthedocs.io/) - 安全 Linting - [Safety](https://safety.pyup.io/) - 依赖检查 - [Groq](https://groq.com/) - 用于 AI 修复的 LLM API - [Next.js](https://nextjs.org/) - 前端框架 - [FastAPI](https://fastapi.tiangolo.com/) - 后端框架
标签:AI安全扫描, AV绕过, Bandit, DNS 反向解析, FastAPI, Python漏洞检测, Safety, SQLAlchemy, Web安全, 代码安全, 代码审计工具, 依赖安全检查, 开发安全, 开源安全工具, 漏洞修复建议, 漏洞枚举, 网络安全, 自定义脚本, 蓝队分析, 逆向工具, 逆向工程平台, 错误基检测, 隐私保护, 静态代码分析, 风险评分