Files
iAs/docker/build-images.sh
T
wunianxiao 20f7c3ba9c feat(sandbox): Docker 一次性容器执行隔离边界(步骤 6-7)
引入两类安全边界:统一审批=授权边界(上一提交),一次性 Docker
容器=执行隔离边界(本提交)。LLM 即使执行恶意代码也只能在受限容器
内运行。

spec.rs: 新增 SandboxSpec(profile/network/memory/cpus/pids_limit/
  read_only),默认 profile=local 不启用容器。
executor.rs: 按 sandbox.profile 选择执行后端
  - local: 本地 spawn(env_clear + 白名单注入)
  - stdio: ias-stdio-runner,--network none --read-only --cap-drop ALL
    --security-opt no-new-privileges,仅 bind mount 工具二进制(ro)+tmpfs /tmp
  - network: ias-network-runner(预留自行联网工具)
  - builder: ias-tool-builder(供 tool_manager 编译)
  全局开关 IAS_DOCKER_SANDBOX=1,未启用时行为不变(向后兼容)。
tool_manager: build_tool 支持 IAS_DOCKER_BUILDER=1 在 ias-tool-builder
  容器内离线编译(--network none,挂载 tool_dir 到 /work)。
docker/: 三类 Dockerfile + build-images.sh 构建脚本。
  - stdio-runner: debian-slim + ca-certificates,无网络只读
  - network-runner: 预留联网工具
  - tool-builder: rust:1.88-slim 预缓存 serde_json,支持离线编译
spec 迁移: 17 个普通工具追加 sandbox.profile: stdio;tool_manager
  保持 local(自身在宿主操作文件系统)。

端到端验证: datetime 工具本地模式 +08:00,Docker 模式 +00:00(UTC),
  --rm 无容器残留。
2026-06-22 11:38:42 +08:00

17 lines
603 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 构建三类沙箱基础镜像。无需为每个工具单独写 Dockerfile。
set -euo pipefail
cd "$(dirname "$0")" # docker/
echo "=== 构建 ias-stdio-runner(无网络只读容器)==="
docker build -t ias-stdio-runner -f Dockerfile.stdio-runner .
echo "=== 构建 ias-network-runner(联网容器)==="
docker build -t ias-network-runner -f Dockerfile.network-runner .
echo "=== 构建 ias-tool-builderRust 编译容器)==="
docker build -t ias-tool-builder -f Dockerfile.tool-builder .
echo "=== 完成 ==="
docker images | grep -E '^ias-(stdio|network|tool)'