Skip to content

Commit

Permalink
library: allow .ix-apps for ix_volumes (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros-k authored Dec 23, 2024
1 parent af6890d commit 269607e
Show file tree
Hide file tree
Showing 57 changed files with 12 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def test_is_allowed_path_direct(test_path, expected):
assert is_allowed_path(test_path) == expected


@patch.object(Path, "resolve", mock_resolve)
def test_is_allowed_path_ix_volume():
"""Test that IX volumes are not allowed"""
assert is_allowed_path("/mnt/.ix-apps/something", True)


@patch.object(Path, "resolve", mock_resolve)
def test_is_allowed_path_symlink(tmp_path):
"""
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions library/2.1.5/validations.py → library/2.1.6/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def valid_fs_path_or_raise(path: str):
return path


def is_allowed_path(input_path: str) -> bool:
def is_allowed_path(input_path: str, is_ix_volume: bool = False) -> bool:
"""
Validates that the given path (after resolving symlinks) is not
one of the restricted paths or within those restricted directories.
Expand All @@ -159,15 +159,15 @@ def is_allowed_path(input_path: str) -> bool:
"""
# Resolve the path to avoid symlink bypasses
real_path = Path(input_path).resolve()
for restricted in RESTRICTED:
for restricted in RESTRICTED if not is_ix_volume else [r for r in RESTRICTED if r != Path("/mnt/.ix-apps")]:
if real_path.is_relative_to(restricted):
return False

return real_path not in RESTRICTED_IN


def allowed_fs_host_path_or_raise(path: str):
if not is_allowed_path(path):
def allowed_fs_host_path_or_raise(path: str, is_ix_volume: bool = False):
if not is_allowed_path(path, is_ix_volume):
raise RenderError(f"Path [{path}] is not allowed to be mounted.")
return path

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, render_instance: "Render", config: "IxStorageIxVolumeConfig")
)

path = valid_fs_path_or_raise(ix_volumes[dataset_name].rstrip("/"))
self.source = allowed_fs_host_path_or_raise(path)
self.source = allowed_fs_host_path_or_raise(path, True)

def get(self):
return self.source
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion library/hashes.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133
2.1.5: 94754830801a8fa90e04e35d324a34a51b90d5919e544ebc1018e065adb02a12
2.1.6: 84c965e8b9bea696765ab62b8ee3238162fe7807d0f0a61cf9c153994a47fa90

0 comments on commit 269607e

Please sign in to comment.