VasisthaVed/CloudGuard-AI
GitHub: VasisthaVed/CloudGuard-AI
这是一款集成 AI 大模型的 AWS 安全审计 CLI 工具,能够自动扫描云环境配置错误并生成通俗易懂的修复建议。
Stars: 0 | Forks: 0
# 🛡️ Cloudguard AI - AWS Security Auditor




一个开源的 Python CLI 工具,用于扫描 AWS 环境中的关键安全错误配置,并利用大语言模型 (LLM) 原生生成通俗易懂的解释和分步修复命令。
## 功能
| 扫描器 | 检查内容 | 严重性 |
|---------|---------------|----------|
| **S3 存储桶** | 公开访问阻止、默认加密 (SSE)、版本控制 | Critical / High / Medium |
| **安全组** | 对 `0.0.0.0/0` 或 `::/0` 开放的入站规则(标记 SSH/RDP) | Critical / High |
| **IAM** | Root MFA、用户 MFA、访问密钥期限(>90 天)、AdministratorAccess | Critical / High |
**支持的 AI 提供商:**
- **OpenRouter**(默认)- 支持多种**免费**模型,无需信用卡
- **Anthropic Claude** - 需要付费 API key
**其他功能:**
- 风险评分计算(Critical x10 + High x5 + Medium x2)
- 通过 `rich` 实现的彩色终端输出
- 带时间戳的 JSON 报告导出
- 用于在无 AWS 凭证情况下测试的 Mock 模式
- 在将发现发送给 AI 之前进行数据清理(去除账户 ID 和 ARN)
## 环境要求
- Python 3.8+
- (可选)已配置 AWS CLI
- OpenRouter(免费)或 Anthropic 的 API key
## 快速开始
```
# 1. 安装依赖
pip install -r requirements.txt
# 2. 复制 env 模板并添加你的 API key
cp .env.example .env
# 编辑 .env 文件并填入你的 OPENROUTER_API_KEY
# 3. 运行
python main.py
# 4. 运行测试
python -m pytest tests/ -v
```
## 配置
### `.env` 文件
```
# 选择:"anthropic" 或 "openrouter"
AI_PROVIDER=openrouter
# 在 https://openrouter.ai 获取免费 key(无需信用卡)
OPENROUTER_API_KEY=your-key-here
# 免费模型选项(任选其一):
# meta-llama/llama-3.3-70b-instruct:free
# google/gemma-3-27b-it:free
# deepseek/deepseek-r1:free
# qwen/qwen3-next-80b:free
# mistralai/mistral-small-3.1-24b-instruct:free
# nvidia/llama-3.1-nemotron-70b-instruct:free
OPENROUTER_MODEL=meta-llama/llama-3.3-70b-instruct:free
```
### AWS 凭证(可选)
```
aws configure
```
如果未找到 AWS 凭证,CloudGuard AI 将自动回退到带有示例发现的 **mock 模式**。
## 安全性
- API key 从 `.env` 加载(从不硬编码)
- `.gitignore` 防止提交 `.env` 和扫描报告
- 在发送到 AI API 之前,发现会被**清理**(AWS 账户 ID 和 ARN 被编辑)
- 报告仅保存在本地
## 示例输出
```
+---------------------------------------------------------------+
| ____ _ _ ____ _ |
| / ___| | ___ _ _ __| |/ ___|_ _ __ _ _ __ __| | |
| | | | |/ _ \| | | |/ _` | | _| | | |/ _` | '__/ _` | |
| | |___| | (_) | |_| | (_| | |_| | |_| | (_| | | | (_| | |
| \____|_|\___/ \__,_|\__,_|\____|\__,_|\__,_|_| \__,_| |
| AWS Security Auditor |
+---------------------------------------------------------------+
Starting CloudGuard AI scan...
Scanning Mock AWS Environment...
Found 5 potential misconfigurations in mock data.
+------------- AI Advisor --------------+
| Provider: openrouter |
| model: llama-3.3-70b-instruct:free |
+---------------------------------------+
[1/5] s3-bucket-customer-data - Public Read Access Enabled
[Advice Generated]
[2/5] s3-logs-archive - No default encryption
[Advice Generated]
...
Findings Summary
+------------------+
| Severity | Count |
|----------+-------|
| Critical | 2 |
| High | 2 |
| Medium | 1 |
| Low | 0 |
+------------------+
Overall Risk Score: 32
Scan complete. Report saved to cloudguard_report_20260411_141320.json
```
## 截图
## 项目结构
```
CloudGuard_ai/
main.py Entry point - banner, orchestrates all phases
scanner.py AWS scanning (S3, Security Groups, IAM) + mock mode
ai_advisor.py AI remediation (OpenRouter / Anthropic)
report.py JSON report + summary table + risk score
requirements.txt Python dependencies
.env.example Template for API keys
.gitignore Keeps secrets and reports out of git
tests/
test_scanner.py 14 unit tests (pytest)
.github/
workflows/ci.yml GitHub Actions CI pipeline
README.md This file
GUIDE.md Personal walkthrough for understanding the code
```
## 测试
14 个单元测试涵盖:
- Mock 发现格式验证(正确的键、有效的严重性)
- AWS 连接 mock 回退
- 数据清理(账户 ID + ARN 编辑)
- 风险评分计算公式
- JSON 报告输出完整性
```
python -m pytest tests/ -v
```
每次 push/PR 时,测试也会通过 GitHub Actions CI 自动运行。
## 未来规划
| 功能 | 描述 |
|---------|-------------|
| **AI 对比** | 通过多个 AI 模型运行发现,并排对比建议,构建置信度评分 |
| **聊天模式** | 对话式追问:“为什么这是关键问题?”,“显示修复命令” |
| **Web 仪表板** | Flask/Streamlit UI,配备可筛选表格、风险仪表盘、历史趋势、PDF 导出 |
| **自动修复** | AI 生成可运行的 AWS CLI 命令,一键确认应用 |
| **计划扫描** | Cron/任务调度器,与上次扫描对比,针对新的 Critical 发现发送 Slack/邮件警报 |
| **多云** | Azure + GCP 扫描器支持 |
| **合规性** | 将发现映射到 CIS Benchmarks、SOC 2、PCI-DSS |
请参阅 [GUIDE.md](GUIDE.md) 了解每个功能构思的详细说明。
## 项目结构
```
CloudGuard_ai/
main.py Entry point - banner, orchestrates all phases
scanner.py AWS scanning (S3, Security Groups, IAM) + mock mode
ai_advisor.py AI remediation (OpenRouter / Anthropic)
report.py JSON report + summary table + risk score
requirements.txt Python dependencies
.env.example Template for API keys
.gitignore Keeps secrets and reports out of git
tests/
test_scanner.py 14 unit tests (pytest)
.github/
workflows/ci.yml GitHub Actions CI pipeline
README.md This file
GUIDE.md Personal walkthrough for understanding the code
```
## 测试
14 个单元测试涵盖:
- Mock 发现格式验证(正确的键、有效的严重性)
- AWS 连接 mock 回退
- 数据清理(账户 ID + ARN 编辑)
- 风险评分计算公式
- JSON 报告输出完整性
```
python -m pytest tests/ -v
```
每次 push/PR 时,测试也会通过 GitHub Actions CI 自动运行。
## 未来规划
| 功能 | 描述 |
|---------|-------------|
| **AI 对比** | 通过多个 AI 模型运行发现,并排对比建议,构建置信度评分 |
| **聊天模式** | 对话式追问:“为什么这是关键问题?”,“显示修复命令” |
| **Web 仪表板** | Flask/Streamlit UI,配备可筛选表格、风险仪表盘、历史趋势、PDF 导出 |
| **自动修复** | AI 生成可运行的 AWS CLI 命令,一键确认应用 |
| **计划扫描** | Cron/任务调度器,与上次扫描对比,针对新的 Critical 发现发送 Slack/邮件警报 |
| **多云** | Azure + GCP 扫描器支持 |
| **合规性** | 将发现映射到 CIS Benchmarks、SOC 2、PCI-DSS |
请参阅 [GUIDE.md](GUIDE.md) 了解每个功能构思的详细说明。标签:AWS, Botocore, C2, CLI, DevSecOps, DLL 劫持, DPI, IAM, LLM, Python, S3, Unmanaged PE, WiFi技术, 上游代理, 二进制发布, 人工智能, 大语言模型, 安全组, 开源工具, 无后门, 漏洞修复, 生成式AI, 用户模式Hook绕过, 索引, 网络安全培训, 逆向工具, 风险评分