From b11d1c421d66cb3493c717ef9bc0a4346d044b87 Mon Sep 17 00:00:00 2001 From: gahusb Date: Fri, 1 May 2026 09:27:11 +0900 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20SSH=20env=EA=B0=92=20=EC=A0=9C?= =?UTF-8?q?=EC=96=B4=EB=AC=B8=EC=9E=90=20sanitize=20+=20=ED=8F=AC=ED=8A=B8?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - NAS_SSH_TARGET/PORT/PATH에서 \r\n\t 제거 (잘못된 export·copy-paste 대비) - NAS_SSH_PORT는 숫자만 허용, 잘못된 값이면 명확한 오류 메시지 출력 - SSH deploy 실행 시 cleanTarget/sshCmd 값 콘솔에 출력 (디버그용) Co-Authored-By: Claude Sonnet 4.6 --- scripts/deploy-nas.cjs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/deploy-nas.cjs b/scripts/deploy-nas.cjs index e3e1b2a..ef4edd7 100644 --- a/scripts/deploy-nas.cjs +++ b/scripts/deploy-nas.cjs @@ -40,10 +40,26 @@ if (isWin) { // SSH 경로: NAS_SSH_TARGET이 설정된 경우 항상 우선 if (sshTarget) { - console.log(`Deploying via SSH → ${sshTarget}:${sshPath}`); - const sshCmd = sshPort ? `ssh -p ${sshPort}` : "ssh"; + // 제어문자·줄바꿈 제거 (잘못된 export/copy-paste 대비) + const cleanTarget = sshTarget.replace(/[\r\n\t]/g, "").trim(); + const cleanPath = sshPath.replace(/[\r\n\t]/g, "").trim(); + const cleanPort = sshPort ? sshPort.replace(/\D/g, "").trim() : ""; + + if (!cleanTarget) { + console.error("NAS_SSH_TARGET 값이 비어있습니다. .env.local 또는 환경변수를 확인하세요."); + printSshHint(); + process.exit(1); + } + if (cleanPort && !/^\d{1,5}$/.test(cleanPort)) { + console.error(`NAS_SSH_PORT 값이 잘못됐습니다: "${sshPort}" → 숫자만 입력하세요.`); + process.exit(1); + } + + const sshCmd = cleanPort ? `ssh -p ${cleanPort}` : "ssh"; + console.log(`Deploying via SSH → ${cleanTarget}:${cleanPath}`); + console.log(`SSH command: ${sshCmd}`); execSync( - `rsync -r --delete --delete-delay -e "${sshCmd}" ${src}/ ${sshTarget}:${sshPath}`, + `rsync -r --delete --delete-delay -e "${sshCmd}" ${src}/ ${cleanTarget}:${cleanPath}`, { stdio: "inherit" } ); process.exit(0);