fix: remote_dir 根目录绕过(rstrip 后空串检查)

This commit is contained in:
ymq 2026-08-14 11:27:45 +08:00
parent b3ddb59e2e
commit 4fe5f17490

View File

@ -126,6 +126,8 @@ def _validate_remote(remote_config: dict) -> str:
if not remote_dir.startswith("/"):
return "remote_dir 必须是绝对路径"
_dir = remote_dir.rstrip("/")
if not _dir:
return "remote_dir 不能是根目录 /"
if _dir in _FORBIDDEN_DIRS:
return "remote_dir 不能是系统目录 " + _dir
for d in _FORBIDDEN_DIRS:
@ -169,6 +171,8 @@ async def migrate_work_dir(account_name: str, from_mode: str, to_mode: str, env:
if not remote_dir:
return {"ok": False, "error": "缺少远程目录 remote_dir"}
_d = remote_dir.rstrip("/")
if not _d:
return {"ok": False, "error": "远程目录是根目录,拒绝迁移"}
if _d in _FORBIDDEN_DIRS:
return {"ok": False, "error": "远程目录是系统目录,拒绝迁移: " + _d}
for d in _FORBIDDEN_DIRS: