Skip to content

Commit 3d8e58f

Browse files
committed
fix(env): Disallow passing literal ~ in paths
This should be interpolated by the shell before it ever gets to Python anyway.
1 parent 35f1a83 commit 3d8e58f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dda/env/dev/types/linux_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ def extra_mounts(self) -> list[Mount]:
410410
volume_options = {flag.split("=")[0]: flag.split("=")[1] for flag in flags if "=" in flag}
411411

412412
# Check if the source is a path. If not, it's a named volume.
413-
# Note that Docker only recognizes relative paths if they are prefixed with `./`.
414-
mount_type: Literal["bind", "volume"] = "bind" if src.startswith(("/", "~", "./")) else "volume"
413+
# Note that Docker only recognizes relative paths if they are prefixed with `.`.
414+
mount_type: Literal["bind", "volume"] = "bind" if src.startswith(("/", ".")) else "volume"
415415

416416
mounts.append(
417417
Mount(type=mount_type, path=dst, source=src, read_only=read_only, volume_options=volume_options)
@@ -460,7 +460,7 @@ def __validate_extra_mount_specs(_ctx: Context, _param: Option, value: list[str]
460460

461461
for spec in value:
462462
src, dst, *_ = spec.split(":", 2)
463-
mount_type: Literal["bind", "volume"] = "bind" if src.startswith(("/", "~", "./")) else "volume"
463+
mount_type: Literal["bind", "volume"] = "bind" if src.startswith(("/", ".")) else "volume"
464464
if mount_type == "bind" and not Path(src).exists():
465465
msg = f"Invalid mount source: {spec}. Source must be an existing path on the host."
466466
raise BadParameter(msg)

0 commit comments

Comments
 (0)