mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Fix URL validation to only accept HTTP/HTTPS schemes for Ollama embeddings
- Update _validate_url() to restrict schemes to 'http' and 'https' only - Fixes CI test failures for ftp://invalid-scheme test cases - Maintains security by preventing non-web protocols Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -93,7 +93,7 @@ class EmbeddingConfigurator:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _validate_url(url):
|
def _validate_url(url):
|
||||||
"""Validate that a URL is properly formatted."""
|
"""Validate that a URL is properly formatted and uses HTTP/HTTPS scheme."""
|
||||||
if not url:
|
if not url:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -101,7 +101,10 @@ class EmbeddingConfigurator:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = urlparse(url)
|
result = urlparse(url)
|
||||||
return all([result.scheme, result.netloc])
|
return all([
|
||||||
|
result.scheme in ('http', 'https'),
|
||||||
|
result.netloc
|
||||||
|
])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user