feat: search engine adds proxy addresses and adds SSRF verification.

This commit is contained in:
hjz
2026-04-15 08:53:09 +08:00
committed by lyingbug
parent 092044b68f
commit 7bd36bf954
16 changed files with 228 additions and 14 deletions
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
infra_web_search "github.com/Tencent/WeKnora/internal/infrastructure/web_search"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
@@ -60,6 +61,12 @@ func (s *webSearchProviderService) UpdateProvider(ctx context.Context, provider
}
}
if provider.Provider != "" {
if err := validateProviderParameters(provider.Provider, provider.Parameters); err != nil {
return err
}
}
logger.Infof(ctx, "Updating web search provider: tenant=%d, id=%s", provider.TenantID, provider.ID)
return s.repo.Update(ctx, provider)
}
@@ -114,5 +121,12 @@ func validateProviderParameters(provider types.WebSearchProviderType, params typ
case types.WebSearchProviderTypeDuckDuckGo:
// No API key required
}
if err := validateOptionalProxyURL(params.ProxyURL); err != nil {
return err
}
return nil
}
func validateOptionalProxyURL(proxyURL string) error {
return infra_web_search.ValidateProxyURL(proxyURL)
}