splitlog 4.1.1__tar.gz → 4.1.3__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.
- {splitlog-4.1.1 → splitlog-4.1.3}/PKG-INFO +1 -1
- {splitlog-4.1.1 → splitlog-4.1.3}/pyproject.toml +1 -1
- {splitlog-4.1.1 → splitlog-4.1.3}/splitlog/outputfolder.py +11 -11
- {splitlog-4.1.1 → splitlog-4.1.3}/LICENSE +0 -0
- {splitlog-4.1.1 → splitlog-4.1.3}/README.md +0 -0
- {splitlog-4.1.1 → splitlog-4.1.3}/splitlog/__init__.py +0 -0
- {splitlog-4.1.1 → splitlog-4.1.3}/splitlog/__main__.py +0 -0
|
@@ -77,7 +77,7 @@ def _is_relative_to(path: Path, parent: Path) -> bool:
|
|
|
77
77
|
return True
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
class DefaultLocalFilesystemOutputFolder(OutputFolder
|
|
80
|
+
class DefaultLocalFilesystemOutputFolder(OutputFolder):
|
|
81
81
|
"""Encapsulates filesystem IO on output folders.
|
|
82
82
|
|
|
83
83
|
This implementation is portable but unsafe to use when invoking splitlog with privileges.
|
|
@@ -114,11 +114,11 @@ class DefaultLocalFilesystemOutputFolder(OutputFolder, metaclass=abc.ABCMeta):
|
|
|
114
114
|
os.mkdir(real_path, mode=self.DIR_MODE)
|
|
115
115
|
|
|
116
116
|
def _check_paths(self, path: Path) -> Path:
|
|
117
|
-
|
|
117
|
+
if path.is_absolute():
|
|
118
|
+
raise ValueError(f"Path {path} must be relative")
|
|
118
119
|
real_path = Path(os.path.normpath(self._path / path))
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
), f"Path {path} outside {self._path}"
|
|
120
|
+
if not _is_relative_to(real_path, self._path):
|
|
121
|
+
raise ValueError(f"Path {path} outside {self._path}")
|
|
122
122
|
return real_path
|
|
123
123
|
|
|
124
124
|
def create(self, path: Path) -> BinWriter:
|
|
@@ -214,18 +214,18 @@ class LinuxLocalFilesystemOutputFolder(OutputFolder):
|
|
|
214
214
|
|
|
215
215
|
def create(self, path: Path) -> BinWriter:
|
|
216
216
|
real_path = self._ensure_path_under_root(path)
|
|
217
|
-
return FileWrapper(open(
|
|
217
|
+
return FileWrapper(open(real_path, "xb", opener=self._opener))
|
|
218
218
|
|
|
219
219
|
def _ensure_path_under_root(self, path: Path) -> Path:
|
|
220
|
-
|
|
220
|
+
if path.is_absolute():
|
|
221
|
+
raise ValueError(f"Path {path} must be relative")
|
|
221
222
|
|
|
222
223
|
# remove all ".." and "." components
|
|
223
224
|
real_path = Path(os.path.normpath(self._path / path))
|
|
224
225
|
|
|
225
|
-
#
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
), f"Path {path} outside {self._path}"
|
|
226
|
+
# ensure resulting absolute path is still inside self._path
|
|
227
|
+
if not _is_relative_to(real_path, self._path):
|
|
228
|
+
raise ValueError(f"Path {path} outside {self._path}")
|
|
229
229
|
return real_path.relative_to(self._path)
|
|
230
230
|
|
|
231
231
|
@staticmethod
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|