Skip to content

[PR] fix: mask private relay hosts in the diagnostics blob before it is pasted publicly (#3811) - #3832

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-19_diagnostics-host-mask
Oct 19, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-19_diagnostics-host-mask

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

查重

不重复。同批 #3808(pck 横幅 XSS,HTML 注入机制)与 #3825(diagnostics single-read,性能优化、明确「No output change」)都源自 #3781 发版整体审核,但本条是独立症状 + 独立机制:诊断包的 config 段 / 冲突日志尾缺少 #255 的主机遮蔽纪律,纯 URL 主机一路存活进公开 issue。#3825 与本 PR 改同一文件但关注点不同(读盘次数 vs 主机遮蔽),可无冲突合成。

What / Why

诊断文本专门设计来贴进公开 GitHub issue(buildDiagnostics → 预填 issues/new URL)。但 config 段只按键名遮值(SECRET_KEY_RE)+ redactSecretsInText 的凭据形状 + 一条 user:pass@ 剥离——纯主机名(providers[].upstream、route 前缀键、proxy URL)全程存活,内网中转拓扑直接外泄。冲突日志尾在 BILI_LOG_MASK_HOSTS=0 时同样漏(磁盘日志里是真实主机,被原样拷进公开尾)。日志侧 maskHostForLog(#255/#897)就是防这个的,config 段却标着 (secrets masked) 没做主机遮蔽——自相矛盾。

Fix

  • src/log-mask.ts:新增 maskUrlForPublish / maskUrlsForPublish。与 maskUrlForLog 一样丢弃 userinfo/query/hash,但无条件遮蔽非公共主机——本地 BILI_LOG_MASK_HOSTS 开关不能削弱发布边界(与从不该开关门控的 redactSecretsInText 同一立场)。公共 API 主机(openai.com 等白名单)仍原样保留,维持可诊断性。
  • src/web/diagnostics.ts:把 maskUrlsForPublish 作为最外层 sink net 套到 ① config 段序列化后(同时覆盖 URL 作为值和 providers 表键两种位置),② 冲突日志尾每行;替代原先只剥 userinfo 的正则。

Behavior change (old → new)

  • 旧:诊断包 config 段 / 冲突日志尾里的私有端点主机原样输出(无论 BILI_LOG_MASK_HOSTS 开关如何)。
  • 新:非公共主机一律替换为 <private-host>(端口保留),userinfo/query/hash 丢弃;公共 API 主机不变。该遮蔽不受本地 BILI_LOG_MASK_HOSTS=0 影响——发布边界默认安全。
  • 影响面:仅用自托管/内网中转的用户在生成并粘贴诊断包时受影响;贴公开 issue 前不再需要手工打码主机。

Config surface

不涉及——未新增任何配置字段 / env / CLI flag;复用既有 log-mask 基础设施。

Tests(定向本地绿,全量交给 CI)

  • tests/web-diagnostics-enrichment.test.ts:新增断言——私有中转主机在 config URL 值与 providers 表键两处都被遮;setMaskHostsEnabled(false) 下仍遮(发布边界无条件);匹配到的冲突日志行里的主机也被遮。5 pass。
  • tests/mitm.test.ts(唯一另一个 import log-mask 的测试):21 pass,无回归。
  • tsc --noEmit 全仓干净。

Note on #3825

#3825「diagnostics single-read」改的是同一文件的读盘次数(storage/conflict 两个 tail 共享一次 candidateLogLines(),明确无输出变化),与本 PR 的主机遮蔽正交;两者合成即 union of intent,无行为冲突。若 #3825 先合入,本分支 rebase 即可。

Closes #3811

…blob (#3811)

The web diagnostics blob is designed to be pasted into a public GitHub issue,
but its config section only masked credential VALUES by key name
(SECRET_KEY_RE), plus redactSecretsInText shapes, plus a userinfo strip — a bare
endpoint host (providers[].upstream, route-prefix keys, proxy URLs) survived
verbatim, leaking internal relay topology. The conflict-log tail had the same
gap under BILI_LOG_MASK_HOSTS=0 (real hosts in the on-disk log copied straight
into the published tail).

Add maskUrlForPublish/maskUrlsForPublish to log-mask.ts: like maskUrlForLog they
drop userinfo/query/hash, but they ALWAYS mask non-public hosts — the local
BILI_LOG_MASK_HOSTS opt-out must not weaken a publish-boundary artifact (same
stance as redactSecretsInText, which is never gated by the switch). Apply them
as the outermost sink net to both the config section (catches URLs as values AND
providers-table keys) and the conflict-log tail.

Tests: private relay host masked in a config URL value and in a providers-table
key; masking unconditional even with setMaskHostsEnabled(false); host in a
matched conflict-log line masked.
@ranxianglei ranxianglei changed the title fix: mask private relay hosts in the diagnostics blob before it is pasted publicly (#3811) [PR] fix: mask private relay hosts in the diagnostics blob before it is pasted publicly (#3811) Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-19_diagnostics-host-mask (a4f2730)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4525-pr.3832.34aa512

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3832.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 本条是 PR #3832(修 #3811)的镜像;按失败签名(诊断包主机遮蔽缺失)检索 open+closed,无其他同签名条目。与 #3808(pck 横幅 XSS)、#3825(diagnostics single-read)同源自 #3781 发版审核,但症状/机制各自独立——独立确认过,非照抄正文声明。

标签: bug / scope/ui / p2(缺陷;web 诊断面;仅私有中转用户公开粘贴诊断包时泄露内网拓扑,核心压缩功能不受影响,故非 p1)。客户端标签不打:bili 自身 web 面,不涉及特定客户端。

正在做 PR 独立审核(方向/回归/代码/测试有效性/diff 整洁度 + CI 状态核对),完成后按八问体例回复。

@ranxianglei ranxianglei added bug Something isn't working p2 scope/ui labels Oct 19, 2026
@ranxianglei
ranxianglei merged commit 31012c9 into master Oct 19, 2026
65 of 100 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.608-master.31012c9 (rolling master tag).

npm install -g billion-context@0.0.608-master.31012c9  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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

Labels

bug Something isn't working p2 scope/ui

Projects

None yet

1 participant