citizen204/sentinel-toolkit

GitHub: citizen204/sentinel-toolkit

Sentinel 是一个模块化防御性安全工具包,通过可插拔扫描器将多云环境、日志、Web 应用和网络流量的安全检查统一为标准化发现模型并生成整合报告。

Stars: 0 | Forks: 0

# Sentinel **一个模块化的防御性安全工具包。** Sentinel 针对你自己的基础设施运行可插拔的扫描器,将它们发现的所有内容标准化为单一的 `Finding` 模型,并通过一条命令生成整合的 JSON 和 HTML 安全报告。 ## 为什么选择 Sentinel 大多数安全工具要么是单一用途的脚本,要么是重量级的平台。Sentinel 介于两者之间:它是一个干净、经过充分测试的代码库,其中每个安全域都是一个独立模块,共享通用的基础架构 —— 统一的数据模型、报告生成和 CLI。添加一个新的扫描器只需添加一个 `BaseScanner` 子类;CLI 会自动发现它。 ## 功能 - **统一的 `Finding` 模型** —— 每个扫描器,无论检查什么,都会输出相同的结构化发现(id、severity、description、**remediation**、evidence、resource)。 - **可插拔模块** —— 扫描器通过注册表自动注册;CLI 无需任何更改即可识别新增的扫描器(开闭原则)。 - **整合报告** —— 一次运行即可生成机器可读的 JSON 和带有样式的 HTML 报告,按严重程度分组并带有摘要标题。 - **端到端测试** —— 每个模块都由 `pytest` 覆盖;AWS 使用 `moto` 进行模拟,因此测试永远不会触及真实账户。 ### 可用模块 | 模块 | 领域 | 检查项 | |--------|--------|--------| | `cloudscan` | AWS 配置不当 | 公开的 S3 存储桶 · 在 SSH/RDP 上对 `0.0.0.0/0` 开放的安全组 · 没有启用 MFA 的 IAM 用户 | | `logwatch` | 日志分析 (轻量级 SIEM) | SSH 暴力破解检测 · 直接特权(root/admin)登录 | | `webscan` | Web 应用程序 | 缺失的 HTTP 安全标头 (HSTS, CSP, X-Content-Type-Options, X-Frame-Options) | | `netmon` | 网络流量 | 端口扫描检测 · 主机扫描检测(来自 flow log) | 此外,还有一个 **Next.js + Tailwind 仪表板**(`dashboard/`),用于将任何 `report.json` 可视化。 ## 架构 ``` sentinel/ ├─ core/ # shared kernel │ ├─ finding.py # Finding model + Severity enum │ ├─ scanner.py # BaseScanner ABC + auto-registration registry │ ├─ config.py # YAML config loader │ └─ report.py # JSON + HTML report generation ├─ modules/ # each is a BaseScanner subclass (checks/ = one function per rule) │ ├─ cloudscan/ # AWS misconfiguration scanner │ ├─ logwatch/ # auth-log analysis │ ├─ webscan/ # HTTP security headers │ └─ netmon/ # network flow analysis ├─ templates/ # HTML report template └─ cli.py # Typer CLI: list-scanners, scan , scan-all dashboard/ # Next.js + Tailwind UI that renders a report.json ``` 数据流: ``` scanner.run() ─▶ list[Finding] ─▶ aggregate ─▶ report.json + report.html ``` ## 安装 需要 Python 3.11+。 ``` git clone https://github.com/citizen204/sentinel-toolkit.git cd sentinel-toolkit python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1 pip install -e ".[dev]" ``` ## 用法 ``` # 列出此构建中可用的扫描器 sentinel list-scanners # 运行单个扫描器(使用您的默认 AWS credentials/profile) sentinel scan cloudscan # 将每个已注册的扫描器运行至一个合并报告中 sentinel scan-all # 选择输出格式和目录 sentinel scan cloudscan --format html --output-dir reports ``` 报告会写入 `reports/report-.{json,html}`。 ### 配置 使用 `--config` 传递一个 YAML 配置: ``` # sentinel.yaml aws_profile: my-audit-profile # cloudscan target_url: https://app.example.com # webscan log_paths: # logwatch - /var/log/auth.log capture_file: flows.txt # netmon (src_ip dst_ip dst_port per line) output_dir: reports ``` ``` sentinel scan cloudscan --config sentinel.yaml sentinel scan-all --config sentinel.yaml ``` ### 仪表板 ``` cd dashboard npm install npm run dev # http://localhost:3000 ``` 仪表板会读取 `dashboard/public/report.json`;将真实的报告拖放到此处即可查看你自己的发现。请参阅 [dashboard/README.md](dashboard/README.md)。 ## `cloudscan` 检查的内容 | 规则 ID | 严重程度 | 描述 | |---------|----------|-------------| | `CLOUD-S3-PUBLIC` | 高 | S3 存储桶 ACL 授予了公共组(AllUsers/AuthenticatedUsers)访问权限 | | `CLOUD-SG-OPEN-INGRESS` | 高 | 安全组允许 `0.0.0.0/0` 通过 SSH (22) 或 RDP (3389) 进行入站连接 | | `CLOUD-IAM-NO-MFA` | 中 | IAM 用户未启用 MFA 设备 | 每个发现都包含一个具体的 **remediation** 步骤 —— Sentinel 不仅告诉你出了什么问题,还会告诉你如何解决它。 ## 测试 ``` pytest -q ``` 所有与 AWS 的交互都使用 `moto` 进行了模拟;测试套件完全离线运行。 ## 技术栈 **工具包:** Python 3.11 · Pydantic · Typer · Jinja2 · boto3 · requests · pytest · moto · responses **仪表板:** Next.js · React · Tailwind CSS · TypeScript ## 许可证 基于 MIT 许可证发布 —— 详见 [LICENSE](LICENSE)。
标签:Python, Web报告查看器, 安全规则引擎, 无后门, 足迹分析, 逆向工具