Potential fix for pull request finding 'CodeQL / 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:
Weilong Liao
2026-06-19 12:36:11 +08:00
committed by GitHub
parent 9a53500c61
commit d88c68ea58

View File

@@ -3,6 +3,7 @@ import posixpath
from dataclasses import dataclass, field
from pathlib import Path
from types import SimpleNamespace
from urllib.parse import urlparse
import certifi
import httpx
@@ -353,7 +354,8 @@ async def test_astrbot_updator_falls_back_when_hosted_core_package_fails(
async def fake_download_file(url: str, path: str, progress_callback=None): # noqa: ARG001
calls.append(url)
if url.startswith("https://cdn.example"):
parsed = urlparse(url)
if parsed.scheme == "https" and parsed.hostname == "cdn.example":
raise RuntimeError("404")
Path(path).write_bytes(b"github-core")