Files

3.5 KiB

Archive Streaming Reader, Atomic Staged Publication, Reproducible Creation & Child Isolation

Task ID: M-ARCHIVE-01..05 Phase: P2 (Wave 6B) Status: APPROVED Contracts: C-02, C-03, C-04, C-05, C-06, C-07

1. Context and baseline

Void::Archive preserves the existing incremental extract(path, destination, ExtractionOptions) API and anti-traversal/symlink-swap/size-limit tests while adding typed error reporting (kArchiveErrorDomain = 17), bounded streaming Reader (open_reader, next_entry, read_chunk, skip_entry, normal/forensic list_entries), atomic staged extraction and no-replace directory publication (StagedTree, extract_staged, publish, cleanup_stale_staging), reproducible tar/tar.zstd creation (create_archive), and hardened child-process isolated extraction (extract_staged_isolated, run_isolated_worker_main).

2. Deliverables

  • src/Archive/module.cmake (INTERNAL_DEPS Functional Time System, EXTERNAL_DEPS LibArchive::LibArchive).
  • include/Void/Archive/Types.hpp: kArchiveErrorDomain = 17, ArchiveErrorCode, make_archive_error, ReadLimits (10,000 entries, 512 MiB file, 2 GiB total, 1 GiB compressed, 8 MiB metadata, 64 KiB transfer chunk, 4 KiB path, 255B component, 64 components), EntryInfo, ProgressEvent, PublicationOutcome, PublicationReceipt, CreationOptions, IsolationOptions (128 MiB RSS, 60s timeout), ByteSource/ByteSink + span/vector/file adapters.
  • include/Void/Archive/Archive.hpp, src/Archive/Archive.cpp, src/Archive/StagedArchive.cpp: preserve extract(); add Reader, list_entries (normal + opt-in forensic), StagedTree, extract_staged (exclusive 0700 dir, O_NOFOLLOW, 0644/0755, bottom-up dir fsync, completion inventory, no-follow cleanup), publish via Linux renameat2(..., RENAME_NOREPLACE) (unsupported_capability on ENOSYS/EINVAL, PublicationOutcome::Unknown on post-rename parent fsync failure), cleanup_stale_staging, reproducible create_archive, and extract_staged_isolated / run_isolated_worker_main via Void::Process::spawn (ASan-safe rlimits + parent verification of staged inventory).
  • tests/helpers/ArchiveWorker.cpp wired as VoidArchiveWorker in tests/CMakeLists.txt, tests/standalone/Archive/ArchiveHardening.cpp, tests/package/ArchiveOnly/*, registered in tests/package/InstalledComponents.cmake.

3. Edge cases

  • skip_entry still decodes and accounts for actual decompressed bytes against per-entry and total limits.
  • File-as-parent path conflicts (e.g. file a followed by a/b, or a/b followed by file a) and non-zero/zero invalid limits are rejected cleanly.
  • Diagnostics cap path rendering at 4 KiB and escape control characters / attacker newlines.
  • Post-rename parent fsync failure reports PublicationOutcome::Unknown without falsely claiming rollback; pre-publish failure cleans only the owned staging descriptor and preserves primary error + staging id if cleanup fails.
  • Under __SANITIZE_ADDRESS__, child worker avoids fatal RLIMIT_AS and enforces RLIMIT_CPU/RLIMIT_FSIZE/RLIMIT_NOFILE + /proc/self/statm RSS enforcement.

4. Verification commands

dev cpp-gcc -p libarchive -c bash -lc 'cmake -S . -B /tmp/void-w6b-archive -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOID_ENABLED_MODULES="Archive;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w6b-archive && /tmp/void-w6b-archive/tests/VoidTests --filter "Archive*|archive_*" && ctest --test-dir /tmp/void-w6b-archive --output-on-failure --timeout 120'