fix(deploy): 使用 shlex.quote 防止 curl URL 命令注入

This commit is contained in:
2026-07-19 13:27:03 +08:00
parent e313086d9b
commit d9a061a6bc
+3 -1
View File
@@ -23,6 +23,7 @@ Purpose: 统一部署所有服务到生产服务器,替代原有的多个 shel
import io import io
import os import os
import re import re
import shlex
import sys import sys
import time import time
import subprocess import subprocess
@@ -525,8 +526,9 @@ def verify_deploy():
for url, label in endpoints: for url, label in endpoints:
null_device = 'NUL' if sys.platform == 'win32' else '/dev/null' null_device = 'NUL' if sys.platform == 'win32' else '/dev/null'
safe_url = shlex.quote(url)
ok, stdout, _ = run_command( ok, stdout, _ = run_command(
f'curl -k -s -o {null_device} -w "HTTP %{{http_code}}" {url}', f'curl -k -s -o {null_device} -w "HTTP %{{http_code}}" {safe_url}',
timeout=30 timeout=30
) )
if ok and stdout: if ok and stdout: