qodalis-cli-server-plugin-filesystem 1.0.0b6__tar.gz → 1.0.0b7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/PKG-INFO +1 -1
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/pyproject.toml +1 -1
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/providers/os_provider.py +14 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/.gitignore +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/LICENSE +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/__init__.py +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/errors.py +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/i_file_storage_provider.py +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/models.py +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/providers/__init__.py +0 -0
- {qodalis_cli_server_plugin_filesystem-1.0.0b6 → qodalis_cli_server_plugin_filesystem-1.0.0b7}/qodalis_cli_filesystem/providers/in_memory_provider.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: qodalis-cli-server-plugin-filesystem
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0b7
|
|
4
4
|
Summary: Filesystem abstraction layer for Qodalis CLI servers — interfaces, models, errors, and built-in providers (in-memory, OS)
|
|
5
5
|
Project-URL: Homepage, https://github.com/qodalis-solutions/cli-server-python
|
|
6
6
|
Project-URL: Repository, https://github.com/qodalis-solutions/cli-server-python
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qodalis-cli-server-plugin-filesystem"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.0b7"
|
|
8
8
|
description = "Filesystem abstraction layer for Qodalis CLI servers — interfaces, models, errors, and built-in providers (in-memory, OS)"
|
|
9
9
|
readme = { text = "", content-type = "text/plain" }
|
|
10
10
|
license = "MIT"
|
|
@@ -138,6 +138,7 @@ class OsFileStorageProvider(IFileStorageProvider):
|
|
|
138
138
|
|
|
139
139
|
async def remove(self, path: str, recursive: bool = False) -> None:
|
|
140
140
|
resolved = self._validate(path)
|
|
141
|
+
self._ensure_not_root(resolved, path)
|
|
141
142
|
|
|
142
143
|
if not os.path.exists(resolved):
|
|
143
144
|
raise FileStorageNotFoundError(path)
|
|
@@ -165,6 +166,8 @@ class OsFileStorageProvider(IFileStorageProvider):
|
|
|
165
166
|
async def move(self, src: str, dest: str) -> None:
|
|
166
167
|
resolved_src = self._validate(src)
|
|
167
168
|
resolved_dest = self._validate(dest)
|
|
169
|
+
self._ensure_not_root(resolved_src, src)
|
|
170
|
+
self._ensure_not_root(resolved_dest, dest)
|
|
168
171
|
|
|
169
172
|
if not os.path.exists(resolved_src):
|
|
170
173
|
raise FileStorageNotFoundError(src)
|
|
@@ -196,6 +199,17 @@ class OsFileStorageProvider(IFileStorageProvider):
|
|
|
196
199
|
async def upload_file(self, path: str, content: bytes) -> None:
|
|
197
200
|
await self.write_file(path, content)
|
|
198
201
|
|
|
202
|
+
def _ensure_not_root(self, resolved: str, path: str) -> None:
|
|
203
|
+
"""An allowed root itself cannot be removed, moved/renamed or
|
|
204
|
+
replaced: ``rm /srv/files`` would wipe the whole share and leave the
|
|
205
|
+
provider pointing at nothing.
|
|
206
|
+
|
|
207
|
+
Raises:
|
|
208
|
+
FileStoragePermissionError: If *resolved* is an allowed root.
|
|
209
|
+
"""
|
|
210
|
+
if resolved in self._allowed_paths:
|
|
211
|
+
raise FileStoragePermissionError(path)
|
|
212
|
+
|
|
199
213
|
def _validate(self, path: str) -> str:
|
|
200
214
|
"""Resolve *path* and check it against the allowed whitelist.
|
|
201
215
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|