Skip to main content

Module archive

Module archive 

Source
Expand description

Archive extraction support for SubX.

Provides transparent extraction of archive files supplied as direct -i inputs. Archives discovered during directory traversal are NOT extracted.

§Module Structure

Each supported format lives in its own sub-module, while shared security validation (path-traversal checks, decompression-bomb limits) is centralised in the common module.

  • common — Shared validation: validate_entry_path, ExtractionLimits, size/count constants.
  • zip — ZIP extraction (always available, pure Rust).
  • rar — RAR extraction (feature-gated archive-rar).
  • sevenz — 7-Zip extraction (always available, pure Rust).
  • targz — Tar-gzip extraction (always available, pure Rust).

§Supported Formats

Extension(s)ModuleCrate(s)Feature gate
.zipzipzipalways-on
.rarrarunrar / unrar_sysarchive-rar
.7zsevenzsevenz-rustalways-on
.tar.gz / .tgztargztar + flate2always-on

§Security

All extraction operations enforce:

  • Path traversal prevention (zip-slip)
  • Symlink and hardlink rejection
  • Decompression bomb protection (1 GiB size limit, 10,000 entry limit)

Enums§

ArchiveFormat
Recognised archive formats.

Functions§

detect_format
Detects archive format by file extension (case-insensitive).
extract_archive
Extracts an archive to the given destination directory.