browser: click-path allowlist, safe tenant script upgrade, allowlist activation plan

- click/click_ref: pre-click allowlist gate on resolvable anchor href
  (same check as navigate; miss refuses before the click executes);
  click/click_ref/click_at: post-click landing URL check.
  click_at has no pre-click gate by design (coordinates name no
  element); JS-driven navigation, evaluate, meta refresh and popups
  are documented as unintercepable with the Tinyproxy 403 backstop.
- Tenant script upgrade is now safe: only proven-unmodified scripts
  (manifest match, 2a569ac known-shipped SHA-256, missing, or
  current) auto-merge; tenant-modified scripts are never overwritten,
  are reported as skipped, and get one deduped audit record. The
  manifest never learns a tenant hash (else the next upgrade would
  mistake a modified file for untouched). Idempotent reruns.
- Activation candidate = deployed Tinyproxy programming set encoded
  with leading-dot entries (plain entries would regress
  docs.python.org); npmjs.org per the deployed filter, not npmjs.com.
  Host activation itself is NOT performed this round: only the plan,
  validation tests and rollback are delivered.
Tests: 28 new (click 13, upgrade 8, activation 7), all fake/no-network;
98 browser-related tests pass including prior suites.

(cherry picked from commit e4a93f5748ec815f163d0bc096ff4dc4b8c651f5)
This commit is contained in:
host committed 2026-11-01 09:06:28 +00:00
1 parent 1141d0d0f8
commit 125b436ab3
8 files changed
+1150 -33

No files matched your search

+30 -3
View File
@@ -82,9 +82,36 @@ navigate / snapshot / click / fill / screenshot 都针对该页;
就检查:`file://` 一律放行,`http(s)` 的 host 必须命中列表
(前导点条目做后缀匹配:`.python.org` 同时放行
`python.org` 与 `docs.python.org`,不放行
`notpython.org`),大小写与端口不影响匹配,未命中直接
报错且不启动 Chromium。`localhost` / `127.0.0.1` 没有
特殊待遇:本地开发服务器要自己把它列进变量,否则会被挡。
`notpython.org`;注意:不带前导点的 `python.org` 只精确
匹配自身,不放行 `docs.python.org`),大小写与端口不影响
匹配,未命中直接报错且不启动 Chromium。`localhost` /
`127.0.0.1` 没有特殊待遇:本地开发服务器要自己把它列进
变量,否则会被挡。
页内点击白名单(本轮补齐,与 navigate 同款检查):
`browser_click` / `browser_click_ref` 点到带 href 的链接时,
先解析 href(相对链接按当前页 URL 展开)再检查:未命中
直接报错、点击根本不执行;点到没有 href 的目标(按钮、
JS 处理函数)时事前无从得知目的地,只能在点击后检查落点
URL、命中 blocked host 时报错(此时点击已发生,只是事后
发现,不是事前拦截)。`browser_click_at` 是坐标点击,坐标
本身对应不了任何元素,所以没有事前检查,只有事后落点检查。
真正拦不住的路径(不要假装已拦):页内 JS 自行跳转
(`location.href`、表单提交、SPA 路由、回车提交)、
`browser_evaluate` 里跑的任意 JS、meta refresh、弹窗新页。
这些路径没有“点击前已知目的地”可供检查,只能靠 egress
代理 403 兜底——白名单与代理白名单取同一域名集合时,被挡
域名在代理层就加载失败,不会真的打开目标页;但 evaluate
与 shell 同权,白名单从来不是它的沙箱边界,不要把它当
成防绕过手段。
老租户脚本升级(本轮改动):播种器只对已证明未改动的
租户脚本自动合并新版(播种 manifest 命中,或命中
2a569ac 已发布版本的哈希,或文件缺失/已是最新);租户
改过的脚本绝不覆盖,原样不动、记一条审计
(租户 codex-home 里的 `playwright_scripts_audit.jsonl`),
留待人工处理——下次任务播种时它仍会被跳过,不会悄悄
被新版盖掉。
清理:`browser_close` 会关掉全部页,并尽力删除工作区里的
`browser-live.png` 与 `browser-live.json`(删不掉也不报错),