fasilmveloor/sentinel
GitHub: fasilmveloor/sentinel
Sentinel 是一款AI辅助的自主API安全测试工具,用于自动化发现多步漏洞链。
Stars: 0 | Forks: 0
# l" is used for flow control or monitoring.
Sentinel 是一款针对 OpenAPI 描述服务的自主 API 安全测试工具。它将 AI 辅助规划层与有界执行循环、共享扫描上下文和确定性攻击模块相结合。
核心思想:
```
task -> execute -> learn -> follow-up
```
Sentinel 并不将 AI 置于执行层内部。攻击模块保持确定性。其自主行为源于围绕它们的循环。
## 概述
Sentinel v3 将 API 扫描视为一个有界自主系统:
- 从 API 结构生成种子任务
- 执行确定性攻击
- 通过共享上下文从响应中学习
- 当新构件出现时,将后续工作加入队列
示例链:
```
SQLi -> extract ID -> enqueue IDOR -> probe object access
```
这既保持了执行的可预测性,同时又允许多步探索。
## 主要特性
- 自主循环,对迭代次数和执行的任务有明确限制
- 使用 `ScanContext` 进行上下文驱动的任务链
- 执行层内部无 AI 的确定性攻击模块
- 通过 `TaskQueue` 进行去重的任务调度
- 执行层外部的 AI 辅助规划和优先级排序
- 多种报告格式和 CLI 工作流程
## 工作原理
高级流程:
```
OpenAPI -> Parser -> TaskQueue -> SentinelOrchestrator -> Attack Modules -> ScanContext -> follow-up tasks -> Reporter
```
主要运行时组件:
- `TaskQueue`:去重的 FIFO 扫描任务队列
- `ScanContext`:共享状态,用于存储发现的 ID、令牌、发现结果以及已执行的任务签名
- `SentinelOrchestrator`:有界循环,负责执行任务、更新上下文并应用简单的链式规则
当前 Tier 1 链式规则有意设计得很简单:
- 如果扫描发现 ID,Sentinel 可以将 IDOR 后续任务加入队列,用于匹配的端点。
## 使用方法
安装依赖:
```
pyenv activate env
pip install -r requirements.txt
```
如果您使用项目的 pyenv 环境,请在运行 Sentinel 或 pytest 之前激活它:
```
pyenv activate env
```
运行标准扫描:
```
python -m sentinel scan \
--swagger api-spec.yaml \
--target https://api.example.com
```
运行自主模式:
```
python -m sentinel autonomous \
--swagger api-spec.yaml \
--target https://api.example.com
```
自主模式仍然使用确定性攻击模块。区别在于 Sentinel 可以从中间结果学习并安排后续工作,而不是在单次计划/执行后停止。
带认证的示例:
```
python -m sentinel autonomous \
--swagger api-spec.yaml \
--target https://api.example.com \
--auth-token YOUR_TOKEN
```
常用选项:
- `--swagger`, `-s`:OpenAPI 规范文件路径
- `--target`, `-t`:目标 API 的基础 URL
- `--auth-token`:用于认证测试的 Bearer 令牌
- `--llm`:规划提供者(`gemini`、`openai`、`claude`、`local`)
- `--format`, `-f`:报告格式
- `--output`, `-o`:报告路径
## 架构
Sentinel v3 保持执行层简洁:
```
OpenAPI Spec
-> Parser
-> seed tasks
-> TaskQueue
-> SentinelOrchestrator
-> execute attack
-> update ScanContext
-> enqueue follow-up tasks
-> Reporter
```
重要约束:
- 攻击模块内部不使用 AI
- 链式规则是确定性的
- 循环是有界的
- 保留了向后兼容的扫描模式
## 项目结构
```
sentinel/
├── sentinel/
│ ├── agent.py
│ ├── autonomous.py
│ ├── orchestrator.py
│ ├── scan_context.py
│ ├── tasks.py
│ ├── parser.py
│ ├── models.py
│ ├── main.py
│ ├── reporter.py
│ ├── html_reporter.py
│ ├── json_reporter.py
│ └── attacks/
├── docs/
├── tests/
│ ├── unit/
│ ├── integration/
│ └── e2e/
└── test_server/
```
## 测试
从项目根目录运行测试:
```
pyenv activate env
pytest -q
```
运行特定层级的测试:
```
pytest -q tests/unit
pytest -q tests/integration
pytest -q tests/e2e
```
测试方法:
- 单元测试覆盖任务签名、队列行为、扫描上下文提取和循环控制
- 集成测试模拟攻击者,并在无真实 HTTP 的情况下验证循环/链式行为
- 端到端测试使用本地测试服务器来验证端到端的自主行为
## 文档
- [架构](docs/ARCHITECTURE.md)
- [自主模式](docs/autonomous_mode.md)
- [测试](docs/testing.md)
标签:AI辅助, AI驱动, API安全, API漏洞检测, CISA项目, GraphQL安全矩阵, IDOR检测, JSON输出, OpenAPI支持, SQL注入测试, Web安全, 上下文管理, 任务队列, 安全扫描器, 安全测试, 安全规则引擎, 攻击性安全, 确定性攻击, 网络安全, 网络安全审计, 自主系统, 蓝队分析, 逆向工具, 链式攻击, 隐私保护