1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Extracted entry representations and security bounds.
//!
//! Defines what an extracted file looks like, as well as strict upper bounds
//! to prevent memory exhaustion from hostile archives.
/// Hard upper bound for a single entry payload to limit hostile archives (256 MB).
///
/// Adjust only with care: raising this increases peak memory use per [`ArchiveEntry::data`].
pub const MAX_ENTRY_BYTES: usize = 256 * 1024 * 1024;
/// Maximum number of entries to prevent hostile archives from exhausting resources.
pub const MAX_ENTRIES: usize = 1_000_000;
/// One regular-file payload extracted from an archive.
///
/// Only populated for regular files. Directories and links never appear.
/// On success, `data.len() == size`.
///
/// # Example
///
/// ```
/// use walkkit::archive::ArchiveEntry;
/// let entry = ArchiveEntry {
/// name: "config.json".to_string(),
/// size: 2,
/// data: vec![123, 125].into(), // Arc<[u8]>
/// };
/// assert_eq!(entry.size as usize, entry.data.len());
/// ```