ReMe/reme/steps/common/file_sandbox.py
xyf2020 e5bbb85e54
fix(python): sandbox Python execution and disable benchmark service exposure (#708)
* fix: sandbox Python execution and disable benchmark service exposure

* fix: preserve optional sandbox policy for AutoBash

* fix: sandbox AutoBash with a read-only workspace by default

* fix: preserve sandboxed Python timeout diagnostics

* Simplify Python timeout handling and sandbox workspace defaults

* fix: require patched core for home and allow sandboxed Apple Git

* fix: preserve Python execution workspace directory

* fix: cap Python execution timeouts and allow Xcode Git runtime

* Fix macOS sandbox Git resolution and add Xcode CI coverage

* Make Seatbelt runtime grant test independent of host Xcode symlinks
2026-11-04 14:31:59 +08:00

23 lines
1 KiB
Python

"""Resolve executor sandbox policies."""
from ...utils.file_sandbox import create_file_sandbox_backend
from ...utils.file_sandbox.file_sandbox_backend import FileSandboxBackend
from ..base_step import BaseStep
def file_sandbox_for_step(step: BaseStep) -> FileSandboxBackend:
"""Default to a read-only workspace; callers cannot supply path grants."""
assert step.context is not None
for name in ("read_only_paths", "writable_paths"):
if name in step.context:
raise ValueError(f"{name} must be configured on the Step, not supplied by the caller")
workspace = step.workspace_path.resolve()
read_only_paths = step.kwargs.get("read_only_paths", [])
writable_paths = step.kwargs.get("writable_paths", [])
memory_limit_mib = step.context.get("memory_limit_mib", step.kwargs.get("memory_limit_mib"))
return create_file_sandbox_backend(
cwd=workspace,
read_only_paths=read_only_paths,
writable_paths=writable_paths,
memory_limit_mib=memory_limit_mib,
)