Expand description
Memory-safe archive extraction library with security validation.
exarch-core provides a safe API for extracting archive files (tar, zip)
with built-in protection against common security vulnerabilities like
path traversal, zip bombs, symlink attacks, and hardlink attacks.
§Examples
use exarch_core::SecurityConfig;
use exarch_core::extract_archive;
let config = SecurityConfig::default();
let report = extract_archive("archive.tar.gz", "/output/dir", &config)?;
println!("Extracted {} files", report.files_extracted);Re-exports§
pub use api::create_archive;pub use api::extract_archive;pub use api::list_archive;pub use api::verify_archive;pub use config::Admit;pub use config::DecodeReuse;pub use config::DecodeReuseKind;pub use config::DecompressionBudget;pub use config::ExtractionOptions;pub use config::IntegrityCheck;pub use config::ListOptions;pub use config::ParallelDecode;pub use config::ReuseLimit;pub use config::SecurityConfig;pub use config::SolidArchives;pub use config::SolidLimits;pub use config::StoredTargets;pub use config::VerificationOptions;pub use config::ZipConsistencyPolicy;pub use error::ArchiveError;pub use error::CentralRecordOrdinal;pub use error::CompressionRatio;pub use error::ConfigProblem;pub use error::ConfigSetting;pub use error::EndRecordKind;pub use error::ErrorCode;pub use error::ExcludeRefusal;pub use error::FfiErrorMessage;pub use error::FfiKind;pub use error::FfiSourceFault;pub use error::HiddenRegion;pub use error::InvalidArchiveSubCode;pub use error::IoContext;pub use error::KindSource;pub use error::Malformation;pub use error::NativeKind;pub use error::Partial;pub use error::PartialOutcome;pub use error::PartialWrites;pub use error::PolicySetting;pub use error::PortableHazard;pub use error::QuotaKind;pub use error::QuotaResource;pub use error::ReaderFormatError;pub use error::Result;pub use error::SecurityViolationSubCode;pub use error::SolidMemoryScope;pub use error::SpecialFile;pub use error::SubCode;pub use error::TarAmbiguity;pub use error::TarExtensionKind;pub use error::TarHeaderField;pub use error::TarNonRegularKind;pub use error::TarPathKey;pub use error::TarTrailerRefusal;pub use error::TrailerCorruption;pub use error::Unclassified;pub use error::Violation;pub use error::ZipBombDetails;pub use error::ZipBombScope;pub use error::ZipEntryIndex;pub use error::ZipHeaderField;pub use error::ZipInconsistency;pub use error::ZipNonRegularKind;pub use error::ZipStreamUndecided;pub use error::ZipUncomparable;pub use error::redaction::format_entry_path_for_error;pub use error::redaction::sanitize_io_error_for_error;pub use error::redaction::sanitize_path_for_error;pub use reader::ArchiveReader;pub use reader::SeekableFormat;pub use report::EntryPosition;pub use report::EntryTotal;pub use report::ExtractionReport;pub use report::ExtractionWarning;pub use report::NoopProgress;pub use report::ProgressCallback;pub use report::Skip;pub use report::SkipKind;pub use report::Skips;pub use creation::CreationConfig;pub use creation::CreationReport;pub use creation::CreationWarning;pub use creation::ExcludePattern;pub use writer::ArchiveWriter;pub use inspection::ArchiveEntry;pub use inspection::ArchiveManifest;pub use inspection::CheckStatus;pub use inspection::EntryCompression;pub use inspection::Finding;pub use inspection::Heuristic;pub use inspection::IntegrityGaps;pub use inspection::IntegrityStatus;pub use inspection::IssueCategory;pub use inspection::IssueSeverity;pub use inspection::Landing;pub use inspection::LandingKind;pub use inspection::LandingPath;pub use inspection::LinkTarget;pub use inspection::ManifestEntryKind;pub use inspection::ManifestEntryType;pub use inspection::NameCollisionKind;pub use inspection::OversizedEntry;pub use inspection::PathOccupant;pub use inspection::SolidBlock;pub use inspection::UnverifiedEntry;pub use inspection::UnverifiedReason;pub use inspection::VerificationIssue;pub use inspection::VerificationReport;pub use inspection::VerificationStatus;pub use security::AdmittedSize;pub use security::Compressed;pub use security::EntrySize;pub use security::HardlinkTarget;pub use security::RawMode;pub use security::SanitizedMode;pub use security::Uncompressed;pub use sink::CallbackEntry;pub use sink::CallbackError;pub use sink::CallbackSink;pub use sink::EntrySink;pub use sink::MemoryEntry;pub use sink::MemoryEntryKind;pub use sink::MemoryExtractRequest;pub use sink::MemoryFile;pub use sink::MemoryLimit;pub use sink::MemorySink;pub use sink::SinkFull;pub use sink::SinkOptions;pub use sink::extract_reader_to_callback;pub use sink::extract_reader_to_memory;pub use types::Extension;pub use types::PathComponentName;pub use types::CheckedLinkTarget;pub use types::DestDir;pub use types::SafePath;pub use types::SafeSymlink;
Modules§
- api
- High-level public API for archive extraction, creation, and inspection.
- config
- Security configuration for archive extraction.
- creation
- Archive creation module.
- error
- Error types for archive operations.
- formats
- Archive format implementations.
- inspection
- Archive inspection without extraction.
- reader
- Archives read from a caller-supplied reader instead of a path.
- report
- Extraction operation reporting.
- security
- Security validation modules.
- sink
- Extraction into caller-owned storage instead of a directory.
- types
- Type-safe wrappers for archive extraction operations.
- writer
- Archive creation into a caller-supplied writer instead of a path.
Macros§
- non_
zero - Builds a
NonZerovalue from a constant, failing the build when the constant is zero. - ratio_
limit - Builds a
RatioLimitfrom a constant, failing the build when it is not finite and positive.
Structs§
- Boundary
Path - Validates a raw, caller-supplied path string before it enters the
archive pipeline. Shared by
exarch-pythonandexarch-node. A caller-supplied path string that passed the boundary checks. - Create
Request - Creates an archive from files and directories.
- Extract
Request - Extracts an archive into a directory.
- List
Request - Lists the contents of an archive without extracting it.
- Listed
Archive - An archive that was listed and is ready to extract without decoding it again where that is possible.
- Listed
Extract Options - The options of
ListedArchive::extract: the knobs that may still vary after the archive was listed. - Output
File - The archive file a creation writes: its path, whether it may replace an existing file and how its format is chosen.
- Ratio
Limit - A compression ratio limit: finite and greater than zero.
- Sink
Extract Request - Extracts an archive read from a reader into an
EntrySink. - Verify
Request - Verifies an archive’s security without extracting it.
Enums§
- Durability
- Whether a created archive is flushed to stable storage before it is reported as written.
- Limit
- A positive bound, or no bound.
- Link
Kind - The kind of link a target belongs to; the host limits them differently.
- Output
Format - How the archive format of an
OutputFileis chosen. - Output
Policy - Whether creating an output file may replace one that already exists.
- Path
Model - The path semantics an
EntrySinkis validated against.
Constants§
- MAX_
CONFIG_ ENTRY_ LENGTH - Maximum length, in bytes, of a single
SecurityConfigentry — an allowed extension or a banned path component. Shared byexarch-pythonandexarch-node. Maximum length, in bytes, of a singleSecurityConfigentry — an allowed extension or a banned path component. - MAX_
PATH_ LENGTH - Maximum length, in bytes, of a raw path string accepted at the FFI
boundary. Shared by
exarch-pythonandexarch-node. Maximum length, in bytes, of a raw path string accepted at the FFI boundary.
Traits§
- Closed
Enum - An enum with a fixed set of variants and a stable string form for each.
Functions§
- bytes_
text - Renders raw bytes of an archive name as text, by the rules of
path_text. - non_
zero_ u64 - Parses a runtime byte count, refusing zero.
- non_
zero_ usize - Parses a runtime count, refusing zero.
- path_
text - Renders a path as text so that two distinct paths never render alike.
- positive_
from_ f64 - Parses a floating-point number from a binding (a JavaScript number) into a positive whole count of at most 2^53 - 1.
- positive_
from_ i128 - Parses a signed integer from a binding, refusing zero, negative values and
values above
u64::MAX.