safeuploads 0.1.0__tar.gz → 0.1.1__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.
- {safeuploads-0.1.0 → safeuploads-0.1.1}/PKG-INFO +1 -1
- {safeuploads-0.1.0 → safeuploads-0.1.1}/pyproject.toml +1 -1
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/config.py +1 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/enums.py +12 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/inspectors/zip_inspector.py +14 -6
- {safeuploads-0.1.0 → safeuploads-0.1.1}/LICENSE.md +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/README.md +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/__init__.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/exceptions.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/file_validator.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/inspectors/__init__.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/protocols.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/__init__.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/base.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/compression_validator.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/extension_validator.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/unicode_validator.py +0 -0
- {safeuploads-0.1.0 → safeuploads-0.1.1}/safeuploads/validators/windows_validator.py +0 -0
|
@@ -57,6 +57,7 @@ class SecurityLimits:
|
|
|
57
57
|
max_zip_depth: int = 10 # Maximum nesting depth for directories in ZIP
|
|
58
58
|
max_filename_length: int = 255 # Maximum length for individual file names
|
|
59
59
|
max_path_length: int = 1024 # Maximum length for full file paths
|
|
60
|
+
max_number_files_same_type: int = 1000 # Maximum number of files of the same type
|
|
60
61
|
allow_nested_archives: bool = False # Whether to allow nested archive files
|
|
61
62
|
allow_symlinks: bool = False # Whether to allow symbolic links in ZIP
|
|
62
63
|
allow_absolute_paths: bool = False # Whether to allow absolute paths in ZIP
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
class BinaryFileCategory(Enum):
|
|
7
|
+
"""
|
|
8
|
+
Enumeration of binary file categories.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
FITNESS_FILES: Set of file extensions representing fitness or activity binary files (e.g., '.fit').
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
# Fitness/activity binary files
|
|
15
|
+
FITNESS_FILES = {".fit"}
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
class DangerousExtensionCategory(Enum):
|
|
7
19
|
"""
|
|
8
20
|
File extension categories considered potentially dangerous for uploads.
|
|
@@ -9,7 +9,7 @@ import zipfile
|
|
|
9
9
|
from typing import TYPE_CHECKING
|
|
10
10
|
|
|
11
11
|
import logging
|
|
12
|
-
from ..enums import SuspiciousFilePattern, ZipThreatCategory
|
|
12
|
+
from ..enums import SuspiciousFilePattern, ZipThreatCategory, BinaryFileCategory
|
|
13
13
|
from ..exceptions import ZipContentError, FileProcessingError, ErrorCode
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
@@ -220,8 +220,10 @@ class ZipContentInspector:
|
|
|
220
220
|
|
|
221
221
|
# Check for excessive number of same-type files (potential spam/bomb)
|
|
222
222
|
for ext, count in file_types.items():
|
|
223
|
-
if count >
|
|
224
|
-
threats.append(
|
|
223
|
+
if count > self.config.limits.max_number_files_same_type:
|
|
224
|
+
threats.append(
|
|
225
|
+
f"Excessive number of {ext} files: {self.config.limits.max_number_files_same_type}"
|
|
226
|
+
)
|
|
225
227
|
|
|
226
228
|
return threats
|
|
227
229
|
|
|
@@ -355,9 +357,15 @@ class ZipContentInspector:
|
|
|
355
357
|
)
|
|
356
358
|
break
|
|
357
359
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
binary_exts = set()
|
|
361
|
+
for category in BinaryFileCategory:
|
|
362
|
+
binary_exts.update(category.value)
|
|
363
|
+
|
|
364
|
+
ext = os.path.splitext(entry.filename)[1].lower()
|
|
365
|
+
if ext not in binary_exts:
|
|
366
|
+
# Check for script content patterns
|
|
367
|
+
if self._contains_script_patterns(content_sample, entry.filename):
|
|
368
|
+
threats.append(f"Script content detected in '{entry.filename}'")
|
|
361
369
|
|
|
362
370
|
except Exception as err:
|
|
363
371
|
logger.warning(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|