CracklesCreeper commited on
Commit
ee5b683
Β·
1 Parent(s): 27410ce

v0.2.0 final: Dockerfile fix, version sync, README rewrite, web UI 4th task

Browse files
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
- opensecops_env/
52
- β”œβ”€β”€ __init__.py # Package exports
53
- β”œβ”€β”€ models.py # SecOpsAction, SecOpsObservation, SecOpsState (dataclasses)
54
- β”œβ”€β”€ env.py # OpenSecOpsEnv – core environment (reset/step/state)
55
- β”œβ”€β”€ grader.py # Deterministic multi-component grader β†’ [0, 1]
56
- β”œβ”€β”€ client.py # HTTP client for running server
57
- β”œβ”€β”€ inference.py # Baseline inference script (LLM or heuristic agent)
58
- β”œβ”€β”€ tasks/
59
  β”‚ β”œβ”€β”€ __init__.py
60
- β”‚ └── task_definitions.py # EASY / MEDIUM / HARD task configs (deterministic)
61
- └── server/
62
- β”œβ”€β”€ __init__.py
63
- └── app.py # FastAPI server (reset/step/state/grade endpoints)
64
- openenv.yaml # OpenEnv manifest
65
- Dockerfile # Production container
66
- requirements.txt
67
- pyproject.toml
68
- tests/
69
- └── test_opensecops.py # pytest test suite
 
 
 
 
 
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 `MISCONF: invalid config REDIS_URL=''`.
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 | Heuristic agent | Qwen/Qwen2.5-72B LLM |
185
- |------|-----------|-----------------|----------------------|
186
- | easy_memory_leak | Easy | ~0.95 | **1.00** |
187
- | medium_ddos_cascade | Medium | ~0.90 | **0.73** |
188
- | medium_hard_bad_deployment | Medium-Hard | ~0.93 | **~0.75** |
189
- | hard_data_exfiltration | Hard | ~0.93 | **0.80** |
190
- | **Average** | | **~0.93** | **~0.82** |
191
 
192
- > Scores in **[0, 1]**. A frontier 72B model scores ~0.82, showing the benchmark is
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 / enter project
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 -m opensecops_env.inference
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://api.openai.com/v1"
235
- export MODEL_NAME="gpt-4o-mini"
236
- export HF_TOKEN="hf_..." # or OPENAI_API_KEY
237
 
238
- python -m opensecops_env.inference
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.1.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.1.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>