Skip to content

Commit 04d652d

Browse files
committed
Reject CONTAINER_WORKSPACE values containing a colon
A colon in the workspace path breaks Docker's volume mount syntax (host:container[:options]), silently changing mount behaviour. Raise RuntimeError early in _start_container() if the colon is present. Adds a corresponding test.
1 parent 0892143 commit 04d652d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/seclab_taskflows/mcp_servers/container_shell.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
def _start_container() -> str:
2929
"""Start the Docker container and return its name."""
30+
if CONTAINER_WORKSPACE and ":" in CONTAINER_WORKSPACE:
31+
raise RuntimeError(f"CONTAINER_WORKSPACE must not contain a colon: {CONTAINER_WORKSPACE!r}")
3032
name = f"seclab-shell-{uuid.uuid4().hex[:8]}"
3133
cmd = ["docker", "run", "-d", "--rm", "--name", name]
3234
if CONTAINER_WORKSPACE:

tests/test_container_shell.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def test_start_container_failure(self):
7070
with pytest.raises(RuntimeError, match="docker run failed"):
7171
cs_mod._start_container()
7272

73+
def test_start_container_rejects_colon_in_workspace(self):
74+
with (
75+
patch.object(cs_mod, "CONTAINER_IMAGE", "test-image:latest"),
76+
patch.object(cs_mod, "CONTAINER_WORKSPACE", "/host/path:ro"),
77+
):
78+
with pytest.raises(RuntimeError, match="CONTAINER_WORKSPACE must not contain a colon"):
79+
cs_mod._start_container()
80+
7381

7482
# ---------------------------------------------------------------------------
7583
# shell_exec tests

0 commit comments

Comments
 (0)