fix: Add shell quoting for command arguments

- Use shlex.quote() to escape special characters in argument values
- Fixes: 'unrecognized arguments' error when values contain spaces
- Example: target_name='example.com scan' now correctly quoted
This commit is contained in:
yyhuni
2025-12-30 17:32:09 +08:00
parent 81abc59961
commit 2a31e29aa2

View File

@@ -242,11 +242,13 @@ class TaskDistributor:
Returns:
命令列表(如 ['python', '-m', 'script', '--arg=value']
"""
import shlex
# 日志文件路径(容器内)
log_file = f"{self.logs_mount}/container_{script_module.split('.')[-1]}.log"
# 构建参数列表
args = [f"--{k}={v}" for k, v in script_args.items()]
# 构建参数列表(使用 shlex.quote 转义特殊字符)
args = [f"--{k}={shlex.quote(str(v))}" for k, v in script_args.items()]
# 完整命令:日志轮转 + 执行脚本
command = [