Skip to content

test(terminal): 写删 dashboard secret 的测试在围栏没生效时拒跑 - #2976

Merged
deepcoldy merged 1 commit into
masterfrom
test/secret-home-fence
Nov 7, 2026
Merged

deepcoldy merged 1 commit into
masterfrom
test/secret-home-fence

Conversation

@deepcoldy

Copy link
Copy Markdown
Owner

背景

2026-11-06 16:13–16:17,一次 vitest 全量运行绕过了仓库的全部测试围栏:配置文件是 0 字节,没有 setupFiles,HOME 也没有被重定向。

test/terminal-url.test.ts 和 test/worker-terminal-read-auth.integration.test.ts 会写入并删除 dashboardSecretPath()。这个路径由 homedir() 推导,平时由 unit-setup / bun-test-fence 围到临时 HOME。那次运行里它指向了真实的 ~/.botmux/.dashboard-secret:terminal-url.test.ts 先用测试值覆盖它,用例结束再删掉。之后:

  • 宿主上所有走 HMAC 签名的 CLI → daemon IPC 都退回按会话轮换凭证的校验;
  • 决策看板页面报 daemon IPC secret is missing or empty;
  • 会话里的 botmux board … 报 origin_unproven。

改了什么(只改测试)

影响面

只改这两个测试文件,生产代码不变。围栏正常时行为不变。

验证

  • npx vitest run --project unit test/terminal-url.test.ts test/worker-terminal-read-auth.integration.test.ts:34/34 通过。

  • bun test --timeout=180000 ./test/worker-terminal-read-auth.integration.test.ts:5/5 通过。terminal-url.test.ts 在裸 bun test 下报 importOriginal is not a function,未改动的 master 上同样如此,是既有现象。

  • test/test-hygiene.test.ts:通过。

  • 事故场景对比:用 0 字节 vitest 配置、在临时 HOME 下运行(HOME 里预先放一个哨兵 secret):

    terminal-url worker-terminal-read-auth 哨兵 secret
    master 原版 29 passed 5 passed 被删除(和 11-06 一致)
    本 PR 加载即拒跑 加载即拒跑 原样保留

    拒跑信息:refusing to run: data-dir fence not active (__TEST_DATA_DIR_FENCE=<unset>, …)。

同类线索(未在本 PR 处理)

同一次运行里还有这些测试往真实 HOME 写过东西,都已从线上目录清理:

  • hook 安装类测试:~/.config/opencode/plugin/botmux-ask.js;
  • worker-codex-model-migration-picker.integration:~/.codex/history.jsonl、~/.codex/sessions;
  • recall-frozen-cards:~/.claude/projects;
  • durable-lark-canonical-dispatch / durable-session-primary:~/temp;
  • 某个测试走到生成会话标题的代码,真的拉起了一次 Claude CLI。

🤖 Generated with Claude Code

test/terminal-url.test.ts 与 test/worker-terminal-read-auth.integration.test.ts
会写入并删除 dashboardSecretPath()(由 homedir() 推导)。2026-11-06 一次绕过
setupFiles 的 vitest 全量运行(0 字节配置)里,这两处写删落在了真实的
~/.botmux/.dashboard-secret 上,决策看板和会话内 botmux board 因此失效。

- 两个文件都以 require-fenced-data-dir 作为第一个 import:围栏没执行时整文件拒跑;
- 写/删 secret 一律走 fencedSecretPath():路径不在本文件的测试围栏里就抛错。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@deepcoldy
deepcoldy merged commit 0327ba6 into master Nov 7, 2026
15 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner Author

已合并,感谢 🙏

一个复审中实测发现的同类既存面,供后续围栏加固系列跟进(不影响本 PR):

  • test/dashboard-daemon-port-change.integration.test.ts 目前没有导入期围栏,且直接写继承 HOME 下的 ~/.botmux/.dashboard-secret 与 bots.json;在绕过 setupFiles 的运行(0 字节/手写 vitest 配置)里会把真实文件覆盖成测试值。形态与本 PR 修复的两个文件相同,建议按同样的两层守卫处理。

PR 描述「同类线索」一节列的其余文件(opencode hook 安装测试、codex 历史/会话写入、recall-frozen-cards 的 ~/.claude/projects、两个 durable 测试的 ~/temp)也建议一并纳入后续覆盖。

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

🚀 Released in v3.58.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant