Limits
provide.foundation.archive.limits
¶
TODO: Add module docstring.
Classes¶
ArchiveLimits
¶
Configurable limits for archive extraction to prevent decompression bombs.
Attributes:
| Name | Type | Description |
|---|---|---|
max_total_size |
int
|
Maximum total extracted size in bytes (default: 1GB) |
max_file_count |
int
|
Maximum number of files in archive (default: 10,000) |
max_compression_ratio |
float
|
Maximum compression ratio (default: 100:1) |
max_single_file_size |
int
|
Maximum size of any single file (default: 100MB) |
enabled |
bool
|
Whether to enforce limits (default: True) |
ExtractionTracker
¶
Track extraction progress to enforce limits.
Initialize tracker with limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limits
|
ArchiveLimits
|
Archive extraction limits |
required |
Source code in provide/foundation/archive/limits.py
Functions¶
add_extracted_size
¶
Track extracted size and check total limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Size of extracted content in bytes |
required |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If total extracted size exceeds limit |
Source code in provide/foundation/archive/limits.py
check_compression_ratio
¶
Check if compression ratio exceeds limit.
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If compression ratio exceeds limit |
Source code in provide/foundation/archive/limits.py
check_file_count
¶
Check if adding files would exceed limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of files to add |
1
|
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If file count would exceed limit |
Source code in provide/foundation/archive/limits.py
check_file_size
¶
Check if file size exceeds single file limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
File size in bytes |
required |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If file size exceeds limit |
Source code in provide/foundation/archive/limits.py
set_compressed_size
¶
Set the compressed archive size for ratio calculation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Compressed archive size in bytes |
required |
validate_member_size
¶
Validate a single archive member before extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_size
|
int
|
Uncompressed size of the member |
required |
compressed_member_size
|
int | None
|
Optional compressed size for ratio check |
None
|
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If member violates any limits |