mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 15:37:44 +00:00
fix(security): replace eval() with ast.literal_eval and add request timeouts (B307, B113)
- submit.py: eval(json_str) → ast.literal_eval(json_str) for safe Python-literal parsing without arbitrary code execution - info.py: add timeout=30 to both requests.get() calls to prevent indefinite hangs on unresponsive GitHub API Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,11 +54,11 @@ def rdagent_info():
|
||||
current_version = importlib.metadata.version("rdagent")
|
||||
logger.info(f"RD-Agent version: {current_version}")
|
||||
api_url = f"https://api.github.com/repos/microsoft/RD-Agent/contents/requirements.txt?ref=main"
|
||||
response = requests.get(api_url)
|
||||
response = requests.get(api_url, timeout=30)
|
||||
if response.status_code == 200:
|
||||
files = response.json()
|
||||
file_url = files["download_url"]
|
||||
file_response = requests.get(file_url)
|
||||
file_response = requests.get(file_url, timeout=30)
|
||||
if file_response.status_code == 200:
|
||||
all_file_contents = file_response.text.split("\n")
|
||||
else:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import pickle
|
||||
@@ -587,8 +588,8 @@ def _parsing_score(grade_stdout: str) -> Optional[float]:
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
# Priority 2: Eval dict
|
||||
return float(eval(json_str)["score"])
|
||||
# Priority 2: safe literal eval for Python-style dicts
|
||||
return float(ast.literal_eval(json_str)["score"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user