Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def _remote_terminal_workspace_candidate(path: str | Path) -> Path | None:
return None
candidate = Path(raw).expanduser().resolve()
base = Path(cwd).expanduser().resolve()
if _is_blocked_workspace_path(candidate, raw) or _is_blocked_workspace_path(base, cwd):
return None
if candidate == base or _is_within(candidate, base):
return candidate
return None
Expand Down
11 changes: 11 additions & 0 deletions tests/test_remote_terminal_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ def test_remote_terminal_workspace_paths_outside_cwd_still_reject(monkeypatch):

with pytest.raises(ValueError, match="Path does not exist"):
workspace.resolve_trusted_workspace("/Users/other/projects/demo")


@pytest.mark.parametrize("workspace_path", ["/etc", "/etc/ssh"])
def test_remote_terminal_workspace_system_roots_still_reject(monkeypatch, workspace_path):
monkeypatch.setattr(api_config, "get_config", lambda: _remote_config(terminal={"backend": "ssh", "cwd": "/etc"}))

with pytest.raises(ValueError, match="Path points to a system directory"):
workspace.validate_workspace_to_add(workspace_path)

with pytest.raises(ValueError, match="Path points to a system directory"):
workspace.resolve_trusted_workspace(workspace_path)
Loading