MG-Teban/multiplatform-access-review-agent
GitHub: MG-Teban/multiplatform-access-review-agent
一款面向企业的多云身份治理引擎,可跨 Azure、AWS、Google 自动化执行访问审查、风险评分与合规报告生成。
Stars: 0 | Forks: 0
# 多平台访问审查 Agent
## 概述
本平台可跨多个云身份提供商自动化执行 **Access Review**(访问审查)流程。它收集用户访问数据,将其与最小权限基线进行比对,检测异常情况,计算每位用户的风险评分,并生成符合审计要求的报告。
专为旨在满足 **ISO 27001**、**SOC 2** 和 **Australian Privacy Principles (APP)** 合规要求的企业环境而构建。
## 流水线
```
Collectors → Normalizer → Analyzer → Risk Engine → Report Engine → Output
```
| 阶段 | 职责 |
|---|---|
| **Collectors** | 从 Azure、AWS、Google 获取原始用户数据(含重试 + 超时机制) |
| **Normalizer** | 将特定于提供商的数据转换为统一的 `NormalizedUser` schema |
| **Analyzer** | 基线比对 + 异常检测(不活跃、未启用 MFA、已停用但仍有权限) |
| **Risk Engine** | 对每位用户进行 0–100 评分,划分为 LOW / MEDIUM / HIGH 等级 |
| **Report Engine** | 生成 JSON(审计就绪)+ CSV(供合规团队使用) |
## 风险评分
| 分数 | 等级 | 典型触发条件 |
|---|:---:|---|
| 60 – 100 | **HIGH** | 管理员未启用 MFA,已停用账号拥有活跃角色 |
| 30 – 59 | **MEDIUM** | 不活跃超过 90 天,权限高于基线 |
| 0 – 29 | **LOW** | 活跃用户,已启用 MFA,符合基线 |
### 评分规则
```
Admin role (no MFA) → +40 pts × 1.3 (admin multiplier)
Disabled + admin roles → +35 pts × 1.2 (disabled multiplier)
Inactive > 180 days → +30 pts
No MFA (non-admin) → +25 pts
Account never logged in → +25 pts
Excessive permissions → +20 pts
Baseline violation → +15–30 pts
─────────────────────────────────────────────
Cap: 100
```
## 架构
```
┌──────────────────────────────────────────────────────────┐
│ POST /review/run │
│ {"providers": ["azure","aws","google"]} │
└─────────────────────┬────────────────────────────────────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
AzureCollector AWSCollector GoogleCollector
(Graph API) (boto3 IAM) (Admin SDK)
│ │ │
└───────────┼───────────┘
▼
Normalizer Layer
(unified NormalizedUser)
│
┌───────────┴────────────┐
▼ ▼
BaselineComparator AnomalyDetector
(perms vs baseline) (inactivity, MFA, disabled)
│ │
└───────────┬────────────┘
▼
Risk Engine
(score + level + recs)
│
Report Engine
┌──────────┴──────────┐
▼ ▼
JSON Report CSV Report
(audit-ready) (compliance team)
│
┌──────┴──────┐
▼ ▼
Splunk ServiceNow
(HIGH risk (tickets for
events) HIGH users)
```
## API 参考
### `POST /review/run`
跨指定提供商运行完整的访问审查。
```
curl -X POST http://localhost:8000/review/run \
-H "Content-Type: application/json" \
-d '{
"providers": ["azure", "aws", "google"],
"use_mock": true
}'
```
**响应:**
```
{
"report_id": "f3a2b1c4-...",
"status": "completed",
"message": "Analysis completed. 4 HIGH risk users detected.",
"providers_scanned": ["azure", "aws", "google"],
"total_users_analyzed": 13,
"high_risk_users": 4,
"duration_seconds": 1.24
}
```
### `GET /report/{report_id}`
检索先前生成的报告。
```
curl http://localhost:8000/report/f3a2b1c4-...
```
**响应包含:**
- 执行摘要(风险分布、主要问题、统计数据)
- 按风险等级排序的完整用户列表
- 每位用户的详情:发现项、风险评分、建议
- 每项发现对应的合规标签(ISO 27001, SOC 2, APP)
### `GET /health`
```
curl http://localhost:8000/health
```
## 快速开始
### 本地设置
```
# 1. Clone
git clone https://github.com/MG-Teban/multiplatform-access-review-agent.git
cd multiplatform-access-review-agent
# 2. Virtual environment
python -m venv .venv && source .venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure
cp .env.example .env
# 设置 JWT_SECRET_KEY — 保留 USE_MOCK=true 以使用样本数据启动
# 5. Run
uvicorn main:app --reload
# 文档:http://localhost:8000/docs
```
### 使用模拟数据运行(无需云凭证)
```
curl -X POST http://localhost:8000/review/run \
-H "Content-Type: application/json" \
-d '{"providers": ["azure", "aws", "google"], "use_mock": true}'
```
模拟数据集包含涵盖所有风险配置的 13 位用户:
- 启用了 MFA 的正常活跃用户 → **LOW**
- 未启用 MFA 的管理员 → **HIGH**
- 不活跃超过 90 天 → **HIGH**
- 拥有管理员角色的已停用账号 → **HIGH**
- Service account (CI/CD) → **LOW**
### Docker
```
docker-compose up --build
```
### 运行测试
```
pytest -v
```
## 项目结构
```
├── app/
│ ├── api/routes/ # FastAPI endpoints
│ ├── collectors/ # Azure, AWS, Google + Mock
│ ├── normalizers/ # Per-provider normalizers + pipeline
│ ├── analyzers/ # Baseline comparator + anomaly detector
│ ├── risk/ # Scoring engine + configurable rules
│ ├── reports/ # JSON + CSV generators
│ ├── integrations/ # Splunk, ServiceNow
│ ├── models/ # NormalizedUser, UserRiskResult, ReviewReport
│ └── utils/ # Config, structured logging, retry
├── tests/
├── main.py
├── Dockerfile
└── .env.example
```
## 云提供商设置
### Azure Entra ID
1. 在 [Azure Portal → App registrations](https://entra.microsoft.com) 中注册一个应用
2. API permissions (application):`User.Read.All`、`Directory.Read.All`、`AuditLog.Read.All`
3. 设置 `AZURE_TENANT_ID`、`AZURE_CLIENT_ID`、`AZURE_CLIENT_SECRET`
### AWS IAM
1. 创建具有只读权限的 IAM user:`IAMReadOnlyAccess`、`AmazonCognitoReadOnly`
2. 设置 `AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY`
3. 生产环境:使用 IAM Roles 搭配 STS,而非静态密钥
### Google Workspace
1. 创建具有 Domain-Wide Delegation 权限的 Service Account
2. OAuth scope:`https://www.googleapis.com/auth/admin.directory.user.readonly`
3. 设置 `GOOGLE_SERVICE_ACCOUNT_FILE`、`GOOGLE_ADMIN_EMAIL`
## 合规覆盖
| 框架 | 控制项 |
|---|---|
| ISO 27001 | A.9.2 (User access management), A.9.4 (Access control), A.12.4 (Logging) |
| SOC 2 | CC6.1 (Logical access), CC6.3 (Access removal), CC7.2 (Monitoring) |
| Australian Privacy Principles | APP 11 (Security of personal information) |
## 技术栈
| 层级 | 技术 |
|---|---|
| API | FastAPI + Pydantic v2 |
| Azure | Microsoft Graph API (httpx) |
| AWS | boto3 IAM |
| Google | google-api-python-client (Admin SDK) |
| Async | asyncio + httpx |
| Logging | python-json-logger (structured JSON) |
| Testing | pytest + pytest-asyncio |
| Container | Docker + docker-compose |
*IAM Engineering 作品集的一部分 — 为企业环境中的 Cloud Security 角色而构建。*
标签:APP, AWS IAM, Azure AD, CIEM, CSPM, Google Workspace, IGA, ISO 27001, MFA 检测, SIEM 集成, SOC 2, TinkerPop, 不可变基础设施, 云安全态势管理, 企业安全, 前端应用, 审计报告, 幽灵账户, 异常检测, 最小权限, 权限管理, 权限蔓延, 构建工具, 模型越狱, 澳大利亚隐私原则, 网络资产管理, 自动化合规, 计算机取证, 访问审查, 请求拦截, 身份安全, 身份治理, 运行时操纵, 逆向工具, 风险评分