feat: search engine adds proxy addresses and adds SSRF verification.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user