Expand description
Archive extraction, hardened against hostile archives.
Both tar_gz and zip() iterate an archive in memory and write selected entries beneath
dest. strip_prefix (e.g. Some("package/") for npm tarballs) is removed from each entry
path before Select is applied.
Archive contents are untrusted input, so extraction is defended in layers:
- Entry-type allowlist — only regular files and directories are written; symlinks, hardlinks, device nodes, FIFOs and sockets are skipped, so an archive can’t plant a link or special file.
- Structural path check (
crate::path_safety::safe_join) — reject.., absolute, root/drive, and backslash segments before touching the filesystem. - Symlink-resolved containment (
crate::path_safety::contained_target) — each write’s parent is canonicalized and required to stay within the canonicalizeddest, so even a symlink already on disk (pre-existing, or from a destination shared across calls) can’t redirect a write outside it. - Size cap — entries are streamed (never buffered whole) and the total is bounded, so a decompression bomb can’t exhaust memory or disk.
Enums§
- Select
- Which archive entries to extract, and where each lands (relative to
dest).