|
|
2 months ago | |
|---|---|---|
| .kiro | 2 months ago | |
| backend | 2 months ago | |
| frontend | 2 months ago | |
| .dockerignore | 2 months ago | |
| .gitignore | 3 months ago | |
| CREDENTIAL_UPDATE.md | 3 months ago | |
| DOCKER_DEPLOY.md | 2 months ago | |
| Dockerfile | 2 months ago | |
| QUICK_START.md | 2 months ago | |
| README.md | 2 months ago | |
| [Client Name]-[Project Name]-Project-Report-v1.0.docx | 2 months ago | |
| cloudshell_scanner.py | 2 months ago | |
| docker-compose.yml | 2 months ago | |
| regions.txt | 2 months ago | |
| test_cloudshell_scanner.py | 2 months ago |
一个全栈Web应用,用于扫描AWS账号中的资源信息,并按照Word模板生成专业的项目报告文档。系统支持多账号、多区域并行扫描,具有完整的用户权限管理、任务调度和报告管理功能。
git clone https://git.iaun.cn/iaun/cloud-reporter.git
cd cloud-reporter
mkdir sample-reports
# 复制报告模板到 sample-reports 文件夹
copy "[Client Name]-[Project Name]-Project-Report-v1.0.docx" sample-reports/
# Unix/Linux/macOS:
# cp "[Client Name]-[Project Name]-Project-Report-v1.0.docx" sample-reports/
# 进入后端目录
cd backend
# Windows用户
setup.bat
# Unix/Linux/macOS用户
chmod +x setup.sh && ./setup.sh
# 激活虚拟环境
# Windows:
activate_venv.bat
# Unix/Linux/macOS:
source activate_venv.sh
# 初始化数据库
python init_db.py
# 启动后端服务
python run.py
# 新开终端,进入后端目录并激活虚拟环境
cd backend
activate_venv.bat # Windows
# 或 source activate_venv.sh # Unix/Linux
# 启动Celery Worker
celery -A celery_worker.celery_app worker --loglevel=info --pool=solo
# 新开终端,进入前端目录
cd frontend
# Windows用户
setup.bat
# Unix/Linux/macOS用户
chmod +x setup.sh && ./setup.sh
# 启动前端服务
yarn dev
admin / admin123cloud-reporter/
├── backend/ # Python Flask后端
│ ├── app/ # 应用核心代码
│ │ ├── api/ # REST API路由
│ │ ├── models/ # 数据模型
│ │ ├── services/ # 业务逻辑服务
│ │ ├── scanners/ # AWS扫描器模块
│ │ │ ├── services/ # 各服务扫描器实现
│ │ │ └── DEVELOPMENT_GUIDE.md # 扫描器开发指南
│ │ ├── tasks/ # Celery异步任务
│ │ └── utils/ # 工具函数
│ ├── config/ # 配置文件
│ ├── migrations/ # 数据库迁移
│ ├── tests/ # 测试文件
│ ├── instance/ # 实例数据(数据库等)
│ ├── uploads/ # 上传文件存储
│ ├── reports/ # 生成的报告文件
│ └── requirements.txt # Python依赖
├── frontend/ # React前端
│ ├── src/ # 源代码
│ │ ├── components/ # React组件
│ │ ├── pages/ # 页面组件
│ │ ├── services/ # API服务
│ │ ├── contexts/ # React Context
│ │ └── utils/ # 工具函数
│ ├── public/ # 静态资源
│ └── package.json # 项目配置
├── sample-reports/ # 示例报告模板
├── .gitignore # Git忽略文件
└── README.md # 项目说明
# Flask配置
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key-here
# 数据库配置
DATABASE_URL=sqlite:///dev.db
# 生产环境使用PostgreSQL:
# DATABASE_URL=postgresql://user:password@localhost/dbname
# Celery配置
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/1
# 加密密钥
ENCRYPTION_KEY=your-encryption-key-here
# 文件存储
UPLOAD_FOLDER=uploads
REPORTS_FOLDER=reports
# API配置
VITE_API_BASE_URL=http://localhost:5000
# 应用配置
VITE_APP_TITLE=AWS Resource Scanner
VITE_DEBUG=true
| 角色 | 权限范围 |
|---|---|
| Admin | 系统全部权限:用户管理、凭证管理、所有报告、Worker管理 |
| Power User | 使用所有凭证、查看所有报告、创建扫描任务 |
| User | 仅使用分配的凭证、查看自己的报告、创建扫描任务 |
添加新的AWS服务扫描器时,请参考 扫描器开发指南,其中包含:
cd backend
# 激活虚拟环境
activate_venv.bat # Windows
source activate_venv.sh # Unix/Linux
# 启动开发服务器
python run.py
# 运行测试
pytest
# 数据库操作
python init_db.py --reset # 重置数据库
python init_db.py --with-demo # 创建示例数据
# 启动Celery Worker (必需,用于任务处理)
celery -A celery_worker.celery_app worker --loglevel=info --pool=solo
cd frontend
# 启动开发服务器
yarn dev
# 构建生产版本
yarn build
# 运行测试
yarn test
# 代码检查
yarn lint
# 类型检查
npx tsc --noEmit
POST /api/auth/login - 用户登录POST /api/auth/refresh - 刷新令牌POST /api/auth/logout - 用户登出GET /api/auth/me - 获取当前用户信息GET /api/users - 获取用户列表POST /api/users/create - 创建用户POST /api/users/update - 更新用户POST /api/users/delete - 删除用户GET /api/credentials - 获取凭证列表POST /api/credentials/create - 创建凭证POST /api/credentials/update - 更新凭证POST /api/credentials/delete - 删除凭证GET /api/tasks - 获取任务列表POST /api/tasks/create - 创建扫描任务GET /api/tasks/detail - 获取任务详情POST /api/tasks/delete - 删除任务GET /api/reports - 获取报告列表GET /api/reports/download - 下载报告POST /api/reports/delete - 删除报告GET /api/workers - 获取Worker列表和状态GET /api/workers/stats - 获取Worker统计信息POST /api/workers/purge - 清空任务队列POST /api/workers/revoke - 取消指定任务# 后端测试
cd backend
pytest
# 前端测试
cd frontend
yarn test
# 覆盖率测试
pytest --cov=app
yarn test --coverage
环境准备
# 安装PostgreSQL和Redis
sudo apt-get install postgresql redis-server
# 创建数据库
sudo -u postgres createdb aws_scanner
应用部署
# 设置生产环境变量
export FLASK_ENV=production
export DATABASE_URL=postgresql://user:pass@localhost/aws_scanner
# 安装依赖
pip install -r requirements.txt
# 数据库迁移
flask db upgrade
# 使用Gunicorn启动
gunicorn -w 4 -b 0.0.0.0:5000 run:app
Celery Worker
# 启动Celery Worker
celery -A celery_worker worker --loglevel=info --concurrency=4
# 构建生产版本
yarn build
# 部署到Nginx
sudo cp -r dist/* /var/www/html/
# 构建镜像
docker-compose build
# 启动服务
docker-compose up -d
除了完整的Web应用外,项目还提供了一个独立的CloudShell扫描脚本 cloudshell_scanner.py,可以直接在AWS CloudShell环境中运行,无需配置Access Key。
# 在AWS CloudShell中运行
# 扫描所有区域
python cloudshell_scanner.py
# 扫描指定区域
python cloudshell_scanner.py --regions us-east-1,ap-northeast-1
# 指定输出文件
python cloudshell_scanner.py --output my_scan.json
# 扫描指定服务
python cloudshell_scanner.py --services ec2,vpc,rds
与Web应用支持相同的30+AWS服务类型,包括VPC、EC2、RDS、S3、Lambda、EKS等。
扫描结果以JSON格式输出,可直接上传到Web应用生成报告。
虚拟环境问题
# 重新创建虚拟环境
python setup_venv.py --clean
数据库连接失败
# 检查数据库配置
python verify_setup.py
Celery Worker无法启动
# 检查Redis连接
redis-cli ping
# 确保使用正确的启动命令
celery -A celery_worker.celery_app worker --loglevel=info --pool=solo
依赖安装失败
# 清理并重新安装
yarn cache clean
rm -rf node_modules yarn.lock
yarn install
构建失败
# 检查TypeScript错误
npx tsc --noEmit
# 后端日志
tail -f backend/logs/app.log
# Celery日志
tail -f backend/logs/celery.log
# 前端开发日志
# 在浏览器开发者工具中查看
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)本项目采用MIT许可证 - 查看 LICENSE 文件了解详情。
如果您遇到问题或有疑问,请:
查看故障排除部分
AWS Resource Scanner - 让AWS资源管理变得简单高效 🚀