fix(web): all web_search backends use SafeHTTPClient (N4)

This commit is contained in:
sausheong committed 2026-06-13 11:22:15 +08:00
1 parent d7777f7c89
commit 7d85074509
3 files changed
+42 -4

No files matched your search

+6 -1
View File
@@ -14,6 +14,11 @@ import (
const searchTimeout = 15 * time.Second
// searchClient is the shared SSRF-safe HTTP client for all web_search
// backends. It pins the validated IP and re-validates redirects, bringing
// web_search to parity with web_fetch. (N4)
var searchClient = SafeHTTPClient(searchTimeout)
// WebSearchTool searches the web and returns results via a configurable
// backend. The default backend (when Backend is nil) scrapes DuckDuckGo's
// HTML interface — no API key required, but fragile to upstream HTML
@@ -131,7 +136,7 @@ func duckDuckGoSearch(ctx context.Context, query string, maxResults int) ([]sear
}
req.Header.Set("User-Agent", "harness/1.0 (Go agent framework)")
resp, err := http.DefaultClient.Do(req)
resp, err := searchClient.Do(req)
if err != nil {
return nil, err
}