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::create_archive_with_progress;
pub use api::extract_archive;
pub use api::extract_archive_with_options;
pub use api::extract_archive_with_options_and_progress;
pub use api::extract_archive_with_progress;
pub use api::extract_to_sink;
pub use api::extract_to_sink_with_progress;
pub use api::list_archive;
pub use api::list_archive_with_options;
pub use api::list_reader;
pub use api::list_reader_with_progress;
pub use api::verify_archive;
pub use api::verify_archive_with_options;
pub use api::verify_reader;
pub use api::verify_reader_with_progress;
pub use archive::Archive;
pub use archive::ArchiveBuilder;
pub use config::DecompressionBudget;
pub use config::ExtractionOptions;
pub use config::IntegrityCheck;
pub use config::ListOptions;
pub use config::ParallelDecode;
pub use config::SecurityConfig;
pub use config::StoredTargets;
pub use config::Unvalidated;
pub use config::Validated;
pub use config::VerificationOptions;
pub use config::ZipConsistencyPolicy;
pub use error::ArchiveError;
pub use error::CentralRecordOrdinal;
pub use error::CompressionRatio;
pub use error::EndRecordKind;
pub use error::ErrorCode;
pub use error::FfiErrorMessage;
pub use error::FfiKind;
pub use error::HiddenRegion;
pub use error::IoContext;
pub use error::PartialOutcome;
pub use error::PartialWrites;
pub use error::PolicySetting;
pub use error::QuotaResource;
pub use error::ReaderFormatError;
pub use error::Result;
pub use error::ZipBombDetails;
pub use error::ZipBombScope;
pub use error::ZipEntryIndex;
pub use error::ZipHeaderField;
pub use error::ZipInconsistency;
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 inspection::list_archive_with_progress;
pub use inspection::verify_archive_with_progress;
pub use reader::ArchiveReader;
pub use reader::SeekableFormat;
pub use report::ExtractionReport;
pub use report::NoopProgress;
pub use report::ProgressCallback;
pub use creation::ArchiveCreator;
pub use creation::CreationConfig;
pub use creation::CreationReport;
pub use formats::traits::FormatCreator;
pub use writer::ArchiveWriter;
pub use writer::create_to_bytes;
pub use writer::create_to_writer;
pub use writer::create_to_writer_with_progress;
pub use inspection::ArchiveEntry;
pub use inspection::ArchiveManifest;
pub use inspection::CheckStatus;
pub use inspection::EntryCompression;
pub use inspection::IntegrityGaps;
pub use inspection::IntegrityStatus;
pub use inspection::IssueCategory;
pub use inspection::IssueSeverity;
pub use inspection::LinkTarget;
pub use inspection::ManifestEntryKind;
pub use inspection::ManifestEntryType;
pub use inspection::OversizedEntry;
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::SanitizedMode;
pub use security::ValidationReport;
pub use sink::EntrySink;
pub use sink::MemoryEntry;
pub use sink::MemoryEntryKind;
pub use sink::MemoryFile;
pub use sink::MemoryLimit;
pub use sink::MemorySink;
pub use sink::SinkFull;
pub use sink::SinkOptions;
pub use sink::extract_bytes_to_memory;
pub use sink::utf8_entry_path;
pub use types::DestDir;
pub use types::EntryType;
pub use types::SafePath;

Modules§

api
High-level public API for archive extraction, creation, and inspection.
archive
Archive types and builders.
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.

Enums§

LinkKind
The kind of link a target belongs to; the host limits them differently.
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.

Functions§

validate_config_entry
Validates a single caller-supplied SecurityConfig entry string. Shared by exarch-python and exarch-node. Validates a single caller-supplied SecurityConfig entry string.
validate_raw_path_str
Validates a raw, caller-supplied path string before it enters the archive pipeline. Shared by exarch-python and exarch-node. Validates a raw, caller-supplied path string before it enters the archive pipeline.