diff --git a/apps/worker/worker_app/tasks/generation.py b/apps/worker/worker_app/tasks/generation.py index 99e94a614..6af97259a 100755 --- a/apps/worker/worker_app/tasks/generation.py +++ b/apps/worker/worker_app/tasks/generation.py @@ -460,8 +460,6 @@ def _verify_url_accessible( import urllib.request from urllib.parse import urljoin - from shared.url_security import UrlSecurityError, validate_url_safety - from video_processing.url_security import UrlSecurityError, validate_url_safety # P0-1 SSRF 防护:请求前先校验 URL 安全性 diff --git a/tests/unit/test_url_security.py b/tests/unit/test_url_security.py index 2c7ac13d6..63da47669 100755 --- a/tests/unit/test_url_security.py +++ b/tests/unit/test_url_security.py @@ -233,7 +233,7 @@ class TestSafeDownload(unittest.TestCase): with unittest.mock.patch("urllib.request.build_opener") as mock_opener: mock_resp = unittest.mock.MagicMock() mock_resp.headers = {"Content-Type": "audio/mpeg"} - mock_resp.read.side_effect = [b"audio_data", b""] + mock_resp.read.side_effect = [b"ID3audio_data", b""] mock_resp.geturl.return_value = "https://example.com/test.mp3" mock_opener.return_value.open.return_value = mock_resp size = safe_download_file( @@ -242,7 +242,7 @@ class TestSafeDownload(unittest.TestCase): purpose="test", allowed_mime_types=ALLOWED_AUDIO_MIME_TYPES, ) - self.assertEqual(size, 10) + self.assertEqual(size, 13) self.assertTrue(os.path.exists(dest)) def test_safe_download_file_stream_size_limit(self): @@ -274,7 +274,7 @@ class TestSafeDownload(unittest.TestCase): def test_safe_download_bytes_returns_content(self): """safe_download_bytes 应该返回文件内容.""" - test_data = b"hello world test audio" + test_data = b"ID3hello world test audio" with unittest.mock.patch("urllib.request.build_opener") as mock_opener: mock_resp = unittest.mock.MagicMock() mock_resp.headers = {"Content-Type": "audio/mpeg"}