Skip to content

fix(sandbox): 收敛沙箱 SSH 暴露并保留 GitHub 访问#579

Merged
CodeCasterX merged 2 commits into
mainfrom
agent-infra-chore-sandbox-ssh-github-access
Jul 7, 2026
Merged

fix(sandbox): 收敛沙箱 SSH 暴露并保留 GitHub 访问#579
CodeCasterX merged 2 commits into
mainfrom
agent-infra-chore-sandbox-ssh-github-access

Conversation

@CodeCasterX

Copy link
Copy Markdown
Contributor

🔗 相关问题 / Related Issue

Issue 链接 / Issue Link: Closes #576 👈👈

  • 我已经创建了相关 Issue 并进行了讨论 / I have created and discussed the related issue
  • 这是一个微小的修改(如错别字),不需要 Issue / This is a trivial change (like typo fix) that doesn't need an issue

📋 变更类型 / Type of Change

  • 🐛 Bug 修复 / Bug fix (non-breaking change which fixes an issue)
  • ✨ 新功能 / New feature (non-breaking change which adds functionality)
  • 💥 破坏性变更 / Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • 📚 文档更新 / Documentation update
  • 🔧 重构 / Refactoring (no functional changes)
  • ⚡ 性能优化 / Performance improvement
  • 📦 依赖升级 / Dependency upgrade (update dependencies to newer versions)
  • 🚀 功能增强 / Feature enhancement (improve existing functionality without breaking changes)
  • 🧹 代码清理 / Code cleanup

📝 变更目的 / Purpose of the Change

当前默认沙箱会把宿主机 ~/.ssh 只读挂载到容器 /home/devuser/.ssh,导致个人 SSH config、known_hosts、私钥、pem 文件和跳板机配置进入通用 agent 沙箱。本次变更收敛默认暴露面:移除通用 SSH 挂载,同时保留既有 gh auth token -> GH_TOKEN 的 GitHub CLI / HTTPS token 访问路径。

📋 主要变更 / Brief Changelog

  • 删除 ai sandbox create 中宿主 ~/.ssh 到容器 /home/devuser/.ssh 的默认只读挂载。
  • 新增创建流程回归测试,验证 Docker run 参数不包含 /home/devuser/.ssh,且 /workspace/share/common/share/branch 核心挂载仍存在。
  • 将 engine path 测试中的 .ssh 示例替换为非敏感 .cache 示例,保留 WSL2/native/SELinux 覆盖。
  • 更新中英文 sandbox 与 platform-support 文档,明确 GitHub 访问走 gh / HTTPS token,既有沙箱需删除并重建以移除旧挂载。

🧪 验证变更 / Verifying this Change

测试步骤 / Test Steps

  1. node --experimental-strip-types --no-warnings --test tests/integration/cli/sandbox-core.test.ts
  2. npm run test:core
  3. npm test
  4. Commit hook: npm run typecheck
  5. Commit hook: npm run test:core

测试覆盖 / Test Coverage

  • 我已经添加了单元测试 / I have added unit tests
  • 所有现有测试都通过 / All existing tests pass
  • 我已经进行了手动测试 / I have performed manual testing

📸 截图 / Screenshots

N/A

✅ 贡献者检查清单 / Contributor Checklist

基本要求 / Basic Requirements:

  • 确保有 GitHub Issue 对应这个变更(微小变更如错别字除外)/ Make sure there is a Github issue filed for the change (trivial changes like typos excluded)
  • 你的 Pull Request 只解决一个 Issue,没有包含其他不相关的变更 / Your PR addresses just this issue, without pulling in other changes - one PR resolves one issue
  • PR 中的每个 commit 都有有意义的主题行和描述 / Each commit in the PR has a meaningful subject line and body

代码质量 / Code Quality:

  • 我的代码遵循项目的代码规范 / My code follows the project's coding standards
  • 我已经进行了自我代码审查 / I have performed a self-review of my code
  • 我已经为复杂的代码添加了必要的注释 / I have commented my code, particularly in hard-to-understand areas

测试要求 / Testing Requirements:

  • 我已经编写了必要的单元测试来验证逻辑正确性 / I have written necessary unit-tests to verify the logic correction
  • 当存在跨模块依赖时,我尽量使用了 mock / I have used mocks when cross-module dependencies exist
  • 代码检查通过 / Lint checks pass
  • 单元测试通过 / Unit tests pass

文档和兼容性 / Documentation and Compatibility:

  • 我已经更新了相应的文档 / I have made corresponding changes to the documentation
  • 如果有破坏性变更,我已经在 PR 描述中详细说明 / If there are breaking changes, I have documented them in detail
  • 我已经考虑了向后兼容性 / I have considered backward compatibility

📋 附加信息 / Additional Notes

  • PR milestone reuses Issue chore(meta): 收敛沙箱 SSH 暴露并保留 GitHub 访问 #576 milestone 0.8.3.
  • 默认沙箱不再支持隐式 git@github.com:* SSH workflow;如后续确有需要,应单独设计 GitHub 专用 SSH 通道。
  • 已有沙箱不会自动移除旧挂载,需要 ai sandbox rm <branch> 后重新 ai sandbox create <branch>
  • 待人工验证:在真实 Docker 环境中创建沙箱,检查 docker inspect 的 Mounts 不包含 /home/devuser/.ssh,并确认 gh auth status 仍可用。

审查者注意事项 / Reviewer Notes:

重点关注 Docker run 参数删除 .ssh 挂载后,GitHub CLI 是否仍通过 GH_TOKEN env-file 满足访问需求,以及文档中默认沙箱边界、dotfiles 保护和既有沙箱重建说明是否清晰。

Generated with AI assistance

- Remove the default read-only SSH bind mount from sandbox create.
- Keep GitHub access on the gh/HTTPS token path.
- Cover docker run mounts with a regression test and docs updates.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@CodeCasterX CodeCasterX added this to the 0.8.3 milestone Jul 6, 2026
@CodeCasterX CodeCasterX added type: task A general task in: cli Module: cli labels Jul 6, 2026
@CodeCasterX CodeCasterX self-assigned this Jul 6, 2026
@CodeCasterX

CodeCasterX commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

审查摘要

codex · TASK-20260705-200010

更新时间:2026-07-07 18:54:17+08:00

✅ 人工验证已通过

  • 验证结论:通过。
  • 验证范围:PR fix(sandbox): 收敛沙箱 SSH 暴露并保留 GitHub 访问 #579 最新提交 2748756,在新沙箱内确认 /home/devuser/.ssh 不存在且不是挂载点,/proc/self/mountinfo 未发现 .ssh / /home/devuser/.ssh 挂载。
  • 核心挂载:/workspace/share/common/share/branch 均存在。
  • GitHub 访问:gh auth status 通过,认证来源为 GH_TOKEN,Git operations protocol 为 https
  • 回归验证:sandbox-core 聚焦测试通过(60/60),npm run test:core 通过(1097 passed, 1 skipped),npm test 通过(1337 passed, 1 skipped),npm run typecheck 通过。

关键技术决策

  • 移除默认全量 SSH bind mount:删除 ~/.ssh -> /home/devuser/.ssh:ro,避免个人 SSH config、known_hosts、私钥、pem 文件和跳板机配置进入通用 agent 沙箱。
  • 保留 GitHub 访问的 gh / HTTPS token 路径:继续依赖现有 gh auth token -> GH_TOKEN env-file 注入,不新增 GitHub SSH 专用通道。
  • 保留 dotfiles .ssh/* 保护:.ssh 不通过 dotfiles 渠道导入沙箱,文档明确默认沙箱不支持隐式 git@github.com:* SSH workflow。
  • 既有沙箱需要删除并重建:已有容器不会自动移除旧挂载,需要 ai sandbox rm <branch> 后重新 ai sandbox create <branch>

审查历程

轮次 结论 问题统计 修复状态
Round 1 Approved 0 blocker / 0 major / 0 minor / 1 manual-validation 人工校验已通过

测试结果

  • node --experimental-strip-types --no-warnings --test tests/integration/cli/sandbox-core.test.ts:60 tests, 60 pass, 0 fail。
  • npm run test:core:1098 tests, 1097 pass, 0 fail, 1 skipped。
  • npm test:1338 tests, 1337 pass, 0 fail, 1 skipped。
  • npm run typecheck:通过。

由 codex 自动生成 · 内部追踪:TASK-20260705-200010

@CodeCasterX CodeCasterX merged commit 29fa6e4 into main Jul 7, 2026
15 checks passed
@CodeCasterX CodeCasterX deleted the agent-infra-chore-sandbox-ssh-github-access branch July 7, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: cli Module: cli type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(meta): 收敛沙箱 SSH 暴露并保留 GitHub 访问

1 participant