forked from pu8crm6xf/analysiscode
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
1 month ago | |
|---|---|---|
| .. | ||
| .idea | 3 months ago | |
| bandit-main/bandit-main | 3 months ago | |
| config | 1 month ago | |
| flake8-main/flake8-main | 3 months ago | |
| frontend | 1 month ago | |
| node_modules | 1 month ago | |
| pylint-main | 3 months ago | |
| rule | 2 months ago | |
| server | 1 month ago | |
| .gitignore | 2 months ago | |
| Ollama部署指南.md | 1 month ago | |
| README.md | 2 months ago | |
| backend.js | 1 month ago | |
| package-lock.json | 1 month ago | |
| package.json | 1 month ago | |
| requirements.txt | 2 months ago | |
| start_server.bat | 1 month ago | |
| start_server.sh | 2 months ago | |
| 创新点说明.md | 1 month ago | |
| 快速开始指南.md | 2 months ago | |
| 清理说明.md | 1 month ago | |
| 研究背景.md | 1 month ago | |
| 项目功能说明.md | 1 month ago | |
README.md
FortifyCode - 基于多Agent协同的军工Python代码合规性检查系统
项目简介
FortifyCode 是一个集成了多个代码质量检查工具(Pylint、Flake8、Bandit)的 Web 应用,专为军工 Python 代码合规性检查而设计。
功能特性
- ✅ 多工具协同检查:整合 Pylint、Flake8、Bandit 三大代码检查工具
- ✅ 可视化界面:直观的 Web 界面,实时显示检查进度和结果
- ✅ 项目管理:支持创建、管理多个代码检查项目
- ✅ 文件浏览器:在线浏览和编辑项目文件
- ✅ 智能分类:自动分类错误、警告和信息级别的问题
- ✅ 多种来源:支持 GitHub、Gitee 克隆或直接文件上传
技术栈
前端
- HTML5 + CSS3 + JavaScript (原生)
- Font Awesome 图标库
- 响应式设计
后端
- Node.js + Express
- Multer (文件上传)
- CORS (跨域支持)
代码检查工具
- Pylint: Python 代码质量和风格检查
- Flake8: PEP 8 编码规范检查
- Bandit: 安全漏洞扫描
系统要求
- Node.js >= 14.0
- Python >= 3.7
- npm 或 yarn 包管理器
安装步骤
1. 克隆项目
git clone <repository-url>
cd FortifyCode_guoning/src
2. 安装 Node.js 依赖
npm install
3. 安装 Python 检查工具
pip install pylint flake8 bandit
或者使用 requirements.txt(如果提供):
pip install -r requirements.txt
运行项目
Windows 系统
双击运行 start_server.bat 或在命令行中执行:
start_server.bat
Linux/Mac 系统
chmod +x start_server.sh
./start_server.sh
手动启动
node backend.js
访问系统
启动成功后,在浏览器中访问:
- 前端界面: http://localhost:5000
- API 接口: http://localhost:5000/api
使用说明
快捷代码检查
- 点击上传区域或拖拽 Python 文件(.py, .pyx, .pyi)
- 点击"开始检查"按钮
- 等待检查完成,查看结果
项目管理
- 进入"项目管理"页面
- 点击"新建项目"
- 选择项目来源(GitHub、Gitee 或文件上传)
- 填写项目信息并创建
- 在项目详情页面进行代码检查和文件管理
查看检查结果
检查完成后,结果会显示在页面下方,包括:
- 问题总数统计
- 错误、警告、信息分类
- 具体问题位置(文件、行号、列号)
- 问题描述和修复建议
API 接口文档
文件上传
POST /api/upload
Content-Type: multipart/form-data
参数:
- files: 文件数组
响应:
{
"success": true,
"data": {
"temp_path": "临时目录路径",
"files": ["文件列表"]
}
}
代码检查
POST /api/check
Content-Type: application/json
参数:
{
"temp_path": "临时目录路径"
}
响应:
{
"success": true,
"data": {
"tools_status": {...},
"all_issues": [...],
"total_issues": 数量,
"error_count": 数量,
"warning_count": 数量,
"info_count": 数量
}
}
项目管理
GET /api/projects - 获取所有项目
POST /api/projects - 创建新项目
GET /api/projects/:id - 获取项目详情
DELETE /api/projects/:id - 删除项目
POST /api/projects/:id/check - 运行项目检查
更多 API 详情请查看 view/API.md
项目结构
src/
├── backend.js # 后端服务器主文件
├── frontend/ # 前端文件
│ ├── index.html # 主页面
│ ├── css/
│ │ └── style.css # 样式文件
│ └── js/
│ └── app.js # 前端逻辑
├── projects_data/ # 项目数据存储目录(自动创建)
├── out/ # 检查报告输出目录
├── start_server.bat # Windows 启动脚本
├── start_server.sh # Linux/Mac 启动脚本
├── package.json # Node.js 依赖配置
└── README.md # 本文档
常见问题
Q: 提示找不到 Python 模块?
A: 确保已正确安装 pylint、flake8 和 bandit:
pip install pylint flake8 bandit
Q: 端口 5000 被占用?
A: 修改 backend.js 中的 PORT 变量,或设置环境变量:
PORT=8080 node backend.js
Q: 文件上传失败?
A: 检查以下几点:
- 文件大小不超过 100MB
- 文件格式为 .py, .pyx, .pyi
- 临时目录有写入权限
Q: 检查工具报错?
A: 确保 Python 和检查工具在系统 PATH 中:
python -m pylint --version
python -m flake8 --version
python -m bandit --version
开发说明
修改端口
编辑 backend.js:
const PORT = process.env.PORT || 5000; // 修改为其他端口
添加新的检查工具
在 backend.js 的 TOOL_CONFIG 中添加配置:
newtool: {
command: '命令',
args: (filePath) => `参数 ${filePath}`,
parseResult: (stdout) => {
// 解析逻辑
return issues;
}
}
贡献指南
欢迎提交 Issue 和 Pull Request!
许可证
本项目采用 MIT 许可证。
联系方式
如有问题或建议,请联系项目维护者。
注意: 本系统用于代码质量检查,不应替代人工代码审查。建议结合实际项目需求和编码规范使用。