Skip to content
Open
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
15 changes: 2 additions & 13 deletions backend/app/hands/environment_hands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,8 @@ def can_execute_terminal(self) -> bool:
def can_access_filesystem(self, path: str) -> bool:
if self._caps.filesystem_scope == "full":
try:
resolved = Path(path).expanduser().resolve()
home = Path.home()
workspace = self.workspace_root.resolve()
try:
resolved.relative_to(home)
return True
except ValueError:
pass
try:
resolved.relative_to(workspace)
return True
except ValueError:
return False
Path(path).expanduser().resolve()
return True
except (OSError, RuntimeError):
return False
if self._caps.filesystem_scope == "workspace_only":
Expand Down
38 changes: 38 additions & 0 deletions backend/tests/app/hands/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# limitations under the License.
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========

from pathlib import Path

import pytest

from app.hands import capabilities
Expand Down Expand Up @@ -66,3 +68,39 @@ def test_detect_capabilities_uses_terminal_shell_probe(monkeypatch):

assert caps.has_terminal is True
assert hands.can_execute_terminal() is True


@pytest.mark.unit
def test_environment_hands_full_scope_allows_path_outside_workspace(tmp_path):
workspace = tmp_path / "workspace"
workspace.mkdir()

# Use the filesystem root so this path is outside both the configured
# workspace and the user's home directory on Windows and POSIX runners.
outside = Path(tmp_path.anchor) / "eigent-full-scope-test"

caps = capabilities.BrainCapabilities(
filesystem_scope="full",
workspace_root=workspace,
)
hands = EnvironmentHands(caps)

assert hands.can_access_filesystem(str(outside)) is True


@pytest.mark.unit
def test_environment_hands_workspace_only_stays_restricted(tmp_path):
workspace = tmp_path / "workspace"
workspace.mkdir()
inside = workspace / "project"
inside.mkdir()
outside = Path(tmp_path.anchor) / "eigent-workspace-only-test"

caps = capabilities.BrainCapabilities(
filesystem_scope="workspace_only",
workspace_root=workspace,
)
hands = EnvironmentHands(caps)

assert hands.can_access_filesystem(str(inside)) is True
assert hands.can_access_filesystem(str(outside)) is False