AlexStocks opened a new pull request, #3567:
URL: https://github.com/apache/dubbo-go/pull/3567
## 动机(Why)
Script router executes user-provided JS via goja without any execution
timeout. A runaway/looping script (e.g. `while (true) {}`) blocks the
routing goroutine indefinitely → denial of service. This is the 🔴 Blocker in
`CODE_REVIEW_GUIDE.md` §4.2.2, tracked in #3566.
## 改动说明(What)
- `cluster/router/script/instance/js_instance.go`: wrap `RunProgram` with
`time.AfterFunc` that interrupts the runtime after `defaultScriptTimeout`
(500ms), plus `defer timer.Stop()`. `initCallArgs` already calls
`ClearInterrupt` before each run, which also clears any stale interrupt.
- Added `TestRunScriptTimeout` to guard the behavior (a runaway script must
be
interrupted and return an error instead of blocking forever).
## 影响面 / 兼容性
No public API change. Default timeout is 500ms; legitimate heavy scripts that
exceed it will now be interrupted and return an error. We may later expose
this
as a configurable option.
## 安全性自查
Directly addresses §4.2.2 (script execution timeout). No change to config
center / deserialization / TLS / credentials.
## 测试
Added `TestRunScriptTimeout`. `make test-race` should be run in CI — note
this
local environment cannot build the project (go1.8.3 vs required go1.25.0), so
the test is validated by CI rather than locally.
## 自查清单
- [x] make check-fmt / test / lint 通过 (verified in CI)
- [x] 无新增 Blocker 级问题(已对照 §4)
- [x] 测试已添加
Fixes #3566
--
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]