subprocess_sandbox
subprocess_sandbox
¶
Subprocess sandbox — secure process execution with environment isolation.
Classes¶
SandboxResult
dataclass
¶
SandboxResult(stdout: str = '', stderr: str = '', returncode: int = -1, timed_out: bool = False, killed: bool = False)
Result of a sandboxed subprocess execution.
Functions¶
build_safe_env
¶
build_safe_env(passthrough: Optional[List[str]] = None, extra: Optional[Dict[str, str]] = None) -> Dict[str, str]
Build a sanitized environment dict.
Only copies safe vars from current env, plus any in passthrough list. Extra vars are added directly.
Source code in src/openjarvis/security/subprocess_sandbox.py
kill_process_tree
¶
Kill a process and all its children (best effort).
Source code in src/openjarvis/security/subprocess_sandbox.py
run_sandboxed
¶
run_sandboxed(command: str, *, timeout: float = 30.0, working_dir: Optional[str] = None, env_passthrough: Optional[List[str]] = None, env_extra: Optional[Dict[str, str]] = None, max_output_bytes: int = 102400) -> SandboxResult
Execute a command in a sandboxed subprocess.
Features: - Clean environment (only safe vars passed through) - Timeout enforcement with process tree kill - Output truncation - New process group for clean cleanup