CI fix: reject Windows drive-letter paths in _safe_root (os.path.isabs is POSIX-only on Linux runners)

This commit is contained in:
DistributedApps.AI
2026-08-31 11:38:02 -04:00
parent 69066b3368
commit 0363334582
+4 -2
View File
@@ -31,11 +31,13 @@ def create_app(test_config=None) -> Flask:
def _safe_root(root: str) -> str:
"""Reject absolute paths and path traversal; normalize to a relative name."""
"""Reject absolute paths (POSIX + Windows drive/UNC) and path traversal;
normalize to a relative name. Must be platform-independent (tests run on Linux)."""
root = (root or "").strip().replace("\\", "/").strip("/")
if not root:
raise ValueError("workspace root must not be empty")
if os.path.isabs(root):
drive = len(root) >= 2 and root[1] == ":" and root[0].isalpha() # C:/...
if os.path.isabs(root) or drive or root.startswith("//"):
raise ValueError("workspace root must be a relative path")
if any(part == ".." for part in root.split("/")):
raise ValueError("workspace root must not contain '..'")