Loading...
Loading...
Compare original and translation side by side
graph TD
A[Agent Task] --> B{Trust Level Assessment}
B -->|Internal Dev| C[Process Sandbox]
B -->|Multi-Tenant| D[Container Sandbox]
B -->|Untrusted Code| E[VM Sandbox]
C --> F[seccomp + AppArmor Profile]
D --> G[Docker: No Root + Read-Only FS]
E --> H[Firecracker microVM]
F --> I[Resource Limits: CPU, Memory, Disk]
G --> I
H --> I
I --> J[Network Policy: Allowlist Only]
J --> K[Filesystem: Scoped Mount]
K --> L[Monitoring: Syscall Audit]
L --> M[Execution within Sandbox]graph TD
A[Agent Task] --> B{Trust Level Assessment}
B -->|Internal Dev| C[Process Sandbox]
B -->|Multi-Tenant| D[Container Sandbox]
B -->|Untrusted Code| E[VM Sandbox]
C --> F[seccomp + AppArmor Profile]
D --> G[Docker: No Root + Read-Only FS]
E --> H[Firecracker microVM]
F --> I[Resource Limits: CPU, Memory, Disk]
G --> I
H --> I
I --> J[Network Policy: Allowlist Only]
J --> K[Filesystem: Scoped Mount]
K --> L[Monitoring: Syscall Audit]
L --> M[Execution within Sandbox]undefinedundefined
```yaml
```yaml
```python
import resource
import os
class ProcessSandbox:
"""Process-level sandboxing for single-tenant development."""
@staticmethod
def apply_limits(
max_memory_mb: int = 256,
max_cpu_seconds: int = 30,
max_file_size_mb: int = 10,
max_open_files: int = 64,
max_processes: int = 10,
):
mb = 1024 * 1024
resource.setrlimit(resource.RLIMIT_AS, (max_memory_mb * mb, max_memory_mb * mb))
resource.setrlimit(resource.RLIMIT_CPU, (max_cpu_seconds, max_cpu_seconds))
resource.setrlimit(resource.RLIMIT_FSIZE, (max_file_size_mb * mb, max_file_size_mb * mb))
resource.setrlimit(resource.RLIMIT_NOFILE, (max_open_files, max_open_files))
resource.setrlimit(resource.RLIMIT_NPROC, (max_processes, max_processes))
@staticmethod
def restrict_filesystem(allowed_dirs: list[str]):
"""Use chroot or bind mounts to restrict filesystem access."""
for d in allowed_dirs:
assert os.path.isabs(d), f"Allowed dirs must be absolute: {d}"
assert os.path.exists(d), f"Allowed dir does not exist: {d}"
@staticmethod
def validate_command(command: str, blocklist: list[str]) -> bool:
"""Check command against blocklist before execution."""
return not any(blocked in command for blocked in blocklist)
COMMAND_BLOCKLIST = [
"rm -rf /", "mkfs", "dd if=", "> /dev/sd",
"curl | sh", "wget | bash", "chmod 777",
"iptables", "mount", "umount",
]
```python
import resource
import os
class ProcessSandbox:
"""Process-level sandboxing for single-tenant development."""
@staticmethod
def apply_limits(
max_memory_mb: int = 256,
max_cpu_seconds: int = 30,
max_file_size_mb: int = 10,
max_open_files: int = 64,
max_processes: int = 10,
):
mb = 1024 * 1024
resource.setrlimit(resource.RLIMIT_AS, (max_memory_mb * mb, max_memory_mb * mb))
resource.setrlimit(resource.RLIMIT_CPU, (max_cpu_seconds, max_cpu_seconds))
resource.setrlimit(resource.RLIMIT_FSIZE, (max_file_size_mb * mb, max_file_size_mb * mb))
resource.setrlimit(resource.RLIMIT_NOFILE, (max_open_files, max_open_files))
resource.setrlimit(resource.RLIMIT_NPROC, (max_processes, max_processes))
@staticmethod
def restrict_filesystem(allowed_dirs: list[str]):
"""Use chroot or bind mounts to restrict filesystem access."""
for d in allowed_dirs:
assert os.path.isabs(d), f"Allowed dirs must be absolute: {d}"
assert os.path.exists(d), f"Allowed dir does not exist: {d}"
@staticmethod
def validate_command(command: str, blocklist: list[str]) -> bool:
"""Check command against blocklist before execution."""
return not any(blocked in command for blocked in blocklist)
COMMAND_BLOCKLIST = [
"rm -rf /", "mkfs", "dd if=", "> /dev/sd",
"curl | sh", "wget | bash", "chmod 777",
"iptables", "mount", "umount",
]no-new-privilegesno-new-privileges| Platform | Support | Notes |
|---|---|---|
| Cursor | Full | Docker + process sandboxing |
| VS Code | Full | Dev container support |
| Windsurf | Full | Sandbox configuration |
| Claude Code | Full | Container-based isolation |
| Cline | Full | Security boundary config |
| aider | Partial | Process-level only |
| 平台 | 支持情况 | 备注 |
|---|---|---|
| Cursor | 完整支持 | Docker + 进程沙箱 |
| VS Code | 完整支持 | 开发容器支持 |
| Windsurf | 完整支持 | 沙箱配置 |
| Claude Code | 完整支持 | 基于容器的隔离 |
| Cline | 完整支持 | 安全边界配置 |
| aider | 部分支持 | 仅支持进程级隔离 |
sandboxcontainer-securityisolationleast-privilegeresource-limitsseccompdocker-hardeningagent-isolationsandboxcontainer-securityisolationleast-privilegeresource-limitsseccompdocker-hardeningagent-isolation