easysap/SAP-SHIELD
GitHub: easysap/SAP-SHIELD
SAP Shield 是一个利用 AI/ML 技术为中小企业提供 SAP 内部威胁检测和行为异常监控的开源工具。
Stars: 0 | Forks: 0
# 🛡️ SAP Shield
**面向 SAP 的开源内部威胁检测——专为无法承担企业级 SIEM 工具的组织构建。**
SAP Shield 监控 SAP 系统中的用户活动,并利用 AI/ML 检测可能表明内部威胁的行为异常:数据窃取、权限滥用、未经授权的访问等。
## 为什么选择 SAP Shield?
大多数内部威胁检测平台价格高达六位数,并且需要专门的安全团队。SAP Shield 将相同的能力带给中小企业:
- **零成本** — 基于 Apache 2.0 的完全开源
- **无需 SAP 系统即可试用** — 内置数据模拟器让您在几分钟内即可体验
- **轻量级** — 可在单机上通过 Docker 运行
- **AI 驱动** — 基于机器学习的行为基线化,误报率低
- **实时** — 持续监控,即时告警
## 快速开始 (< 5 分钟)
```
# Clone the repository
git clone https://github.com/YOUR_USERNAME/sap-shield.git
cd sap-shield
# 使用 Docker 启动所有服务
docker compose up --build
# 打开 dashboard
# http://localhost:3000
```
就这样。模拟器会生成注入了威胁的现实 SAP 活动数据,因此您可以立即看到 SAP Shield 的实际运行效果。
## 架构
```
┌─────────────────────────────────────────────────────┐
│ SAP Shield │
├──────────┬──────────┬──────────┬────────────────────┤
│Connectors│ Pipeline │Detection │ Dashboard │
│ │ │ Engine │ │
│ • RFC │ • Ingest │ • ML │ • Alert viewer │
│ • OData │ • Normal │ models │ • User profiles │
│ • File │ • Enrich │ • Rule │ • Risk scores │
│ • Sim │ • Store │ engine │ • Trend charts │
└────┬─────┴────┬─────┴────┬─────┴────────┬───────────┘
│ │ │ │
▼ ▼ ▼ ▼
SAP System SQLite/ Alert Queue REST API
Postgres
```
### 组件
| Component | Description |
|-----------|-------------|
| **Connectors** | 从 SAP(或模拟数据)中提取审计日志、变更文档和用户活动 |
| **Pipeline** | 对活动事件进行标准化、丰富并存储 |
| **Detection Engine** | 基于机器学习的异常检测 + 可配置规则引擎 |
| **REST API** | 查询告警、用户风险评分和系统状态 |
| **Dashboard** | 用于调查威胁和监控活动的 Web UI |
| **Simulator** | 生成注入了威胁场景的现实 SAP 活动数据 |
## 检测场景 (v0.1)
| Scenario | Description | Method |
|----------|-------------|--------|
| 🔴 Mass Data Export | 用户下载异常数量的敏感数据 | 统计离群点检测 |
| 🟠 Privilege Escalation | 异常的授权变更或角色分配 | 基于规则 + 序列分析 |
| 🟡 Off-Hours Access | 在营业时间外执行关键事务 | 时间窗口异常检测 |
| 🔴 Ghost Account Activity | 休眠账户或服务账户突然变得活跃 | 基线偏差评分 |
| 🟠 Transaction Hopping | 用户访问异常组合的事务 | 基于图的行为建模 |
## 项目结构
```
sap-shield/
├── README.md
├── LICENSE
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
├── setup.py
├── config/
│ ├── default.yaml # Default configuration
│ └── detection_rules.yaml # Configurable detection rules
├── connectors/
│ ├── __init__.py
│ ├── base.py # Base connector interface
│ ├── rfc_connector.py # SAP RFC connector (PyRFC)
│ ├── odata_connector.py # SAP OData API connector
│ └── file_connector.py # File-based log ingestion
├── simulator/
│ ├── __init__.py
│ ├── generator.py # Activity data generator
│ ├── profiles.py # User behavior profiles
│ └── threat_scenarios.py # Injected threat patterns
├── pipeline/
│ ├── __init__.py
│ ├── ingestion.py # Event ingestion and normalization
│ ├── enrichment.py # Context enrichment (user, role, data sensitivity)
│ └── storage.py # Storage backend (SQLite / PostgreSQL)
├── detection/
│ ├── __init__.py
│ ├── engine.py # Main detection orchestrator
│ ├── models/
│ │ ├── __init__.py
│ │ ├── baseline.py # User behavior baselining
│ │ ├── anomaly.py # Anomaly scoring models
│ │ └── sequence.py # Transaction sequence analysis
│ └── rules/
│ ├── __init__.py
│ └── rule_engine.py # Configurable rule-based detection
├── api/
│ ├── __init__.py
│ ├── app.py # FastAPI application
│ └── routes.py # API endpoints
├── dashboard/
│ └── index.html # Single-page dashboard
├── tests/
│ ├── ...
├── docs/
│ ├── architecture.md
│ ├── sap-configuration.md
│ ├── detection-logic.md
│ └── deployment.md
├── scripts/
│ └── seed_data.py # Generate sample data
└── .github/
└── workflows/
└── ci.yml # GitHub Actions CI
```
## 配置
SAP Shield 通过 `config/default.yaml` 进行配置:
```
# SAP 连接(simulator 模式下不需要)
sap:
connector: simulator # Options: rfc, odata, file, simulator
# rfc_config:
# ashost: sap-server.company.com
# sysnr: "00"
# client: "100"
# 检测调优
detection:
sensitivity: medium # low, medium, high
baseline_days: 30 # Days of history for behavioral baseline
alert_threshold: 0.75 # Risk score threshold (0.0 - 1.0)
# 存储
storage:
backend: sqlite # Options: sqlite, postgresql
sqlite_path: ./data/sapshield.db
```
## 生产环境部署
当您准备好连接到真实的 SAP 系统时:
1. 安装 SAP NW RFC SDK 和 PyRFC(参见 [docs/sap-configuration.md](docs/sap-configuration.md))
2. 在 `config/default.yaml` 中更新您的 SAP 连接详情
3. 将存储切换至 PostgreSQL 以实现扩展
4. 使用 Docker 或 Kubernetes 进行部署
## 路线图
| Phase | Focus | Status |
|-------|-------|--------|
| **v0.1** | 核心检测引擎、模拟器、基础仪表板 | 🟢 当前版本 |
| **v0.2** | 增强的机器学习模型、更多 SAP 连接器、SIEM 导出 | 🔵 计划中 |
| **v0.3** | 实时流式管道、Kafka 集成 | 🔵 计划中 |
| **v0.4** | 多租户 SaaS 部署选项 | 🔵 计划中 |
## 许可证
Apache 2.0 — 详情请参阅 [LICENSE](LICENSE)。
## 免责声明
SAP Shield 是一款安全监控工具。部署时应符合您组织的隐私政策以及适用的劳动/数据保护法律。务必根据当地法规告知员工有关监控的情况。
标签:AI安全, Chat Copilot, DevSecOps, OData, RFC连接, SAP安全, SAP权限管理, SIEM替代, 上游代理, 中小企业安全, 内部威胁检测, 威胁情报, 密钥泄露防护, 开发者工具, 开源安全工具, 异常检测, 数据防泄露 (DLP), 时间线生成, 机器学习安全, 权限滥用检测, 测试用例, 用户行为分析 (UEBA), 网络安全, 自动化防御, 请求拦截, 轻量级安全, 逆向工具, 逆向工程平台, 隐私保护