fix: 补全 shared/worker 层对 domain 常量的 re-export

domain 层重构后,部分常量未从 shared/worker 层 re-export,
导致 10 个测试模块因 ImportError 无法收集。

修复:
- packages/shared/url_security.py: 补全 ALLOWED_AUDIO_MIME_TYPES,
  ALLOWED_IMAGE_MIME_TYPES, MAX_URL_LENGTH 的 re-export,
  以及 _check_internal_hostnames, _check_ssrf_ip, _is_trusted_domain
  私有别名
- apps/worker/video_processing/speed_engine.py: 补全 MAX_SPEED,
  MIN_SPEED 的 re-export

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
xiaoxia
2026-07-28 16:29:14 +08:00
parent 28173f1713
commit 0ce9a22b91
2 changed files with 15 additions and 0 deletions
@@ -16,6 +16,8 @@ from __future__ import annotations
from packages.domain.speed_config import (
DEFAULT_SPEED,
MAX_SPEED,
MIN_SPEED,
SpeedConfig,
_split_atempo_stages,
)
+13
View File
@@ -22,11 +22,16 @@ import urllib.error
import urllib.request
from urllib.parse import urljoin
from packages.domain.url_security import ALLOWED_AUDIO_MIME_TYPES as _allowed_audio_base
from packages.domain.url_security import ALLOWED_IMAGE_MIME_TYPES as _allowed_image_base
from packages.domain.url_security import ALLOWED_PORTS as _allowed_ports_base
from packages.domain.url_security import ALLOWED_SCHEMES as _allowed_schemes_base
from packages.domain.url_security import MAX_URL_LENGTH as _max_url_length_base
from packages.domain.url_security import UrlSecurityError as _UrlSecurityError_base
from packages.domain.url_security import check_internal_hostname as _check_internal_hostname_base
from packages.domain.url_security import check_ssrf_ip as _check_ssrf_ip_base
from packages.domain.url_security import is_ip_address as _is_ip_address_base
from packages.domain.url_security import is_trusted_domain as _is_trusted_domain_base
from packages.domain.url_security import validate_magic_number as _validate_magic_number_base
from packages.domain.url_security import validate_url_basic as _validate_url_basic_base
@@ -35,8 +40,16 @@ logger = logging.getLogger(__name__)
# ── 兼容导出(保持原有变量名供外部引用) ──────────────────────────────────
ALLOWED_SCHEMES = set(_allowed_schemes_base)
ALLOWED_PORTS = set(_allowed_ports_base)
ALLOWED_AUDIO_MIME_TYPES = set(_allowed_audio_base)
ALLOWED_IMAGE_MIME_TYPES = set(_allowed_image_base)
MAX_URL_LENGTH = _max_url_length_base
UrlSecurityError = _UrlSecurityError_base
# 私有别名(供测试和内部引用)
_check_internal_hostnames = _check_internal_hostname_base
_check_ssrf_ip = _check_ssrf_ip_base
_is_trusted_domain = _is_trusted_domain_base
# 可信域名白名单(从环境变量读取)
TRUSTED_DOMAINS: set[str] = set()
_env_trusted = os.environ.get("URL_SECURITY_TRUSTED_DOMAINS", "")