pub struct PackageLimits {
pub max_total_uncompressed: u64,
pub max_single_uncompressed: u64,
pub max_compression_ratio: u64,
pub max_entries: usize,
pub max_filename_len: usize,
}Expand description
ZIP archive size and complexity limits to prevent decompression bombs and element explosion attacks.
§Examples
use easydoc_reader::security::PackageLimits;
let limits = PackageLimits::new();
// Default: 100 MB total, 50 MB per entry, 100x ratio, 10 000 entries
assert_eq!(limits.max_total_uncompressed, 100 * 1024 * 1024);Fields§
§max_total_uncompressed: u64Maximum total uncompressed size across all entries (bytes). Default: 100 MB.
max_single_uncompressed: u64Maximum uncompressed size for a single entry (bytes). Default: 50 MB.
max_compression_ratio: u64Maximum allowed compression ratio (uncompressed / compressed). Default: 100.
max_entries: usizeMaximum number of entries in the archive. Default: 10 000.
max_filename_len: usizeMaximum length of a single filename (bytes). Default: 256.
Implementations§
Source§impl PackageLimits
impl PackageLimits
Sourcepub fn validate_archive<R: Read + Seek>(
&self,
archive: &mut ZipArchive<R>,
) -> Result<(), String>
pub fn validate_archive<R: Read + Seek>( &self, archive: &mut ZipArchive<R>, ) -> Result<(), String>
Validates a ZIP archive against all configured limits.
Checks:
- Entry count does not exceed
max_entries. - Each filename is within
max_filename_len. - No path traversal (
..or leading/) – Zip Slip prevention. - No single entry exceeds
max_single_uncompressed. - Per-entry compression ratio does not exceed
max_compression_ratio. - Total uncompressed size does not exceed
max_total_uncompressed. - Overall compression ratio does not exceed
max_compression_ratio.
§Errors
Returns a human-readable error describing which limit was exceeded.
Trait Implementations§
Source§impl Clone for PackageLimits
impl Clone for PackageLimits
Source§fn clone(&self) -> PackageLimits
fn clone(&self) -> PackageLimits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PackageLimits
impl Debug for PackageLimits
Auto Trait Implementations§
impl Freeze for PackageLimits
impl RefUnwindSafe for PackageLimits
impl Send for PackageLimits
impl Sync for PackageLimits
impl Unpin for PackageLimits
impl UnsafeUnpin for PackageLimits
impl UnwindSafe for PackageLimits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more