chetangajbe/iam-incident-response-playbook
GitHub: chetangajbe/iam-incident-response-playbook
为 SailPoint 企业 IAM 环境提供自动化连接器故障诊断、事件分级和修复 Runbook 的综合事件响应框架,帮助 SOC 团队显著降低高优事件的平均解决时间。
Stars: 0 | Forks: 0
# 企业 IAM 事件响应手册
一个基于 Python 的综合事件响应框架,专为 SailPoint IAM 环境设计,旨在为 SOC 团队标准化连接器故障处理流程。该框架通过自动化诊断、标准化工作流和集成修复功能,将 P1/P2 事件的平均解决时间(MTTR)缩短了 20%。
## 🎯 核心功能
- **标准化连接器故障框架**:在 SOC 范围内采用统一的响应流程
- **MTTR 降低 20%**:针对 P1/P2 事件优化的检测与修复工作流
- **自动化诊断**:实时 SailPoint 连接器健康监控
- **事件分类**:智能严重性评估与分类
- **Runbook 自动化**:具备回滚能力的分步修复
- **审计追踪**:用于合规及事后分析的综合日志
- **集成就绪**:兼容 Slack、PagerDuty、ServiceNow 和 SIEM
## 📋 目录
- [要求](#requirements)
- [安装](#installation)
- [配置](#configuration)
- [用法](#usage)
- [项目结构](#project-structure)
- [核心模块](#core-modules)
- [事件分类](#incident-classification)
- [贡献](#contributing)
- [许可证](#license)
## 📦 要求
- Python 3.8+
- SailPoint IdentityIQ 或 IdentityNow API 访问权限
- Elasticsearch(可选,用于事件存储)
- Redis(可选,用于缓存)
有关所有 Python 依赖项,请参见 `requirements.txt`。
## 🚀 安装
### 1. 克隆仓库
```
git clone https://github.com/yourusername/iam-incident-response-playbook.git
cd iam-incident-response-playbook
```
### 2. 创建虚拟环境
```
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
### 3. 安装依赖项
```
pip install -r requirements.txt
```
### 4. 配置环境
```
cp .env.example .env
# 使用你的 SailPoint 凭证和 API 端点编辑 .env
```
### 5. 运行初始设置
```
python setup.py
```
## ⚙️ 配置
### 环境变量 (.env)
```
# SailPoint 配置
SAILPOINT_API_URL=https://your-instance.api.identitynow.com
SAILPOINT_CLIENT_ID=your_client_id
SAILPOINT_CLIENT_SECRET=your_client_secret
# Incident Management
INCIDENT_LOG_DIR=./logs/incidents
MAX_CONCURRENT_INCIDENTS=10
INCIDENT_RETENTION_DAYS=90
# Integrations
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
PAGERDUTY_API_KEY=your_pagerduty_api_key
SERVICENOW_INSTANCE=https://your-instance.service-now.com
# Redis 配置 (可选)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
```
### SailPoint 连接器映射
请使用您的连接器详细信息更新 `config/connector_mappings.json`:
```
{
"connectors": {
"active_directory": {
"critical": true,
"sla_minutes": 30,
"escalation_threshold": 15
},
"okta": {
"critical": true,
"sla_minutes": 45,
"escalation_threshold": 20
}
}
}
```
## 📖 用法
### 快速入门
```
from iam_incident_response import IncidentResponseEngine, SailPointConnector
# 初始化 engine
engine = IncidentResponseEngine()
# Monitor connector
sailpoint = SailPointConnector()
status = sailpoint.get_connector_status("active_directory")
# 检测到时处理 incident
if not status['healthy']:
incident = engine.create_incident(
connector_id="active_directory",
severity="P1",
error_message=status['error']
)
remediation = engine.execute_remediation(incident)
```
### CLI 界面
```
# 检查 connector 状态
python -m iam_incident_response.cli status active_directory
# 手动创建 incident
python -m iam_incident_response.cli incident create --connector=okta --severity=P1
# 列出活跃的 incidents
python -m iam_incident_response.cli incident list --status=open
# 执行 runbook
python -m iam_incident_response.cli runbook execute --incident-id=INC-001
```
### REST API
启动 API 服务器:
```
python -m iam_incident_response.api --port=8000
```
端点:
- `GET /api/v1/incidents` - 列出事件
- `POST /api/v1/incidents` - 创建事件
- `GET /api/v1/incidents/{id}` - 获取事件详情
- `POST /api/v1/incidents/{id}/remediate` - 执行修复
- `GET /api/v1/connectors/status` - 获取所有连接器状态
## 📁 项目结构
```
iam-incident-response-playbook/
├── iam_incident_response/
│ ├── __init__.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── engine.py # Main incident response engine
│ │ ├── classifier.py # Incident classification logic
│ │ └── remediation.py # Automated remediation execution
│ ├── integrations/
│ │ ├── __init__.py
│ │ ├── sailpoint.py # SailPoint API integration
│ │ ├── slack.py # Slack notifications
│ │ ├── pagerduty.py # PagerDuty escalation
│ │ ├── servicenow.py # ServiceNow ticket creation
│ │ └── siem.py # SIEM event forwarding
│ ├── models/
│ │ ├── __init__.py
│ │ ├── incident.py # Incident data model
│ │ ├── remediation.py # Remediation data model
│ │ └── connector.py # Connector status model
│ ├── database/
│ │ ├── __init__.py
│ │ ├── models.py # SQLAlchemy ORM models
│ │ └── client.py # Database connection manager
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── logger.py # Structured logging
│ │ ├── validators.py # Input validation
│ │ ├── exceptions.py # Custom exceptions
│ │ └── decorators.py # Retry, timeout, caching
│ ├── cli.py # Command-line interface
│ └── api.py # REST API server
├── config/
│ ├── __init__.py
│ ├── settings.py # Configuration management
│ ├── runbooks/ # Incident runbooks (YAML)
│ │ ├── connector_failure.yaml
│ │ ├── permission_sync_failure.yaml
│ │ └── auth_failure.yaml
│ └── connector_mappings.json # Connector configuration
├── tests/
│ ├── __init__.py
│ ├── unit/
│ │ ├── test_engine.py
│ │ ├── test_classifier.py
│ │ └── test_remediation.py
│ ├── integration/
│ │ └── test_sailpoint_integration.py
│ └── conftest.py # Pytest fixtures
├── logs/
│ └── incidents/ # Incident logs directory
├── docs/
│ ├── ARCHITECTURE.md # System architecture
│ ├── RUNBOOKS.md # Detailed runbook documentation
│ ├── API_REFERENCE.md # API documentation
│ └── TROUBLESHOOTING.md # Troubleshooting guide
├── examples/
│ ├── basic_usage.py # Basic usage examples
│ ├── advanced_automation.py # Advanced scenarios
│ └── integration_examples.py # Integration examples
├── .env.example
├── .gitignore
├── requirements.txt
├── setup.py
├── pytest.ini
└── README.md
```
## 🏗️ 核心模块
### Engine (`core/engine.py`)
管理事件生命周期的中央编排引擎:
- 事件创建与跟踪
- Runbook 执行
- 状态监控
- 升级管理
### Classifier (`core/classifier.py`)
智能事件严重性和类型分类:
- 连接器故障检测
- 权限同步问题
- 身份验证失败
- 自定义规则引擎
### Remediation (`core/remediation.py`)
具有回滚功能的自动化修复执行:
- 预检查
- 分步执行
- 验证与核实
- 失败时回滚
### SailPoint 集成 (`integrations/sailpoint.py`)
完整的 SailPoint API 封装:
- 连接器健康监控
- 账户/身份操作
- 认证管理
- 审计事件检索
## 📊 事件分类
事件将自动分类为以下严重级别:
| 严重级别 | 响应时间 | 升级 | 示例 |
|----------|---------------|-----------|----------|
| P1 | 15 分钟 | 立即 | 关键连接器宕机,身份验证失败 |
| P2 | 30 分钟 | 15 分钟升级 | 同步缓慢,部分故障 |
| P3 | 2 小时 | 1 小时升级 | 轻微问题,警告 |
| P4 | 下一个工作日 | 手动 | 信息事件 |
## 📈 指标与监控
该框架跟踪以下关键指标:
- **MTTR**(平均解决时间)
- **MTTD**(平均检测时间)
- **事件数量**(按类型和严重程度)
- **修复成功率**
- **误报率**
- **SLA 合规性**
查看指标仪表板:
```
python -m iam_incident_response.metrics --port=8001
```
## 🔄 工作流示例
```
Connector Failure Detected
↓
Incident Created (Auto-assigned)
↓
Classification (Severity Assessment)
↓
Notifications Sent (Slack, PagerDuty)
↓
Runbook Execution (Automated Remediation)
↓
Validation & Verification
↓
Incident Resolution / Escalation
↓
Post-Incident Analysis & Logging
```
## 🧪 测试
运行测试套件:
```
# 所有测试
pytest
# 仅 Unit tests
pytest tests/unit/
# Integration tests
pytest tests/integration/
# 包含覆盖率
pytest --cov=iam_incident_response tests/
```
## 📚 文档
- **[架构](docs/ARCHITECTURE.md)** - 系统设计与组件
- **[Runbook](docs/RUNBOOKS.md)** - 详细的修复流程
- **[API 参考](docs/API_REFERENCE.md)** - 完整的 API 文档
- **[故障排除](docs/TROUBLESHOOTING.md)** - 常见问题与解决方案
## 🔌 集成示例
### Slack 通知
向 Slack 自动发送事件警报:
```
from iam_incident_response.integrations import SlackNotifier
notifier = SlackNotifier()
notifier.notify_incident(incident, severity="P1")
```
### PagerDuty 升级
自动创建 PagerDuty 事件:
```
from iam_incident_response.integrations import PagerDutyEscalator
escalator = PagerDutyEscalator()
escalator.create_incident(incident, urgency="high")
```
### ServiceNow 工单
自动在 ServiceNow 中创建工单:
```
from iam_incident_response.integrations import ServiceNowIntegration
snow = ServiceNowIntegration()
ticket = snow.create_incident_ticket(incident)
```
## 📊 性能改进
**实施前:**
- P1 事件 MTTR:45-60 分钟
- MTTD:10-15 分钟
- 手动创建事件:5-10 分钟
**实施后:**
- P1 事件 MTTR:36-48 分钟 ✅(降低 20%)
- MTTD:2-3 分钟(自动监控)
- 创建事件:< 30 秒(自动化)
## 🔒 安全与合规
- **审计日志**:所有操作均记录日志并带有时间戳
- **RBAC**:基于角色的事件访问控制
- **加密**:所有 API 通信使用 TLS
- **密钥管理**:环境变量与凭据保管库集成
- **合规性**:满足 SOC 2、HIPAA、PCI-DSS 要求
## 📝 许可证
本项目基于 MIT 许可证授权 - 详见 [LICENSE](LICENSE) 文件。
## 👥 支持
- **文档**:参见 `/docs` 目录
- **问题**:GitHub Issues
- **邮箱**:support@example.com
- **Slack**:#iam-incident-response
## 🚦 路线图
- [ ] 基于机器学习的事件预测
- [ ] 高级 SOAR 集成
- [ ] 多租户支持
- [ ] 增强型分析仪表板
- [ ] 移动端事件响应应用
- [ ] Kubernetes 部署模板
## 📄 更新日志
有关版本历史和更新,请参见 [CHANGELOG.md](CHANGELOG.md)。
**用 ❤️ 为企业 IAM 团队构建**
标签:API集成, Elasticsearch, IAM, IR Playbook, MTTR, P1/P2事件, PagerDuty, Python, Redis, Runbook, SailPoint, ServiceNow, Slack, SOAR, 企业安全, 可观测性, 安全事件管理, 安全运营中心, 搜索引擎查询, 无后门, 网络映射, 网络测绘, 网络资产管理, 自动化诊断, 身份与访问管理, 身份安全, 运维自动化, 连接器故障, 逆向工具