Fix test failures and workload/websocket behavior
This commit is contained in:
@@ -33,6 +33,8 @@ class FileStorageService:
|
||||
|
||||
def __init__(self):
|
||||
self.base_dir = Path(settings.UPLOAD_DIR).resolve()
|
||||
# Backward-compatible attribute name for tests and older code
|
||||
self.upload_dir = self.base_dir
|
||||
self._storage_status = {
|
||||
"validated": False,
|
||||
"path_exists": False,
|
||||
@@ -217,15 +219,16 @@ class FileStorageService:
|
||||
PathTraversalError: If the path is outside the base directory
|
||||
"""
|
||||
resolved_path = path.resolve()
|
||||
base_dir = self.base_dir.resolve()
|
||||
|
||||
# Check if the resolved path is within the base directory
|
||||
try:
|
||||
resolved_path.relative_to(self.base_dir)
|
||||
resolved_path.relative_to(base_dir)
|
||||
except ValueError:
|
||||
logger.warning(
|
||||
"Path traversal attempt detected: path %s is outside base directory %s. Context: %s",
|
||||
resolved_path,
|
||||
self.base_dir,
|
||||
base_dir,
|
||||
context
|
||||
)
|
||||
raise PathTraversalError(
|
||||
|
||||
Reference in New Issue
Block a user