File size: 1,962 Bytes
3282be6
57c1397
 
 
 
3282be6
 
57c1397
 
 
 
 
 
 
3282be6
 
57c1397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: WebSec Repair Env
emoji: 🛡️
colorFrom: red
colorTo: gray
sdk: docker
pinned: false
app_port: 8000
base_path: /web
tags:
  - openenv
  - security
  - web
  - training
---

# WebSec Repair Env

`websec_repair_env` is a lean OpenEnv environment for AI vulnerability review and remediation.
Each episode presents one deterministic vulnerability scenario and asks the agent to:

1. inspect the task
2. classify the vulnerability
3. apply one discrete patch template
4. verify exploit blocking and functionality preservation
5. submit

The environment ships with exactly three tasks:

- `sqli_login`
- `xss_comments`
- `broken_auth_admin`

## Actions

- `inspect`
- `classify`
- `apply_patch`
- `verify`
- `submit`

## Reward

The score is absolute in `[0.0, 1.0]`:

- `0.25` correct classification
- `0.35` correct patch
- `0.20` exploit blocked
- `0.15` functionality preserved
- `0.05` successful submit

`step()` returns reward as score delta from the previous state.

## Extra Routes

- `GET /tasks`
- `GET /grader`
- `GET /baseline`

`/grader` accepts optional `task_id`.
`/baseline` accepts optional `task_id` and returns a filtered catalog.

## Local Usage

Install and lock dependencies:

```bash
uv sync
```

Run the server:

```bash
uv run server
```

Run the baseline agent against a running server:

```bash
uv run python inference.py --task sqli_login
```

Run tests:

```bash
uv run pytest
```

Validate structure:

```bash
/home/dux/.openclaw/workspace/OpenEnv/venv/bin/openenv validate . --verbose
```

Validate a running server:

```bash
/home/dux/.openclaw/workspace/OpenEnv/venv/bin/openenv validate --url http://127.0.0.1:8000
```

## Docker

Build:

```bash
docker build -t websec-repair-env:latest -f server/Dockerfile .
```

Run:

```bash
docker run --rm -p 8000:8000 websec-repair-env:latest
```

## Hugging Face Spaces

From this environment directory:

```bash
/home/dux/.openclaw/workspace/OpenEnv/venv/bin/openenv push
```