mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-26 16:48:13 +00:00
Potential fix for code scanning alert no. 27: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
from urllib.parse import urlparse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from crewai.utilities.agent_utils import is_context_length_exceeded
|
from crewai.utilities.agent_utils import is_context_length_exceeded
|
||||||
@@ -161,7 +161,9 @@ class AzureCompletion(BaseLLM):
|
|||||||
Returns:
|
Returns:
|
||||||
Validated and potentially corrected endpoint URL
|
Validated and potentially corrected endpoint URL
|
||||||
"""
|
"""
|
||||||
if "openai.azure.com" in endpoint and "/openai/deployments/" not in endpoint:
|
parsed_url = urlparse(endpoint)
|
||||||
|
hostname = parsed_url.hostname or ""
|
||||||
|
if (hostname == "openai.azure.com" or hostname.endswith(".openai.azure.com")) and "/openai/deployments/" not in endpoint:
|
||||||
endpoint = endpoint.rstrip("/")
|
endpoint = endpoint.rstrip("/")
|
||||||
|
|
||||||
if not endpoint.endswith("/openai/deployments"):
|
if not endpoint.endswith("/openai/deployments"):
|
||||||
|
|||||||
Reference in New Issue
Block a user