cherryaugusta/OpsSentinel

GitHub: cherryaugusta/OpsSentinel

一个面向学习与作品集展示的实时安全运维控制台,提供可解释的异常检测与事件管理能力。

Stars: 0 | Forks: 0

# OpsSentinel — 实时异常与事件控制台(可解释 SecOps) **教育目的与技能展示:** 本仓库是面向作品集展示的高质量演示项目,适用于学习、面试和技术评估。它并非用于受监管生产系统的直接替代方案。其中的安全控制措施是作为“安全设计(Security-by-Design)”的示例实现的,在任何实际部署前必须经过审查和调整。 ## 功能说明 OpsSentinel 将合成的应用程序和安全日志事件流式传输到 Django 后端,利用确定性规则基线检测异常,并生成包含可解释性工件的事件。 - **为何触发此告警?** 包含规则追踪、证据摘要和序列回放 - **实时推送:** 通过 Django Channels 实现 WebSockets - **检测任务:** 使用 Celery 进行周期性评估 - **运维弹性钩子:** 为未来的混沌注入模式预留设计 ## 截图 ### 前端仪表板 运行在容器化前端环境中的 Angular 仪表板,这是首选的集成验证路径。 ![Frontend Dashboard](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/33a43ab893044751.png) ### API 文档 通过 Swagger UI 提供的 OpenAPI 文档。 ![API Docs](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/0054bc43ed044755.png) ### 健康检查端点 用于验证后端依赖状态的健康检查端点。 ![API Health](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/3f120a3ddb044759.png) ## 架构概览 - **后端:** Django, Django REST Framework, drf-spectacular, Channels, Celery - **数据存储:** PostgreSQL, Redis - **前端:** Angular 严格模式,类型化 API 服务契约,关联 ID 传播 - **DevSecOps:** pre-commit, pip-audit, safety, ESLint strict, gitleaks ## 实施的安全设计原则 - **可追溯性:** 每个请求都会传播 `X-Correlation-ID` 并在响应中回显 - **最小暴露:** 仅提交 `.env.example`;真实的 `.env` 被忽略 - **加固默认设置:** 安全标头,HTTPOnly Cookie,以及显式依赖项检查 - **利于审计的检测:** 带有结构化跟踪的确定性基线规则 ## AI 伦理与披露 OpsSentinel 旨在以可控、可审计的方式支持 AI 辅助调查。如果或当使用模型时,必须强制执行以下规定。 ### PII 清洗 - 禁止将直接 PII 输入模型 - 隐去(Redact)电子邮件、电话号码、账户标识符、类似卡号的模式、令牌、JWT 和 API 密钥 - 切勿在可解释性字段中持久化存储原始敏感内容 ### 人在回路模式 - 对于严重级别升级、自动补救或影响客户的操作,必须经过人工批准 - 模型输出仅供参考;操作员确认操作并记录理由 ### 幻觉缓解 - 仅基于证据生成 - 明确限制与不确定性处理 - 基于检索而非猜测 - 当证据不足时拒绝执行 ### 治理工件 请参阅: - `ai_governance/prompt_catalog.json` - `ai_governance/evals/sample_eval.json` ## 本地开发 ### 后端 在 `D:\Projects\OpsSentinel\api` 目录下运行: ``` cd .\api .\.venv\Scripts\Activate.ps1 python manage.py migrate python manage.py runserver 0.0.0.0:8000 ``` 后端端点: * 健康检查:`http://localhost:8000/api/core/health/` * OpenAPI 架构:`http://localhost:8000/api/schema/` * Swagger UI:`http://localhost:8000/api/docs/` ### 前端 在 `D:\Projects\OpsSentinel\client` 目录下运行: ``` cd .\client npm install npx ng serve --proxy-config .\proxy.conf.json ``` 前端本地 URL: * `http://localhost:4200/` ### Docker Compose 在 `D:\Projects\OpsSentinel` 目录下运行: ``` cd .\ if (-not (Test-Path ".\.env")) { Copy-Item ".\.env.example" ".\.env" } docker compose up --build ``` 容器化端点: * 前端:`http://localhost:8080/` * API 健康检查:`http://localhost:8000/api/core/health/` * API 文档:`http://localhost:8000/api/docs/` ### 演示事件种子 在 Docker 堆栈启动后运行此命令,以便为仪表板创建一个可见的事件。 ``` $event = Invoke-RestMethod -Method Post -Uri "http://localhost:8000/api/incidents/events/" -ContentType "application/json" -Body '{ "ts": "2026-03-11T10:00:00Z", "source": "api-gateway", "event_type": "LOGIN", "actor": "demo-user", "ip": "203.0.113.10", "message": "login from unusual location", "risk_score": 0.92 }' Invoke-RestMethod -Method Post -Uri "http://localhost:8000/api/incidents/events/$($event.id)/evaluate/" ``` ### 质量门禁 在 `D:\Projects\OpsSentinel` 目录下运行: ``` .\scripts\quality-gates.ps1 ``` 这将执行: * `pip-audit` * `safety check` 或 `safety scan` * `flake8` * `python manage.py test` * `npx ng lint` ## 仓库结构 ``` OpsSentinel/ .dockerignore .editorconfig .env.example .flake8 .gitattributes .gitignore .gitleaks.toml .pre-commit-config.yaml README.md docker-compose.yml screenshots/ api-docs-browser.png api-health-browser.png frontend-dashboard.png infra/ docker/ api.Dockerfile client.Dockerfile nginx.conf docs/ adr/ 0001-architecture-baseline.md scripts/ verify-tree.ps1 quality-gates.ps1 ai_governance/ prompt_catalog.json evals/ sample_eval.json api/ manage.py requirements.txt requirements-dev.txt opssentinel_api/ core/ incidents/ tests/ client/ angular.json package.json package-lock.json proxy.conf.json tsconfig.json tsconfig.app.json tsconfig.spec.json eslint.config.js public/ src/ ``` ## 许可证 本仓库仅用于教育和作品集展示目的。不适用于生产或监管用途。
标签:AMSI绕过, Angular, API安全, Celery, CISA项目, DevSecOps, Django, Django Channels, Docker, Grype, JSON输出, OpenAPI, PE 加载器, PostgreSQL, Python, Redis, SecOps, Swagger, TypeScript, WebSocket, XAI, 上游代理, 云安全架构, 依赖分析, 可解释性人工智能, 威胁检测, 安全仪表盘, 安全信息与事件管理, 安全左移, 安全插件, 安全运营, 安全防御评估, 开源安全项目, 异常检测, 扫描框架, 搜索引擎查询, 搜索引擎爬取, 教育项目, 无后门, 测试用例, 网络安全, 请求拦截, 隐私保护