Skip to content

fix(providers): 连接 endpoint 持久化与回显前剥离 userinfo 凭证 - #94

Open
yjg-djb wants to merge 1 commit into
helsome:mainfrom
yjg-djb:fix/issue-93-endpoint-sanitization
Open

fix(providers): 连接 endpoint 持久化与回显前剥离 userinfo 凭证#94
yjg-djb wants to merge 1 commit into
helsome:mainfrom
yjg-djb:fix/issue-93-endpoint-sanitization

Conversation

@yjg-djb

@yjg-djb yjg-djb commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

修复 #93:连接 endpoint 在持久化与回显前剥离 URL userinfo 凭证(scheme://user:pass@hostscheme://[REDACTED]@host)。

问题回顾

ProviderConfig 是非 secret 设置通道(接口注释明确 "Credentials belong in the OS-backed CredentialStore"),setConfig 已做字段白名单防 apiKey 落盘,但 endpoint 字段本身未做 secret 形态检查。PR #64 的 production canary 运行实测:经真实 IPC 写入带 userinfo 的 endpoint 后,connections.json 明文保存了 folio_user:CANARYLEAK04dbpass,并会经 connection health 链路回显。

修复(2 个文件,+69 行)

测试

#93 验收标准新增 3 个用例 + 全部既有测试不变:

用例 断言
userinfo 密码落盘 connections.json 无明文密码/用户名,含 [REDACTED],主机路径保留
读侧 getConfig 返回 https://[REDACTED]@db.host.internal:5432/api
存量文件(写于修复前) 读侧惰性净化,https://user:legacy-pass@…https://[REDACTED]@…
无 userinfo https://api.example.com/v1?symbol=AAPL 逐字不变

测试报告

  • 命令:bun run typecheckbun test --isolatebun test packages/shared/src/providers
  • 环境:Windows 11 (10.0.26200) + Bun 1.4.2,基线 upstream/main @ 4cdb6bd
  • 结果:typecheck 五 workspace 全部 exit 0;全仓 bun test --isolate 0 fail(1361 tests / 152 files,8 skip 为基线既有);providers 套件 112 tests / 0 fail

Closes #93

ProviderConfig 是非 secret 设置通道(凭证属于 OS 级
CredentialStore),setConfig 已做字段白名单,但 endpoint 字段本身
未做 secret 形态检查——URL userinfo(scheme://user:pass@host)是
常见凭证携带形态,会在 connections.json 明文落盘并回显到 UI
(PR helsome#64 production canary 运行实测发现,见该 PR 证据评论)。

- 新增 sanitizeEndpoint:scheme://user:pass@host →
  scheme://[REDACTED]@host,协议/主机/路径保留,目标地址仍可读;
  无 userinfo 的 endpoint 原样通过
- setConfig 持久化前净化(写侧)
- getConfig 惰性净化(读侧),修复存量明文文件,不破坏本地优先
  的无迁移语义
- 单测覆盖:userinfo 密码剥离且落盘无明文、旧文件读侧净化、
  无 userinfo endpoint 行为不变

Closes helsome#93
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.

[Privacy] Sanitize credentials in persisted connection endpoints (connections.json stores userinfo in cleartext)

1 participant