BandariVathanSai20/soc-openenv

GitHub: BandariVathanSai20/soc-openenv

一个确定性的SOC仿真环境,用于在受控场景下评估AI智能体对网络安全事件的分类和响应能力。

Stars: 0 | Forks: 2

## app_port: 7860 colorFrom: blue colorTo: green emoji: 🛡️ sdk: docker title: SOC OpenEnv # SOC-OpenEnv SOC-OpenEnv 是一个确定性的**安全运营中心(SOC)**仿真环境,用于评估 AI 智能体在网络安全决策任务中的表现。它完全符合 **OpenEnv** 基准测试要求,专为 Meta PyTorch 黑客松设计。 ## 🚀 概述 SOC-OpenEnv 模拟真实的网络安全事件,例如暴力破解登录尝试、SQL 注入攻击以及多阶段**高级持续性威胁(APT)**。智能体必须将每个事件分类为**正常**、**可疑**或**攻击**。 ## ✨ 主要特性 - ✅ **通过第二阶段验证**:所有分数严格位于开放区间 $(0, 1)$ 内。 - 🔁 **确定性**:多次运行场景可复现。 - 🎯 **三个难度等级**:简单(暴力破解)、中等(SQL 注入)、困难(APT)。 - ⚡ **FastAPI 驱动**:低延迟 REST API。 - 🐳 **Docker 优化**:可直接部署到 Hugging Face Spaces。 - 🤖 **OpenAI 兼容**:推理脚本使用标准 OpenAI 客户端签名。 ## 🧠 环境描述 ### 🔍 观测空间 字段 | 描述 --- | --- `event` | 事件类型(例如 `login_failed`、`query`、`port_scan`) `ip` | 源 IP 地址 `level` | 严重级别(INFO、WARN、CRITICAL) `query` | SQL 查询(如适用) `step` | 当前回合步骤 `difficulty` | 场景难度(easy、medium、hard) ### 🎮 动作空间 - `normal`:良性活动。 - `suspicious`:潜在恶意/调查活动。 - `attack`:已确认的恶意活动。 ## 📊 评分方案 环境使用确定性评分器,根据真实标签评估动作序列。 | 结果 | 奖励(步骤) | 分数(评分器) | |---------|---------------|----------------| | 正确匹配 | +1.00 | 计入准确率 | | 错误匹配 | -1.00 | 应用惩罚 | **关于归一化的说明:** 最终分数严格限制在 **0.01 到 0.99** 之间,以确保符合基准测试验证规则。 ## 📊 基线性能 使用 `Qwen/Qwen2.5-72B-Instruct` 评估。这些结果是确定性的。 | 难度 | 归一化分数 | |------------|------------------| | 简单 | 0.80 | | 中等 | 0.85 | | 困难 | 0.85 | ### 🧪 推理输出示例 ``` [START] task=easy env=soc-openenv model=Qwen/Qwen2.5-72B-Instruct [STEP] step=1 action=suspicious reward=1.00 done=false error=null [STEP] step=2 action=suspicious reward=1.00 done=false error=null [STEP] step=3 action=suspicious reward=-1.00 done=false error=null [STEP] step=4 action=normal reward=1.00 done=false error=null [STEP] step=5 action=normal reward=1.00 done=true error=null [END] success=true steps=5 rewards=1.00,1.00,-1.00,1.00,1.00 --- Final Summary --- Task Easy: 0.80 Task Medium: 0.85 Task Hard: 0.85 ## 奖励与评估设计 SOC-OpenEnv follows the architectural principles of official OpenEnv environments such as TBench2, CARLA, and REPL. ### 环境奖励 - Returned by the `/step` endpoint. - Provide immediate feedback to the agent. - Include bonuses for early detection and penalties for false positives or missed attacks. - Suitable for reinforcement learning and agent training. ### 评分评估 - Implemented in `server/grader.py`. - Computes standardized metrics such as normalized score, accuracy, false positives, and missed attacks. - The final benchmark score is normalized to the range [0, 1] and is used for evaluation. This separation ensures both expressive agent feedback and fair benchmarking. ## 安装 ### 1. 克隆仓库 ``` bash git clone https://github.com/BandariVathanSai20/soc-openenv.git cd soc-openenv ``` ### 2. 创建并激活虚拟环境 #### Windows(PowerShell) ``` python -m venv .venv .\.venv\Scripts\activate ``` #### Linux/macOS ``` python3 -m venv .venv source .venv/bin/activate ``` ### 3. 安装依赖 ``` pip install --upgrade pip pip install -r requirements.txt ``` ## ▶️ 运行环境 ``` uvicorn server.app:app --host 0.0.0.0 --port 7860 ``` ### 健康检查 ``` curl http://localhost:7860/health ``` ## 🤖 运行基线智能体 ``` python inference.py ``` ## 🧪 运行测试 ``` python -m pytest tests/ ``` **预期输出** ``` ==================== 12 passed ==================== ``` ## 🐳 Docker 部署 ### 构建 Docker 镜像 ``` docker build -t soc-openenv . ``` ### 运行 Docker 容器 ``` docker run -p 7860:7860 soc-openenv ``` ## ✅ OpenEnv 验证 ``` bash scripts/validate-submission.sh http://localhost:7860 ``` **成功输出** ``` All 3/3 checks passed! Your submission is ready to submit. ``` ## 🌐 API 端点 端点 | 方法 | 描述 `/health` | GET | 服务健康检查 `/reset` | POST | 重置环境 `/step` | POST | 执行动作 `/state` | GET | 获取当前状态 ## 📦 API 使用示例 ### 重置环境 ``` curl -X POST http://localhost:7860/reset \ -H "Content-Type: application/json" \ -d '{"difficulty":"easy"}' ``` ### 执行步骤 ``` curl -X POST http://localhost:7860/step \ -H "Content-Type: application/json" \ -d '{"action":"suspicious"}' ``` ## ☁️ 部署到 Hugging Face Spaces 1. 创建一个新的 **Hugging Face Space**。 2. 选择 **Docker** 作为 SDK。 3. 上传或推送仓库文件。 4. 确保在 `Dockerfile` 中暴露端口 **7860**。 5. 为 Space 添加 **openenv** 标签。 6. 提交并部署 Space。 ## 🔧 跨平台 CLI 兼容性 包含一个名为 `openenv` 的 Bash 包装脚本,以确保在 Unix 验证环境中可以访问 OpenEnv CLI,尤其是在使用 Windows 虚拟环境时。 ## 🤝 贡献 欢迎贡献! 1. Fork 仓库。 2. 创建新分支:`git checkout -b feature/YourFeature`。 3. 提交更改:`git commit -m 'Add YourFeature'`。 4. 推送到分支:`git push origin feature/YourFeature`。 5. 打开 Pull Request。 请确保在提交贡献前所有测试都通过。 ## 🐞 问题 如果遇到任何错误或有功能请求,请在 GitHub 上提交问题:👉 https://github.com/BandariVathanSai20/soc-openenv/issues ## 📜 许可证 本项目基于 **MIT 许可证**。详见 `LICENSE` 文件。 ## 👨‍💻 作者 **Bandari Vathan Sai**\ GitHub:https://github.com/BandariVathanSai20 ## 🙌 致谢 - **OpenEnv 团队**提供的基准测试和验证框架。 - **Hugging Face** 提供的部署基础设施。 - **网络安全社区**提供的灵感和领域知识。 ## 📚 引用 ``` @software{soc_openenv, author = {Bandari Vathan Sai}, title = {SOC OpenEnv: Deterministic Cyber Attack Simulation Environment}, year = {2026}, url = {https://github.com/BandariVathanSai20/soc-openenv} } ``` ## ⭐ 支持 如果觉得本项目有用,请考虑在 GitHub 上给它一个 ⭐ 以支持后续开发!
标签:AI安全, AMSI绕过, APT攻击, AV绕过, Chat Copilot, CISA项目, Docker, DOE合作, FastAPI, LLM代理, PoC, 反取证, 威胁检测, 安全规则引擎, 安全评估, 安全运营中心, 安全防御评估, 异常检测, 强化学习, 插件系统, 数据统计, 暴力破解, 模拟环境, 混合加密, 端口扫描, 网络威胁情报, 网络安全, 网络映射, 蓝队防御, 请求拦截, 逆向工具, 隐私保护, 高级持续性威胁