利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(llm): redact token-only credentials in error URLs
Rudy Celekliff2a91c02216
diff --git a/app/services/llm.py b/app/services/llm.pyindex 993e0ac9..deef62ad 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -45,7 +45,7 @@ _THINK_BLOCK_RE = re.compile(r"<think\b[^>]*>.*?</think>", re.IGNORECASE | re.DO_UNCLOSED_THINK_BLOCK_RE = re.compile(r"<think\b[^>]*>.*$", re.IGNORECASE | re.DOTALL)_UNOPENED_THINK_BLOCK_RE = re.compile(r"^.*</think\s*>", re.IGNORECASE | re.DOTALL)_URL_USERINFO_RE = re.compile(- r"((?:https?|wss?)://)([^/\s?#@]*:[^/\s?#@]*@)", re.IGNORECASE+ r"((?:https?|wss?)://)([^/\s?#@]+@)", re.IGNORECASE)_SENSITIVE_QUERY_RE = re.compile(r"([?&](?:api[_-]?key|access[_-]?token|token|key|secret|password)=)([^&#\s]+)",diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex e95c8f06..5987012c 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -1339,6 +1339,21 @@ class TestLiteLLMProvider(unittest.TestCase):self.assertNotIn("secret-key", result)self.assertNotIn("secret-token", result)+ def test_sanitize_error_message_redacts_token_only_url_userinfo(self):+ # Gateways commonly accept the API token as the URL username with no+ # password, e.g. https://<token>@gateway/v1.+ message = (+ "Connection error to https://[email protected]/v1/chat; "+ "see https://gw.example.com/status?page=1 or [email protected]"+ )++ result = llm._sanitize_error_message(message)++ self.assertIn("https://***:***@gw.example.com/v1/chat", result)+ self.assertNotIn("sk-live-SECRET", result)+ self.assertIn("https://gw.example.com/status?page=1", result)+ self.assertIn("[email protected]", result)+def test_openai_provider_error_redacts_embedded_base_url_credentials(self):"""自定义 OpenAI-compatible base_url 可能包含代理网关的 user:pass。