Spaces:
Sleeping
Sleeping
Commit ·
b81d32a
1
Parent(s): d512522
test(environment): add framing sanitization tests for script and javascript injection
Browse files
tests/test_environment.py
CHANGED
|
@@ -35,3 +35,12 @@ async def test_guards():
|
|
| 35 |
env.turn = 10
|
| 36 |
with pytest.raises(ValueError, match="Episode already complete"):
|
| 37 |
await env.step(action)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
env.turn = 10
|
| 36 |
with pytest.raises(ValueError, match="Episode already complete"):
|
| 37 |
await env.step(action)
|
| 38 |
+
|
| 39 |
+
def test_framing_sanitization():
|
| 40 |
+
action = AttackAction(
|
| 41 |
+
strategy_type="roleplay", target_category="privacy", intensity=0.5,
|
| 42 |
+
framing="<script>alert(1)</script> javascript:void(0)"
|
| 43 |
+
)
|
| 44 |
+
assert "<script>" not in action.framing
|
| 45 |
+
assert "javascript:" not in action.framing
|
| 46 |
+
assert "[FILTERED]" in action.framing
|