fix(channel): M41 r1 复审三条 —— telegram 构造分支、QQ 改 MaskQuery、删两处死上限

P2-1 telegram doJSON 的**请求构造**失败分支:http.NewRequestWithContext 解析失败的
err 同样是 *url.Error(里面是整条 /bot<token>/… 地址),而 poll.go 的 long poll
failed 会原样落日志。改成与传输层分支同形:trace.HostOf(endpoint) + callCause。

P2-2 qq_obv11 connectClient 的成功 INFO 从 maskAccessTokenQuery 换成
trace.MaskQuery:后者认得 access%5Ftoken / token / api_key / 签名参数 / userinfo,
且保留 EscapedPath(路径可读)与不截断。maskAccessTokenQuery 仍被
sanitizeConnectReason 使用,未成死代码。

P2-3 删掉 maxEnvelopeMessageRunes / maxDescriptionRunes(各 200):trace.RedactText
内部已 truncate 到 maxSummaryRunes=80,这两层永不命中,注释口径与实际不符。改为
直接 return trace.RedactText(压平空白),注释写明 80 rune 由 RedactText 负责。

用例(全部变异打红,逐条验证):telegram 构造分支 token、QQ 八形态凭据矩阵
(含四种 maskAccessTokenQuery 漏掉的形态 + 路径可读反向断言)、两处 80 rune 上限。
This commit is contained in:
AskaEth committed 2026-10-26 13:58:19 +08:00
1 parent 0f9251b983
commit 4b4173dd42
6 files changed
+212 -54

No files matched your search

+7 -5
View File
@@ -14,6 +14,8 @@ import (
"fmt"
"net/url"
"strings"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/trace"
)
// errClientConfig 是 client 模式配置缺失(remote_url 为空)的错误哨兵:重试治不好
@@ -61,11 +63,11 @@ func (a *Adapter) connectClient(ctx context.Context) error {
return fmt.Errorf("qq-obv11: dial onebot ws %s: %w", a.cfg.RemoteURL, cerr)
}
a.setConn(conn)
// remote_url 按 OneBot 惯例可以直接写着 `?access_token=…`,原样 INFO 就是把凭据
// 写进日志。这里复用同包已有的第二层脱敏(connect_outcome.go 的
// maskAccessTokenQuery)——不另写一套,也不用 sanitizeConnectReason 的 80 rune
// 上限,否则地址的路径会被切掉、失去「连到了哪」的诊断价值。
a.log.Info("connected to onebot ws (client mode)", "url", maskAccessTokenQuery(a.cfg.RemoteURL))
// remote_url 按 OneBot 惯例可以直接写着 `?access_token=…`,也可能是把凭据塞进
// `user:pass@` 或别的键名(`token` / `api_key` / 签名参数)。原样 INFO 就是把凭据
// 写进日志,因此只打 trace.MaskQuery 的形态:凭据类 query/fragment 值与 userinfo
// 一律打码,路径原样保留(「连到了哪个端点」是这条 INFO 的全部诊断价值)。
a.log.Info("connected to onebot ws (client mode)", "url", trace.MaskQuery(a.cfg.RemoteURL))
return nil
}