Skip to content

Commit 362ccd9

Browse files
committed
ISSUE-690: Restore model type guard to restrict non-remote models
1 parent 831c2b4 commit 362ccd9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

server/autotest_server/testers/ai/ai_tester.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ def call_ai_feedback(self) -> dict:
8585
output_mode = test_group.get("output")
8686
cmd = [sys.executable, "-m", "ai_feedback"]
8787

88+
# Restrict to remote model only — prevent access to cloud AIs
89+
if config.get("model", "") != "remote":
90+
results[test_label] = {
91+
"title": test_label,
92+
"status": "error",
93+
"message": f"Unsupported model type: \"{config.get('model', '')}\". Only 'remote' model is allowed.",
94+
}
95+
return results
96+
8897
# Validate remote_url against whitelist
8998
remote_url = config.get("remote_url", self.DEFAULT_REMOTE_URL)
9099
whitelisted_urls = self._load_whitelisted_urls()

server/autotest_server/tests/testers/ai/test_ai_tester.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,41 @@ def test_call_ai_feedback_accepts_whitelisted_url(monkeypatch):
142142
assert results["Test A"]["status"] == "success"
143143

144144

145+
def test_call_ai_feedback_rejects_non_remote_model():
146+
"""Non-remote models (e.g., cloud AIs) should be blocked."""
147+
parent_dir = str(Path(__file__).resolve().parent)
148+
spec = {
149+
"tester_type": "ai",
150+
"env_data": {"ai_feedback_version": "main"},
151+
"test_data": {
152+
"category": ["instructor"],
153+
"config": {
154+
"model": "openai",
155+
"prompt": "code_table",
156+
"scope": "code",
157+
"submission": parent_dir + "/fixtures/sample_submission.py",
158+
"submission_type": "python",
159+
},
160+
"extra_info": {
161+
"name": "AI FEEDBACK COMMENTS",
162+
"display_output": "instructors",
163+
"test_group_id": 17,
164+
"criterion": None,
165+
},
166+
"output": "overall_comment",
167+
"timeout": 30,
168+
"test_label": "Test A",
169+
},
170+
"_env": {"PYTHON": "/home/docker/.autotesting/scripts/128/ai_1/bin/python3"},
171+
}
172+
import json as _json
173+
tester = AiTester(specs=TestSpecs.from_json(_json.dumps(spec)))
174+
results = tester.call_ai_feedback()
175+
assert results["Test A"]["status"] == "error"
176+
assert "Unsupported model type" in results["Test A"]["message"]
177+
assert "openai" in results["Test A"]["message"]
178+
179+
145180
def test_call_ai_feedback_empty_whitelist(mock_whitelist_config):
146181
"""When no URLs are configured in settings, all remote URLs should be rejected."""
147182
mock_whitelist_config.get.side_effect = lambda key, default=None: (

0 commit comments

Comments
 (0)