Skip to content

Commit 46a7237

Browse files
Potential fix for code scanning alert no. 1: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: owndev <69784886+owndev@users.noreply.github.com>
1 parent 2c757bd commit 46a7237

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pipelines/azure/azure_ai_foundry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
from typing import List, Union, Generator, Iterator, Optional, Dict, Any, AsyncIterator
22+
from urllib.parse import urlparse
2223
from fastapi.responses import StreamingResponse
2324
from pydantic import BaseModel, Field, GetCoreSchemaHandler
2425
from open_webui.env import AIOHTTP_CLIENT_TIMEOUT, SRC_LOG_LEVELS
@@ -214,8 +215,10 @@ def _extract_model_from_url(self) -> Optional[str]:
214215

215216
try:
216217
# Check if this is an Azure OpenAI URL
218+
from urllib.parse import urlparse # Local import to avoid scope issues
219+
endpoint_host = urlparse(self.valves.AZURE_AI_ENDPOINT).hostname or ""
217220
if (
218-
".openai.azure.com" in self.valves.AZURE_AI_ENDPOINT
221+
(endpoint_host == "openai.azure.com" or endpoint_host.endswith(".openai.azure.com"))
219222
and "/deployments/" in self.valves.AZURE_AI_ENDPOINT
220223
):
221224
# Extract model name from URL pattern

0 commit comments

Comments
 (0)