fix(security): harden web_fetch and datasource connector SSRF paths

Use SSRF-safe HTTP clients in chat pipeline web_fetch and Feishu/Yuque/Notion
connectors, validating tenant-supplied base_url values before outbound requests.
This commit is contained in:
wizardchen
2026-07-02 12:21:39 +08:00
committed by lyingbug
parent 1d322c525a
commit 8325dac738
13 changed files with 179 additions and 66 deletions
@@ -26,16 +26,19 @@ type notionClient struct {
}
// newClient creates a new Notion API client.
func newClient(token, baseURL string) *notionClient {
func newClient(token, baseURL string) (*notionClient, error) {
if baseURL == "" {
baseURL = DefaultBaseURL
}
if err := datasource.ValidateConnectorBaseURL(baseURL); err != nil {
return nil, err
}
return &notionClient{
token: token,
httpClient: &http.Client{Timeout: 30 * time.Second},
limiter: rate.NewLimiter(rate.Limit(3), 3), // 3 req/s with burst of 3 (matches Notion's actual behavior)
httpClient: datasource.NewConnectorHTTPClient(30 * time.Second),
limiter: rate.NewLimiter(rate.Limit(3), 3),
baseURL: baseURL,
}
}, nil
}
const maxRetries = 3