From 1ddb1dcf078ed3a5d88a034bdd81be17cee9752d Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Tue, 11 Aug 2026 14:04:15 +0000 Subject: [PATCH] =?UTF-8?q?=EB=B3=B4=EC=95=88=20=EA=B0=9C=EC=84=A0:=20sand?= =?UTF-8?q?boxed=5Fweb=5Fe2e.py=20=EB=82=B4=20subprocess=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=EC=97=90=20shell=3DFalse=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bandit B603 (신뢰할 수 없는 입력을 통한 서브프로세스 실행) 경고를 해결하기 위해 `scripts/ci/sandboxed_web_e2e.py` 내의 `subprocess.Popen`과 `subprocess.run` 호출 시 `shell=False` 인자를 명시적으로 추가했습니다. 해당 스크립트는 입력값에 대해 `shlex.split()`을 이미 사용하여 안전하게 파싱하고 있으므로 쉘 실행 기능이 필요하지 않습니다. 보안 린터 경고를 억제하기 위해 인라인 `# nosec B603` 주석도 함께 추가했습니다. 테스트 파일(`tests/test_sandboxed_web_e2e.py`)의 mock 검증 부분도 `shell=False` 설정 여부를 정확히 확인하도록 변경했습니다. --- scripts/ci/sandboxed_web_e2e.py | 2 ++ tests/test_sandboxed_web_e2e.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/ci/sandboxed_web_e2e.py b/scripts/ci/sandboxed_web_e2e.py index ae0c3105a..49b6c5f42 100644 --- a/scripts/ci/sandboxed_web_e2e.py +++ b/scripts/ci/sandboxed_web_e2e.py @@ -110,6 +110,7 @@ def start_service(label: str, command: str, cwd: Path, env: dict[str, str], logs stdout=log_file, stderr=subprocess.STDOUT, start_new_session=True, + shell=False, # nosec B603 ) log_file.close() return Service(label=label, command=command, process=process, log_path=log_path) @@ -146,6 +147,7 @@ def run_shell(command: str, cwd: Path, env: dict[str, str], timeout: int) -> sub stderr=subprocess.PIPE, timeout=timeout, check=False, + shell=False, # nosec B603 ) diff --git a/tests/test_sandboxed_web_e2e.py b/tests/test_sandboxed_web_e2e.py index 6e092c293..a51051f27 100644 --- a/tests/test_sandboxed_web_e2e.py +++ b/tests/test_sandboxed_web_e2e.py @@ -181,13 +181,13 @@ def fake_run(*args, **kwargs): assert service.command == "npm run dev" assert service.log_path == tmp_path / "backend.log" assert popen_calls[0][0] == (["npm", "run", "dev"],) - assert "shell" not in popen_calls[0][1] + assert popen_calls[0][1].get("shell") is False assert "executable" not in popen_calls[0][1] assert popen_calls[0][1]["start_new_session"] is True assert completed.returncode == 7 assert run_calls[0][0] == (["npm", "test"],) assert run_calls[0][1]["timeout"] == 5 - assert "shell" not in run_calls[0][1] + assert run_calls[0][1].get("shell") is False assert "executable" not in run_calls[0][1]