Spaces:
Sleeping
Sleeping
Commit Β·
ee5b683
1
Parent(s): 27410ce
v0.2.0 final: Dockerfile fix, version sync, README rewrite, web UI 4th task
Browse files- Dockerfile +2 -0
- README.md +68 -43
- openenv.yaml +1 -1
- opensecops_env/__init__.py +1 -1
- opensecops_env/server/app.py +1 -0
Dockerfile
CHANGED
|
@@ -15,9 +15,11 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
|
|
| 15 |
|
| 16 |
# ---- Copy project ----
|
| 17 |
COPY opensecops_env/ /app/opensecops_env/
|
|
|
|
| 18 |
COPY openenv.yaml /app/openenv.yaml
|
| 19 |
COPY pyproject.toml /app/pyproject.toml
|
| 20 |
COPY inference.py /app/inference.py
|
|
|
|
| 21 |
|
| 22 |
# ---- Install package (editable so imports resolve correctly) ----
|
| 23 |
RUN pip install --no-cache-dir -e /app
|
|
|
|
| 15 |
|
| 16 |
# ---- Copy project ----
|
| 17 |
COPY opensecops_env/ /app/opensecops_env/
|
| 18 |
+
COPY server/ /app/server/
|
| 19 |
COPY openenv.yaml /app/openenv.yaml
|
| 20 |
COPY pyproject.toml /app/pyproject.toml
|
| 21 |
COPY inference.py /app/inference.py
|
| 22 |
+
COPY README.md /app/README.md
|
| 23 |
|
| 24 |
# ---- Install package (editable so imports resolve correctly) ----
|
| 25 |
RUN pip install --no-cache-dir -e /app
|
README.md
CHANGED
|
@@ -48,25 +48,29 @@ This directly addresses the *SecOps skills gap*: can LLMs / RL agents serve as e
|
|
| 48 |
## π¦ Project Structure
|
| 49 |
|
| 50 |
```
|
| 51 |
-
|
| 52 |
-
βββ
|
| 53 |
-
βββ
|
| 54 |
-
βββ
|
| 55 |
-
βββ
|
| 56 |
-
βββ
|
| 57 |
-
βββ
|
| 58 |
-
βββ tasks/
|
| 59 |
β βββ __init__.py
|
| 60 |
-
β βββ
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
βββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
```
|
| 71 |
|
| 72 |
---
|
|
@@ -118,7 +122,7 @@ cyber_attack:privilege_escalation
|
|
| 118 |
|
| 119 |
---
|
| 120 |
|
| 121 |
-
## π Tasks
|
| 122 |
|
| 123 |
### Task 1 β EASY: `easy_memory_leak` (seed=42)
|
| 124 |
**Scenario:** The `auth` service has a progressive memory leak.
|
|
@@ -134,7 +138,7 @@ cyber_attack:privilege_escalation
|
|
| 134 |
|
| 135 |
### Task 3 β MEDIUM-HARD: `medium_hard_bad_deployment` (seed=9999)
|
| 136 |
**Scenario:** A bad `api` v2.4.1 deployment pushed an invalid Redis connection string, sending the cache service into a reconnect storm. False gateway alerts distract from the real cause.
|
| 137 |
-
**Signals:** Deployment timestamp in logs correlates with degradation onset. Cache error logs show
|
| 138 |
**Correct actions:** Inspect metrics β Query api/cache logs β Rollback api deployment β Restart cache β Submit `misconfiguration:bad_config`
|
| 139 |
**Max steps:** 45 | **Noise:** 35%
|
| 140 |
|
|
@@ -179,18 +183,17 @@ score = 0.5 Γ diagnosis_correct
|
|
| 179 |
| `action_efficiency` | 30% | Fraction of correct mitigations achieved, adjusted for steps used |
|
| 180 |
| `investigation_quality` | 20% | Fraction of affected services investigated |
|
| 181 |
|
| 182 |
-
### Baseline Scores
|
| 183 |
|
| 184 |
-
| Task | Difficulty |
|
| 185 |
-
|------|-----------|-------
|
| 186 |
-
| easy_memory_leak | Easy |
|
| 187 |
-
| medium_ddos_cascade | Medium |
|
| 188 |
-
| medium_hard_bad_deployment | Medium-Hard |
|
| 189 |
-
| hard_data_exfiltration | Hard |
|
| 190 |
-
| **Average** | | **
|
| 191 |
|
| 192 |
-
>
|
| 193 |
-
> hard enough to discriminate, but not unsolvable.
|
| 194 |
|
| 195 |
---
|
| 196 |
|
|
@@ -199,20 +202,20 @@ score = 0.5 Γ diagnosis_correct
|
|
| 199 |
### Local (no Docker)
|
| 200 |
|
| 201 |
```bash
|
| 202 |
-
# Clone
|
| 203 |
cd opensecops_env
|
| 204 |
|
| 205 |
# Install
|
| 206 |
pip install -e ".[dev]"
|
| 207 |
|
| 208 |
-
# Run tests
|
| 209 |
pytest tests/ -v
|
| 210 |
|
| 211 |
# Start server
|
| 212 |
uvicorn opensecops_env.server.app:app --host 0.0.0.0 --port 8000
|
| 213 |
|
| 214 |
-
# Run inference
|
| 215 |
-
python
|
| 216 |
```
|
| 217 |
|
| 218 |
### Docker
|
|
@@ -223,36 +226,56 @@ docker build -t opensecops-env:latest .
|
|
| 223 |
|
| 224 |
# Run
|
| 225 |
docker run -p 8000:8000 opensecops-env:latest
|
| 226 |
-
|
| 227 |
-
# With web UI
|
| 228 |
-
docker run -p 8000:8000 -e ENABLE_WEB_INTERFACE=true opensecops-env:latest
|
| 229 |
```
|
| 230 |
|
| 231 |
### Inference with LLM
|
| 232 |
|
| 233 |
```bash
|
| 234 |
-
export API_BASE_URL="https://
|
| 235 |
-
export MODEL_NAME="
|
| 236 |
-
export HF_TOKEN="hf_..."
|
| 237 |
|
| 238 |
-
python
|
| 239 |
```
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
---
|
| 242 |
|
| 243 |
## π API Endpoints
|
| 244 |
|
| 245 |
| Method | Path | Description |
|
| 246 |
|--------|------|-------------|
|
| 247 |
-
| `GET` | `/health` | Liveness probe |
|
|
|
|
| 248 |
| `POST` | `/reset` | Start episode: `{"task_id": "easy_memory_leak"}` |
|
| 249 |
| `POST` | `/step` | Execute action: `{"action_type": "...", "parameters": {...}}` |
|
| 250 |
-
| `GET` | `/state` | Full internal state (for debugging) |
|
| 251 |
| `POST` | `/grade` | Grade current episode β `{score, details}` |
|
| 252 |
| `GET` | `/web` | Interactive debug UI (set `ENABLE_WEB_INTERFACE=true`) |
|
| 253 |
|
| 254 |
---
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
## π§ Design Principles
|
| 257 |
|
| 258 |
1. **Multi-step reasoning required** β no single action resolves any task
|
|
@@ -261,6 +284,8 @@ python -m opensecops_env.inference
|
|
| 261 |
4. **Action consequences** β blocking wrong IP harms users; isolating healthy service causes outage
|
| 262 |
5. **Deterministic reproducibility** β fixed seeds ensure identical episodes
|
| 263 |
6. **Dense reward** β non-zero signal at every step guides learning
|
|
|
|
|
|
|
| 264 |
|
| 265 |
---
|
| 266 |
|
|
|
|
| 48 |
## π¦ Project Structure
|
| 49 |
|
| 50 |
```
|
| 51 |
+
βββ inference.py # Baseline inference script (root, as required)
|
| 52 |
+
βββ openenv.yaml # OpenEnv manifest
|
| 53 |
+
βββ Dockerfile # Production container
|
| 54 |
+
βββ requirements.txt
|
| 55 |
+
βββ pyproject.toml
|
| 56 |
+
βββ uv.lock
|
| 57 |
+
βββ server/
|
|
|
|
| 58 |
β βββ __init__.py
|
| 59 |
+
β βββ app.py # Root-level entry point (for openenv validate)
|
| 60 |
+
βββ opensecops_env/
|
| 61 |
+
β βββ __init__.py # Package exports
|
| 62 |
+
β βββ models.py # SecOpsAction, SecOpsObservation, SecOpsState (dataclasses)
|
| 63 |
+
β βββ env.py # OpenSecOpsEnv β core environment (reset/step/state)
|
| 64 |
+
β βββ grader.py # Deterministic multi-component grader β [0, 1]
|
| 65 |
+
β βββ client.py # HTTP client for remote server interaction
|
| 66 |
+
β βββ tasks/
|
| 67 |
+
β βββ __init__.py
|
| 68 |
+
β βββ task_definitions.py # 4 task configs (easy β medium β medium-hard β hard)
|
| 69 |
+
β βββ server/
|
| 70 |
+
β βββ __init__.py
|
| 71 |
+
β βββ app.py # FastAPI server (reset/step/state/grade endpoints)
|
| 72 |
+
βββ tests/
|
| 73 |
+
βββ test_opensecops.py # 33 unit tests
|
| 74 |
```
|
| 75 |
|
| 76 |
---
|
|
|
|
| 122 |
|
| 123 |
---
|
| 124 |
|
| 125 |
+
## π Tasks (4 tasks, easy β hard)
|
| 126 |
|
| 127 |
### Task 1 β EASY: `easy_memory_leak` (seed=42)
|
| 128 |
**Scenario:** The `auth` service has a progressive memory leak.
|
|
|
|
| 138 |
|
| 139 |
### Task 3 β MEDIUM-HARD: `medium_hard_bad_deployment` (seed=9999)
|
| 140 |
**Scenario:** A bad `api` v2.4.1 deployment pushed an invalid Redis connection string, sending the cache service into a reconnect storm. False gateway alerts distract from the real cause.
|
| 141 |
+
**Signals:** Deployment timestamp in logs correlates with degradation onset. Cache error logs show connection refused.
|
| 142 |
**Correct actions:** Inspect metrics β Query api/cache logs β Rollback api deployment β Restart cache β Submit `misconfiguration:bad_config`
|
| 143 |
**Max steps:** 45 | **Noise:** 35%
|
| 144 |
|
|
|
|
| 183 |
| `action_efficiency` | 30% | Fraction of correct mitigations achieved, adjusted for steps used |
|
| 184 |
| `investigation_quality` | 20% | Fraction of affected services investigated |
|
| 185 |
|
| 186 |
+
### Baseline Scores (Heuristic Agent)
|
| 187 |
|
| 188 |
+
| Task | Difficulty | Score | Steps |
|
| 189 |
+
|------|-----------|-------|-------|
|
| 190 |
+
| `easy_memory_leak` | Easy | **1.000** | 4 |
|
| 191 |
+
| `medium_ddos_cascade` | Medium | **1.000** | 8 |
|
| 192 |
+
| `medium_hard_bad_deployment` | Medium-Hard | **1.000** | 6 |
|
| 193 |
+
| `hard_data_exfiltration` | Hard | **1.000** | 8 |
|
| 194 |
+
| **Average** | | **1.000** | |
|
| 195 |
|
| 196 |
+
> These are deterministic heuristic scores. A frontier 72B LLM typically scores ~0.75β0.85 on the harder tasks, showing the benchmark discriminates agent capability.
|
|
|
|
| 197 |
|
| 198 |
---
|
| 199 |
|
|
|
|
| 202 |
### Local (no Docker)
|
| 203 |
|
| 204 |
```bash
|
| 205 |
+
# Clone & enter project
|
| 206 |
cd opensecops_env
|
| 207 |
|
| 208 |
# Install
|
| 209 |
pip install -e ".[dev]"
|
| 210 |
|
| 211 |
+
# Run tests (33 tests)
|
| 212 |
pytest tests/ -v
|
| 213 |
|
| 214 |
# Start server
|
| 215 |
uvicorn opensecops_env.server.app:app --host 0.0.0.0 --port 8000
|
| 216 |
|
| 217 |
+
# Run baseline inference
|
| 218 |
+
python inference.py
|
| 219 |
```
|
| 220 |
|
| 221 |
### Docker
|
|
|
|
| 226 |
|
| 227 |
# Run
|
| 228 |
docker run -p 8000:8000 opensecops-env:latest
|
|
|
|
|
|
|
|
|
|
| 229 |
```
|
| 230 |
|
| 231 |
### Inference with LLM
|
| 232 |
|
| 233 |
```bash
|
| 234 |
+
export API_BASE_URL="https://router.huggingface.co/v1"
|
| 235 |
+
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
|
| 236 |
+
export HF_TOKEN="hf_..."
|
| 237 |
|
| 238 |
+
python inference.py
|
| 239 |
```
|
| 240 |
|
| 241 |
+
### Environment Variables
|
| 242 |
+
|
| 243 |
+
| Variable | Required | Default | Description |
|
| 244 |
+
|----------|----------|---------|-------------|
|
| 245 |
+
| `HF_TOKEN` | Yes (for LLM) | *none* | Hugging Face API token |
|
| 246 |
+
| `API_BASE_URL` | No | `https://router.huggingface.co/v1` | LLM endpoint URL |
|
| 247 |
+
| `MODEL_NAME` | No | `Qwen/Qwen2.5-72B-Instruct` | Model identifier |
|
| 248 |
+
| `LOCAL_IMAGE_NAME` | No | *none* | Docker image for `from_docker_image()` |
|
| 249 |
+
|
| 250 |
---
|
| 251 |
|
| 252 |
## π API Endpoints
|
| 253 |
|
| 254 |
| Method | Path | Description |
|
| 255 |
|--------|------|-------------|
|
| 256 |
+
| `GET` | `/health` | Liveness probe β `{"status": "ok"}` |
|
| 257 |
+
| `GET` | `/tasks` | List available tasks with metadata |
|
| 258 |
| `POST` | `/reset` | Start episode: `{"task_id": "easy_memory_leak"}` |
|
| 259 |
| `POST` | `/step` | Execute action: `{"action_type": "...", "parameters": {...}}` |
|
| 260 |
+
| `GET` | `/state` | Full internal state (for debugging / graders) |
|
| 261 |
| `POST` | `/grade` | Grade current episode β `{score, details}` |
|
| 262 |
| `GET` | `/web` | Interactive debug UI (set `ENABLE_WEB_INTERFACE=true`) |
|
| 263 |
|
| 264 |
---
|
| 265 |
|
| 266 |
+
## π§ͺ Validation
|
| 267 |
+
|
| 268 |
+
```bash
|
| 269 |
+
# Local spec validation
|
| 270 |
+
pip install openenv-core
|
| 271 |
+
openenv validate
|
| 272 |
+
|
| 273 |
+
# Run unit tests
|
| 274 |
+
pytest tests/ -v # 33 tests
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
---
|
| 278 |
+
|
| 279 |
## π§ Design Principles
|
| 280 |
|
| 281 |
1. **Multi-step reasoning required** β no single action resolves any task
|
|
|
|
| 284 |
4. **Action consequences** β blocking wrong IP harms users; isolating healthy service causes outage
|
| 285 |
5. **Deterministic reproducibility** β fixed seeds ensure identical episodes
|
| 286 |
6. **Dense reward** β non-zero signal at every step guides learning
|
| 287 |
+
7. **Diminishing returns** β repeated investigation of the same service yields less reward
|
| 288 |
+
8. **4 difficulty levels** β easy β medium β medium-hard β hard progression
|
| 289 |
|
| 290 |
---
|
| 291 |
|
openenv.yaml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
spec_version: 1
|
| 2 |
name: opensecops
|
| 3 |
-
version: "0.
|
| 4 |
description: >
|
| 5 |
OpenSecOpsEnv β A multi-step SecOps incident response environment
|
| 6 |
where an AI agent acts as an on-call engineer. The agent must
|
|
|
|
| 1 |
spec_version: 1
|
| 2 |
name: opensecops
|
| 3 |
+
version: "0.2.0"
|
| 4 |
description: >
|
| 5 |
OpenSecOpsEnv β A multi-step SecOps incident response environment
|
| 6 |
where an AI agent acts as an on-call engineer. The agent must
|
opensecops_env/__init__.py
CHANGED
|
@@ -12,7 +12,7 @@ from opensecops_env.models import (
|
|
| 12 |
SecOpsState,
|
| 13 |
)
|
| 14 |
|
| 15 |
-
__version__ = "0.
|
| 16 |
__all__ = [
|
| 17 |
"OpenSecOpsEnv",
|
| 18 |
"SecOpsAction",
|
|
|
|
| 12 |
SecOpsState,
|
| 13 |
)
|
| 14 |
|
| 15 |
+
__version__ = "0.2.0"
|
| 16 |
__all__ = [
|
| 17 |
"OpenSecOpsEnv",
|
| 18 |
"SecOpsAction",
|
opensecops_env/server/app.py
CHANGED
|
@@ -244,6 +244,7 @@ def _build_web_ui() -> str:
|
|
| 244 |
<select id="task_id">
|
| 245 |
<option value="easy_memory_leak">easy_memory_leak</option>
|
| 246 |
<option value="medium_ddos_cascade">medium_ddos_cascade</option>
|
|
|
|
| 247 |
<option value="hard_data_exfiltration">hard_data_exfiltration</option>
|
| 248 |
</select>
|
| 249 |
<button onclick="doReset()">Reset Episode</button>
|
|
|
|
| 244 |
<select id="task_id">
|
| 245 |
<option value="easy_memory_leak">easy_memory_leak</option>
|
| 246 |
<option value="medium_ddos_cascade">medium_ddos_cascade</option>
|
| 247 |
+
<option value="medium_hard_bad_deployment">medium_hard_bad_deployment</option>
|
| 248 |
<option value="hard_data_exfiltration">hard_data_exfiltration</option>
|
| 249 |
</select>
|
| 250 |
<button onclick="doReset()">Reset Episode</button>
|