remove path traversal restriction from file tools
Container isolation is sufficient — agents can access the full filesystem. Absolute paths are passed through as-is.
This commit is contained in:
+2
-5
@@ -483,11 +483,8 @@ def _get_pty(session_id: str) -> PtySession:
|
|||||||
|
|
||||||
|
|
||||||
def _workspace_path(rel: str) -> pathlib.Path:
|
def _workspace_path(rel: str) -> pathlib.Path:
|
||||||
"""Resolve a relative path inside WORKSPACE, reject path traversal."""
|
p = pathlib.Path(rel)
|
||||||
p = (pathlib.Path(WORKSPACE) / rel).resolve()
|
return p if p.is_absolute() else pathlib.Path(WORKSPACE) / rel
|
||||||
if not str(p).startswith(str(pathlib.Path(WORKSPACE).resolve())):
|
|
||||||
raise ValueError(f"Path escapes workspace: {rel}")
|
|
||||||
return p
|
|
||||||
|
|
||||||
|
|
||||||
def _get_job(job_id: str) -> BackgroundJob:
|
def _get_job(job_id: str) -> BackgroundJob:
|
||||||
|
|||||||
Reference in New Issue
Block a user