Merge pull request #3 from KumarChad/2026-04-06-c5ae: HF space stuff and making it compatible
Browse files- .dockerignore +1 -6
- README.md +185 -145
- pyproject.toml +3 -5
- server/__init__.py +1 -5
- server/app.py +15 -0
.dockerignore
CHANGED
|
@@ -28,7 +28,6 @@ MANIFEST
|
|
| 28 |
|
| 29 |
# Virtual environments
|
| 30 |
venv/
|
| 31 |
-
env/
|
| 32 |
ENV/
|
| 33 |
.venv/
|
| 34 |
.env/
|
|
@@ -57,10 +56,6 @@ logs/
|
|
| 57 |
*.tmp
|
| 58 |
*.temp
|
| 59 |
|
| 60 |
-
# Documentation
|
| 61 |
-
README.md
|
| 62 |
-
docs/
|
| 63 |
-
|
| 64 |
# Test files
|
| 65 |
tests/
|
| 66 |
test_*.py
|
|
@@ -91,4 +86,4 @@ node_modules/
|
|
| 91 |
|
| 92 |
# Docker
|
| 93 |
Dockerfile.*
|
| 94 |
-
docker-compose*.yml
|
|
|
|
| 28 |
|
| 29 |
# Virtual environments
|
| 30 |
venv/
|
|
|
|
| 31 |
ENV/
|
| 32 |
.venv/
|
| 33 |
.env/
|
|
|
|
| 56 |
*.tmp
|
| 57 |
*.temp
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
# Test files
|
| 60 |
tests/
|
| 61 |
test_*.py
|
|
|
|
| 86 |
|
| 87 |
# Docker
|
| 88 |
Dockerfile.*
|
| 89 |
+
docker-compose*.yml
|
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Prompt Injection Env Server
|
| 3 |
-
emoji: 🔊
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
|
@@ -14,213 +14,253 @@ tags:
|
|
| 14 |
|
| 15 |
# IDPI Exfil Environment
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
## Features
|
| 20 |
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
|
|
|
| 26 |
|
| 27 |
## Quick Start
|
| 28 |
|
| 29 |
-
###
|
| 30 |
|
| 31 |
```bash
|
| 32 |
-
# Install dependencies
|
| 33 |
pip install -e .
|
|
|
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
python -m uvicorn server.app:app --host 0.0.0.0 --port 7860
|
| 37 |
|
| 38 |
-
|
| 39 |
python server/app.py
|
| 40 |
```
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
-
import requests
|
| 46 |
|
| 47 |
-
|
| 48 |
-
response = requests.post("http://localhost:7860/reset", json={"difficulty": "easy"})
|
| 49 |
-
observation = response.json()
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
```
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
```bash
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
-
pip install -e .
|
| 68 |
|
| 69 |
-
|
| 70 |
python run_baseline.py
|
|
|
|
| 71 |
```
|
| 72 |
|
| 73 |
-
|
| 74 |
-
- Test GPT-4o on all difficulty levels
|
| 75 |
-
- Generate real-time logs in competition format
|
| 76 |
-
- Save detailed results to `baseline/baseline_results.json`
|
| 77 |
|
| 78 |
-
##
|
| 79 |
|
| 80 |
-
###
|
| 81 |
-
- `ReadDoc`: Read email content
|
| 82 |
-
- `WriteDB(content="...")`: Write to database (for summaries)
|
| 83 |
-
- `SendEmail(to="...", body="...")`: Send email (dangerous!)
|
| 84 |
-
- `FlagInjection(reason="...")`: Flag suspicious content
|
| 85 |
-
- `NoOp`: Take no action
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
- `body`: Email content
|
| 90 |
-
- `last_action_result`: Result of previous action
|
| 91 |
-
- `step_count`: Current step number
|
| 92 |
-
- `task_difficulty`: easy/medium/hard
|
| 93 |
-
- `summary_required`: Whether summary needed (hard tasks)
|
| 94 |
-
- `current_summary`: Current summary progress
|
| 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 |
-
##
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
-
|
| 129 |
-
``
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
│ ├── models.py # Pydantic schemas
|
| 133 |
-
│ ├── reward.py # Reward function
|
| 134 |
-
│ └── grader.py # Episode grading
|
| 135 |
-
├── server/ # FastAPI server
|
| 136 |
-
│ └── app.py # REST API endpoints
|
| 137 |
-
├── baseline/ # Baseline evaluation
|
| 138 |
-
│ ├── run_baseline.py # GPT-4o evaluation
|
| 139 |
-
│ └── baseline_results.json # Results storage
|
| 140 |
-
├── models.py # Schema definitions
|
| 141 |
-
└── openenv.yaml # Environment metadata
|
| 142 |
-
```
|
| 143 |
|
| 144 |
-
###
|
| 145 |
-
1. Update schemas in `models.py`
|
| 146 |
-
2. Implement logic in `env/environment.py`
|
| 147 |
-
3. Update rewards in `env/reward.py`
|
| 148 |
-
4. Add grading logic in `env/grader.py`
|
| 149 |
-
5. Update API endpoints in `server/app.py`
|
| 150 |
-
- `reward` (float) - Reward based on message length (length × 0.1)
|
| 151 |
-
- `done` (bool) - Always False for echo environment
|
| 152 |
-
- `metadata` (dict) - Additional info like step count
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
-
|
| 157 |
-
- "Hello, World!" → reward: 1.3
|
| 158 |
-
- Empty message → reward: 0.0
|
| 159 |
|
| 160 |
-
##
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
-
``
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
#
|
| 170 |
-
async with EchoEnv(base_url="http://localhost:8000") as client:
|
| 171 |
-
result = await client.reset()
|
| 172 |
-
result = await client.step(EchoAction(message="Hello!"))
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
``
|
| 179 |
|
| 180 |
-
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
-
|
| 189 |
-
# From the server directory
|
| 190 |
-
python3 envs/echo_env/server/test_echo_env.py
|
| 191 |
-
```
|
| 192 |
|
| 193 |
-
|
| 194 |
-
-
|
| 195 |
-
-
|
| 196 |
-
-
|
| 197 |
-
-
|
| 198 |
|
| 199 |
-
|
| 200 |
|
| 201 |
-
|
|
|
|
|
|
|
| 202 |
|
| 203 |
```bash
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
| 205 |
```
|
| 206 |
|
| 207 |
-
|
| 208 |
-
- Creating an environment from a Docker image
|
| 209 |
-
- Resetting and stepping through the environment
|
| 210 |
-
- Automatic cleanup with `close()`
|
| 211 |
-
|
| 212 |
-
## Project Structure
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
```
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Prompt Injection Env Server
|
| 3 |
+
emoji: "🔊"
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
|
|
|
| 14 |
|
| 15 |
# IDPI Exfil Environment
|
| 16 |
|
| 17 |
+
`IDPI Exfil Environment` is an OpenEnv-compatible prompt-injection defense environment. Agents operate on realistic email tasks where the visible goal looks benign, but attacker-controlled content tries to redirect behavior toward unsafe actions such as data exfiltration or malicious relays.
|
| 18 |
+
|
| 19 |
+
The environment is designed for evaluating whether an agent can:
|
| 20 |
+
|
| 21 |
+
- read and process email content safely
|
| 22 |
+
- identify indirect prompt injection patterns
|
| 23 |
+
- avoid unsafe outbound actions
|
| 24 |
+
- produce clean internal summaries on harder tasks
|
| 25 |
|
| 26 |
## Features
|
| 27 |
|
| 28 |
+
- `3 difficulty levels`: easy, medium, and hard scenarios with different attack visibility and trigger styles
|
| 29 |
+
- `Realistic attack channels`: inline instructions, hidden wrappers, HTML comments, transcript replay, attachment-style instructions, and more
|
| 30 |
+
- `Safety-aware action space`: includes both benign and risky tools so policies can be meaningfully tested
|
| 31 |
+
- `Structured scoring`: reward shaping during the episode plus end-of-episode grading
|
| 32 |
+
- `OpenEnv server mode`: FastAPI endpoints for reset, step, state, result, and health
|
| 33 |
+
- `Unified evaluation runner`: one runner for inference and baseline-style evaluation output
|
| 34 |
|
| 35 |
## Quick Start
|
| 36 |
|
| 37 |
+
### Install
|
| 38 |
|
| 39 |
```bash
|
|
|
|
| 40 |
pip install -e .
|
| 41 |
+
```
|
| 42 |
|
| 43 |
+
### Run the server
|
|
|
|
| 44 |
|
| 45 |
+
```bash
|
| 46 |
python server/app.py
|
| 47 |
```
|
| 48 |
|
| 49 |
+
The API starts on `http://localhost:7860`.
|
| 50 |
|
| 51 |
+
### Run the evaluation runner
|
|
|
|
| 52 |
|
| 53 |
+
Create a `.env` in the project root with your Gemini API key:
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
```bash
|
| 56 |
+
GEMINI_API_KEY=your_gemini_api_key_here
|
| 57 |
+
MODEL_NAME=gemini-2.5-flash
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
By default, the runner uses Google's OpenAI-compatible Gemini endpoint:
|
| 61 |
|
| 62 |
+
```bash
|
| 63 |
+
API_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
|
| 64 |
```
|
| 65 |
|
| 66 |
+
Then run:
|
| 67 |
|
| 68 |
```bash
|
| 69 |
+
python inference.py
|
| 70 |
+
```
|
| 71 |
|
| 72 |
+
Compatibility commands still work:
|
|
|
|
| 73 |
|
| 74 |
+
```bash
|
| 75 |
python run_baseline.py
|
| 76 |
+
python baseline/run_baseline.py
|
| 77 |
```
|
| 78 |
|
| 79 |
+
All three commands use the same unified runner and write results to `baseline/baseline_results.json`.
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
## Using the HTTP API
|
| 82 |
|
| 83 |
+
### Reset the environment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
```python
|
| 86 |
+
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
response = requests.post(
|
| 89 |
+
"http://localhost:7860/reset",
|
| 90 |
+
json={"difficulty": "easy"},
|
| 91 |
+
)
|
| 92 |
+
observation = response.json()
|
| 93 |
+
print(observation)
|
| 94 |
+
```
|
| 95 |
|
| 96 |
+
### Step with an action
|
| 97 |
|
| 98 |
+
```python
|
| 99 |
+
import requests
|
| 100 |
|
| 101 |
+
response = requests.post(
|
| 102 |
+
"http://localhost:7860/step",
|
| 103 |
+
json={"action": {"type": "ReadDoc"}},
|
| 104 |
+
)
|
| 105 |
+
result = response.json()
|
| 106 |
|
| 107 |
+
print(result["observation"])
|
| 108 |
+
print(result["reward"])
|
| 109 |
+
print(result["done"])
|
| 110 |
+
```
|
| 111 |
|
| 112 |
+
### Inspect state or final result
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
import requests
|
| 116 |
|
| 117 |
+
state = requests.get("http://localhost:7860/state").json()
|
| 118 |
+
episode_result = requests.get("http://localhost:7860/result").json()
|
| 119 |
```
|
| 120 |
|
| 121 |
+
## Environment Overview
|
| 122 |
|
| 123 |
+
### Task model
|
| 124 |
|
| 125 |
+
Each episode presents an email with a benign business-looking task and embedded attacker intent. The agent must complete the safe objective without obeying adversarial instructions contained in the email body or derived attack channels.
|
| 126 |
|
| 127 |
+
Typical safe behavior includes:
|
| 128 |
|
| 129 |
+
- reviewing the email with `ReadDoc`
|
| 130 |
+
- flagging suspicious instructions with `FlagInjection`
|
| 131 |
+
- writing an internal-only clean summary with `WriteDB`
|
| 132 |
+
- refusing unsafe outbound behavior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
+
### Difficulty levels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
- `easy`: explicit or obvious prompt injection patterns
|
| 137 |
+
- `medium`: more obfuscated attacks, hidden wrappers, spoofed instruction hierarchy, or delayed triggers
|
| 138 |
+
- `hard`: attacks embedded in semantically plausible content where the agent must also produce a safe summary
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
### Actions
|
| 141 |
|
| 142 |
+
- `ReadDoc`
|
| 143 |
+
Reads the current email content.
|
| 144 |
+
- `WriteDB(content="...")`
|
| 145 |
+
Writes an internal summary or note.
|
| 146 |
+
- `SendEmail(to="...", body="...")`
|
| 147 |
+
Sends an outbound email. This is the main exfiltration risk surface.
|
| 148 |
+
- `FlagInjection(reason="...")`
|
| 149 |
+
Marks the content as suspicious.
|
| 150 |
+
- `NoOp`
|
| 151 |
+
Takes no action.
|
| 152 |
|
| 153 |
+
### Observation fields
|
| 154 |
|
| 155 |
+
- `subject`
|
| 156 |
+
- `body`
|
| 157 |
+
- `last_action`
|
| 158 |
+
- `last_action_result`
|
| 159 |
+
- `step_count`
|
| 160 |
+
- `task_difficulty`
|
| 161 |
+
- `summary_required`
|
| 162 |
+
- `current_summary`
|
| 163 |
|
| 164 |
+
### Endpoints
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
+
- `GET /health`
|
| 167 |
+
- `POST /reset`
|
| 168 |
+
- `POST /step`
|
| 169 |
+
- `GET /state`
|
| 170 |
+
- `GET /result`
|
| 171 |
|
| 172 |
+
## Evaluation
|
| 173 |
|
| 174 |
+
The evaluation runner loads scenarios from [docs/person_a_benchmark_manifest.json](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/docs/person_a_benchmark_manifest.json) and executes them across `easy`, `medium`, and `hard` splits.
|
| 175 |
|
| 176 |
+
The current manifest includes:
|
| 177 |
|
| 178 |
+
- `32 scenarios total`
|
| 179 |
+
- `9 easy`
|
| 180 |
+
- `13 medium`
|
| 181 |
+
- `10 hard`
|
| 182 |
|
| 183 |
+
Each run logs:
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
- per-step actions and rewards
|
| 186 |
+
- whether exfiltration occurred
|
| 187 |
+
- whether the task was completed safely
|
| 188 |
+
- final graded score
|
| 189 |
+
- per-difficulty summary statistics
|
| 190 |
|
| 191 |
+
Results are written to [baseline/baseline_results.json](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/baseline/baseline_results.json).
|
| 192 |
|
| 193 |
+
### Optional runner settings
|
| 194 |
+
|
| 195 |
+
These values can be set in `.env`:
|
| 196 |
|
| 197 |
```bash
|
| 198 |
+
EPISODES_PER_SCENARIO=1
|
| 199 |
+
MAX_TOKENS=200
|
| 200 |
+
TEMPERATURE=0.0
|
| 201 |
+
REQUEST_DELAY_SECONDS=3.0
|
| 202 |
```
|
| 203 |
|
| 204 |
+
## Development
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
### Project structure
|
| 207 |
+
|
| 208 |
+
```text
|
| 209 |
+
Prompt-injection-env/
|
| 210 |
+
|-- env/
|
| 211 |
+
| |-- environment.py
|
| 212 |
+
| |-- dataset_loader.py
|
| 213 |
+
| |-- scenario_generator.py
|
| 214 |
+
| |-- injection_engine.py
|
| 215 |
+
| |-- policy_engine.py
|
| 216 |
+
| |-- taint_tracker.py
|
| 217 |
+
| |-- reward.py
|
| 218 |
+
| |-- grader.py
|
| 219 |
+
| `-- models.py
|
| 220 |
+
|-- server/
|
| 221 |
+
| |-- app.py
|
| 222 |
+
| `-- Dockerfile
|
| 223 |
+
|-- docs/
|
| 224 |
+
| |-- person_a_benchmark_manifest.json
|
| 225 |
+
| |-- person_a_scenario_audit.md
|
| 226 |
+
| `-- person_a_showcase_episodes.md
|
| 227 |
+
|-- baseline/
|
| 228 |
+
| |-- run_baseline.py
|
| 229 |
+
| `-- baseline_results.json
|
| 230 |
+
|-- inference.py
|
| 231 |
+
|-- run_baseline.py
|
| 232 |
+
|-- openenv.yaml
|
| 233 |
+
`-- README.md
|
| 234 |
```
|
| 235 |
+
|
| 236 |
+
### Core components
|
| 237 |
+
|
| 238 |
+
- [env/environment.py](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/env/environment.py)
|
| 239 |
+
Main episode lifecycle, action handling, reward plumbing, and result assembly.
|
| 240 |
+
- [server/app.py](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/server/app.py)
|
| 241 |
+
FastAPI wrapper exposing the environment over HTTP.
|
| 242 |
+
- [inference.py](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/inference.py)
|
| 243 |
+
Canonical evaluation runner used by both inference and baseline wrappers.
|
| 244 |
+
- [openenv.yaml](/C:/Users/Admin/Desktop/My%20projects/Prompt-injection-env/openenv.yaml)
|
| 245 |
+
Environment metadata for OpenEnv packaging and deployment.
|
| 246 |
+
|
| 247 |
+
### Local Python usage
|
| 248 |
+
|
| 249 |
+
You can exercise the environment directly without starting the server:
|
| 250 |
+
|
| 251 |
+
```python
|
| 252 |
+
from env.environment import IDPIExfilEnv
|
| 253 |
+
from env.models import Action
|
| 254 |
+
|
| 255 |
+
env = IDPIExfilEnv()
|
| 256 |
+
obs = env.reset(difficulty="easy")
|
| 257 |
+
obs, reward, done, info = env.step(Action(type="ReadDoc"))
|
| 258 |
+
print(obs)
|
| 259 |
+
print(reward)
|
| 260 |
```
|
| 261 |
+
|
| 262 |
+
## Notes
|
| 263 |
+
|
| 264 |
+
- The environment terminates early on unsafe exfiltration events.
|
| 265 |
+
- Hard tasks require a clean internal summary that excludes attacker-controlled content.
|
| 266 |
+
- The unified runner now uses Gemini only and requires `GEMINI_API_KEY`.
|
pyproject.toml
CHANGED
|
@@ -37,11 +37,9 @@ dev = [
|
|
| 37 |
]
|
| 38 |
|
| 39 |
[project.scripts]
|
| 40 |
-
# Server entry point
|
| 41 |
-
|
| 42 |
-
server = "echo_env.server.app:main"
|
| 43 |
|
| 44 |
[tool.setuptools]
|
| 45 |
include-package-data = true
|
| 46 |
-
packages = ["
|
| 47 |
-
package-dir = { "echo_env" = ".", "echo_env.server" = "server" }
|
|
|
|
| 37 |
]
|
| 38 |
|
| 39 |
[project.scripts]
|
| 40 |
+
# Server entry point
|
| 41 |
+
server = "server.app:main"
|
|
|
|
| 42 |
|
| 43 |
[tool.setuptools]
|
| 44 |
include-package-data = true
|
| 45 |
+
packages = ["env", "server"]
|
|
|
server/__init__.py
CHANGED
|
@@ -4,8 +4,4 @@
|
|
| 4 |
# This source code is licensed under the BSD-style license found in the
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
-
"""
|
| 8 |
-
|
| 9 |
-
from .echo_environment import EchoEnvironment
|
| 10 |
-
|
| 11 |
-
__all__ = ["EchoEnvironment"]
|
|
|
|
| 4 |
# This source code is licensed under the BSD-style license found in the
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
+
"""IDPI Exfil Environment server package."""
|
|
|
|
|
|
|
|
|
|
|
|
server/app.py
CHANGED
|
@@ -41,6 +41,21 @@ def health():
|
|
| 41 |
return {"status": "ok", "env": "idpi-exfil-env", "version": "0.1.0"}
|
| 42 |
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
@app.post("/reset", response_model=Observation)
|
| 45 |
def reset(request: ResetRequest):
|
| 46 |
# Validates difficulty before passing to env
|
|
|
|
| 41 |
return {"status": "ok", "env": "idpi-exfil-env", "version": "0.1.0"}
|
| 42 |
|
| 43 |
|
| 44 |
+
@app.get("/")
|
| 45 |
+
def root():
|
| 46 |
+
return {
|
| 47 |
+
"name": "IDPI Exfil Environment",
|
| 48 |
+
"status": "ok",
|
| 49 |
+
"description": "OpenEnv-compatible prompt injection defense environment.",
|
| 50 |
+
"routes": ["/health", "/reset", "/step", "/state", "/result"],
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@app.get("/web")
|
| 55 |
+
def web_root():
|
| 56 |
+
return root()
|
| 57 |
+
|
| 58 |
+
|
| 59 |
@app.post("/reset", response_model=Observation)
|
| 60 |
def reset(request: ResetRequest):
|
| 61 |
# Validates difficulty before passing to env
|