Skip to main content

Crate exarch_core

Crate exarch_core 

Source
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;

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 NonZero value from a constant, failing the build when the constant is zero.
ratio_limit
Builds a RatioLimit from a constant, failing the build when it is not finite and positive.

Structs§

BoundaryPath
Validates a raw, caller-supplied path string before it enters the archive pipeline. Shared by exarch-python and exarch-node. A caller-supplied path string that passed the boundary checks.
CreateRequest
Creates an archive from files and directories.
ExtractRequest
Extracts an archive into a directory.
ListRequest
Lists the contents of an archive without extracting it.
ListedArchive
An archive that was listed and is ready to extract without decoding it again where that is possible.
ListedExtractOptions
The options of ListedArchive::extract: the knobs that may still vary after the archive was listed.
OutputFile
The archive file a creation writes: its path, whether it may replace an existing file and how its format is chosen.
RatioLimit
A compression ratio limit: finite and greater than zero.
SinkExtractRequest
Extracts an archive read from a reader into an EntrySink.
VerifyRequest
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.
LinkKind
The kind of link a target belongs to; the host limits them differently.
OutputFormat
How the archive format of an OutputFile is chosen.
OutputPolicy
Whether creating an output file may replace one that already exists.
PathModel
The path semantics an EntrySink is validated against.

Constants§

MAX_CONFIG_ENTRY_LENGTH
Maximum length, in bytes, of a single SecurityConfig entry — an allowed extension or a banned path component. Shared by exarch-python and exarch-node. Maximum length, in bytes, of a single SecurityConfig entry — 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-python and exarch-node. Maximum length, in bytes, of a raw path string accepted at the FFI boundary.

Traits§

ClosedEnum
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.