XnLemon commented on issue #3554:
URL: https://github.com/apache/dubbo-go/issues/3554#issuecomment-5125630584
看过了 Issue 里列出的 Affected locations,可以简单分成下面几类:
- `config_center/apollo/impl.go:121`
Apollo 缓存返回的是 `any`,YAML 或自定义解析器可能产生数字、布尔值等非字符串值。这里直接执行 `value.(string)` 会
panic。
- `registry/protocol/protocol.go:97`
理论风险,实际风险较低
`registries` 是包内私有缓存,写入值来自返回类型已经是 `registry.Registry` 的
`extension.GetRegistry`。正常情况下不会出现其他类型,除非扩展错误地返回 `nil, nil`
或内部缓存被破坏。这里更多是内部不变量,而不是外部数据直接导致的风险。
- `registry/directory/directory.go:502、571、589`
实际风险较低
`cacheInvokersMap` 同样是包内私有缓存,只有 `doCacheInvoker` 会向里面写入
`protocolbase.Invoker`。正常调用链能够保证类型。盲目使用 comma-ok 并跳过错误值,可能反而掩盖内部状态损坏;
- `protocol/dubbo/dubbo_codec.go:148-150`
能够复现,但正常生产路径已有约束
它要求 `response.Result` 必须是值类型 `result.RPCResult`。如果传入常见的指针类型
`*result.RPCResult`,就会 panic,我已经实际复现。
不过当前 Getty 服务端 handler 的返回类型固定为
`result.RPCResult`,所以正常服务端响应链路不会触发。这里是响应**编码**,不是 issue 描述的响应解码。
- `filter/accesslog/filter.go:140-162`
Invocation attachments 的类型本来就是 `map[string]any`,应用代码和其他 filter
可以写入任意类型。Accesslog 却把 interface、version、group、timestamp、地址等值直接断言为字符串。传入 `int`
时我已经复现 `interface {} is int, not string`。日志功能不应该因为 attachment 类型异常导致整个 RPC
panic,应该安全转换、忽略异常值或记录告警。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]