fix(embedding): add SSRF validation and safe HTTP client for embedders

Align embedding outbound requests with chat module defenses by validating
base URLs at construction time and using SSRFSafeDialContext with redirect checks.
This commit is contained in:
wizardchen
2026-06-26 22:37:30 +08:00
committed by lyingbug
parent 500b223acf
commit 6b60d292f8
13 changed files with 112 additions and 26 deletions
+3 -4
View File
@@ -70,16 +70,15 @@ func NewNvidiaEmbedder(apiKey, baseURL, modelName string,
timeout := 60 * time.Second
// Create HTTP client
client := &http.Client{
Timeout: timeout,
if err := validateEmbeddingBaseURL(baseURL); err != nil {
return nil, err
}
return &NvidiaEmbedder{
apiKey: apiKey,
baseURL: baseURL,
modelName: modelName,
httpClient: client,
httpClient: newEmbeddingHTTPClient(timeout),
EmbedderPooler: pooler,
dimensions: dimensions,
modelID: modelID,