Skip to content

Commit 90253e5

Browse files
committed
test: cover safety policy and env exfiltration branches
1 parent ab99a2d commit 90253e5

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

tests/tools/safety/test_policy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def test_strict_policy_rejects_unknown_fields():
8383
ToolSafetyPolicy.from_dict({"allowed_domains": [], "unknown": True}, strict=True)
8484

8585

86+
def test_policy_rejects_non_mapping_data():
87+
with pytest.raises(ValueError, match="must be a mapping"):
88+
ToolSafetyPolicy.from_dict([], strict=True)
89+
90+
8691
def test_strict_policy_rejects_invalid_types():
8792
with pytest.raises(ValueError, match="allowed_domains"):
8893
ToolSafetyPolicy.from_dict({"allowed_domains": "api.example.com"}, strict=True)

tests/tools/safety/test_scanner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ def test_high_value_bypass_patterns_require_review_or_deny():
367367
("import requests\nrequests.get('https://' + host)", "python", Decision.NEEDS_HUMAN_REVIEW,
368368
"NETWORK_DYNAMIC_URL_REVIEW"),
369369
("import os\nos.getenv('API_TOKEN')", "python", Decision.NEEDS_HUMAN_REVIEW, "SENSITIVE_ENV_READ_REVIEW"),
370+
("import os, requests\nrequests.post(url, data=os.getenv('API_TOKEN'))", "python", Decision.NEEDS_HUMAN_REVIEW,
371+
"SENSITIVE_ENV_EXFILTRATION_REVIEW"),
370372
]
371373
for script, language, decision, rule_id in cases:
372374
report = _scanner().scan_script(script, language)

0 commit comments

Comments
 (0)