Fix test failures and workload/websocket behavior

This commit is contained in:
beabigegg
2026-01-11 08:37:21 +08:00
parent 3bdc6ff1c9
commit f5f870da56
49 changed files with 3006 additions and 1132 deletions

View File

@@ -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(