diff --git a/internal/datasource/connector/ima/fake_ima_test.go b/internal/datasource/connector/ima/fake_ima_test.go index f0026c62..1b503ab6 100644 --- a/internal/datasource/connector/ima/fake_ima_test.go +++ b/internal/datasource/connector/ima/fake_ima_test.go @@ -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()) } diff --git a/internal/datasource/connector/yuque/connector_test.go b/internal/datasource/connector/yuque/connector_test.go index 35118e97..44f3ca04 100644 --- a/internal/datasource/connector/yuque/connector_test.go +++ b/internal/datasource/connector/yuque/connector_test.go @@ -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()) }