fix(security): harden model client redirects

This commit is contained in:
wizardchen
2026-07-02 18:25:04 +08:00
committed by lyingbug
parent 663d13eb58
commit 1661827d6e
15 changed files with 226 additions and 20 deletions
+25
View File
@@ -0,0 +1,25 @@
package rerank
import (
"fmt"
"net/http"
"time"
secutils "github.com/Tencent/WeKnora/internal/utils"
)
func validateRerankBaseURL(baseURL string) error {
if baseURL == "" {
return nil
}
if err := secutils.ValidateURLForSSRF(baseURL); err != nil {
return fmt.Errorf("base URL SSRF check failed: %w", err)
}
return nil
}
func newRerankHTTPClient(timeout time.Duration) *http.Client {
cfg := secutils.DefaultSSRFSafeHTTPClientConfig()
cfg.Timeout = timeout
return secutils.NewSSRFSafeHTTPClient(cfg)
}