test(datasource): keep yuque and ima config tests off live DNS
parseYuqueConfig and parseIMAConfig validate DefaultBaseURL through ValidateConnectorBaseURL, which resolves the host with net.LookupIP. Their TestMain only whitelists loopback, so the config tests fail on any machine where www.yuque.com or ima.qq.com resolves to a restricted address (a local DNS sinkhole, for example), and the result depends on the network the tests happen to run on. Whitelist the default host as well, which is what the feishu tests already do for open.feishu.cn.main
parent
86d245d892
commit
90e3977714
|
|
@ -15,9 +15,11 @@ import (
|
|||
)
|
||||
|
||||
// TestMain whitelists loopback for SSRF so the httptest servers (127.0.0.1)
|
||||
// are reachable. Production keeps the default strict SSRF policy.
|
||||
// are reachable, and the default base host so parseIMAConfig does not resolve
|
||||
// ima.qq.com over live DNS during a unit test. Production keeps the default
|
||||
// strict SSRF policy.
|
||||
func TestMain(m *testing.M) {
|
||||
_ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
_ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost,ima.qq.com")
|
||||
secutils.ResetSSRFWhitelistForTest()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ import (
|
|||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
)
|
||||
|
||||
// TestMain whitelists loopback for the httptest servers and the default base
|
||||
// host so parseYuqueConfig does not resolve www.yuque.com over live DNS during
|
||||
// a unit test. Production keeps the default strict SSRF policy.
|
||||
func TestMain(m *testing.M) {
|
||||
os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost")
|
||||
_ = os.Setenv("SSRF_WHITELIST", "127.0.0.1,localhost,www.yuque.com")
|
||||
secutils.ResetSSRFWhitelistForTest()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue