From f557334c0198b3427fe95bd51714e2d0bab89b17 Mon Sep 17 00:00:00 2001 From: Rip&Tear <84775494+theCyberTech@users.noreply.github.com> Date: Sat, 8 Nov 2025 21:31:40 +0800 Subject: [PATCH] Potential fix for code scanning alert no. 26: Incomplete URL substring sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- lib/crewai/src/crewai/llms/providers/azure/completion.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/llms/providers/azure/completion.py b/lib/crewai/src/crewai/llms/providers/azure/completion.py index 17306d8a2..b0a61550b 100644 --- a/lib/crewai/src/crewai/llms/providers/azure/completion.py +++ b/lib/crewai/src/crewai/llms/providers/azure/completion.py @@ -4,7 +4,7 @@ import json import logging import os from typing import TYPE_CHECKING, Any - +from urllib.parse import urlparse from pydantic import BaseModel from crewai.utilities.agent_utils import is_context_length_exceeded @@ -143,8 +143,10 @@ class AzureCompletion(BaseLLM): prefix in model.lower() for prefix in ["gpt-", "o1-", "text-"] ) + parsed_endpoint = urlparse(self.endpoint) + host = parsed_endpoint.hostname or "" self.is_azure_openai_endpoint = ( - "openai.azure.com" in self.endpoint + (host == "openai.azure.com" or host.endswith(".openai.azure.com")) and "/openai/deployments/" in self.endpoint )