Skip to content

Commit ecce15b

Browse files
Potential fix for pull request finding 'CodeQL / Information exposure through an exception'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent fe105d1 commit ecce15b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

backend_api_python/app/utils/safe_exec.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,12 @@ def validate_code_safety(code: str) -> Tuple[bool, Optional[str]]:
411411
try:
412412
tree = ast.parse(code)
413413
except SyntaxError as e:
414-
return False, f"代码语法错误: {e}"
414+
logger.warning(f"Code syntax validation failed: {e}")
415+
return False, "代码语法错误"
415416
except Exception as e:
416417
# AST parse failure → reject (fail-closed, not fail-open)
417-
logger.error(f"AST parse failed, rejecting code: {e}")
418-
return False, f"代码解析失败: {e}"
418+
logger.exception("AST parse failed, rejecting code")
419+
return False, "代码解析失败"
419420

420421
dangerous_modules = {
421422
'os', 'sys', 'subprocess', 'shutil', 'signal', 'resource',

0 commit comments

Comments
 (0)