Metadata-Version: 2.5
Name: deepfetch
Version: 1.0.0
Summary: Fetch single files out of large archives and forensic disk images in S3 without downloading them
Project-URL: Homepage, https://github.com/ratstallion/deepfetch
Project-URL: Documentation, https://github.com/ratstallion/deepfetch/blob/main/docs/guide.md
Project-URL: Changelog, https://github.com/ratstallion/deepfetch/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/ratstallion/deepfetch/issues
Author: Jesse
License-Expression: MIT
License-File: LICENSE
Keywords: 7z,archive,disk image,e01,ewf,exfat,ext4,fat,forensics,ntfs,range request,s3,tar,vhdx,vmdk,zip
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: System :: Archiving
Classifier: Topic :: System :: Archiving :: Compression
Classifier: Topic :: System :: Filesystems
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: isal>=1.7
Requires-Dist: msgspec>=0.19
Requires-Dist: obstore>=0.8
Provides-Extra: aes
Requires-Dist: cryptography>=42; extra == 'aes'
Provides-Extra: brotli
Requires-Dist: brotli>=1.2; extra == 'brotli'
Provides-Extra: deflate64
Requires-Dist: inflate64>=1.0.4; extra == 'deflate64'
Provides-Extra: dev
Requires-Dist: backports-zstd>=1.0; (python_version < '3.14') and extra == 'dev'
Requires-Dist: boto3>=1.34; extra == 'dev'
Requires-Dist: brotli>=1.2; extra == 'dev'
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: cryptography>=42; extra == 'dev'
Requires-Dist: inflate64>=1.0.4; extra == 'dev'
Requires-Dist: moto[server]>=5.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: zstd
Requires-Dist: backports-zstd>=1.0; (python_version < '3.14') and extra == 'zstd'
Description-Content-Type: text/markdown

# deepfetch

deepfetch reads single files out of large archives (zip, 7z, tar, gzip) and forensic disk images (E01, Ex01, VHD, VHDX, VMDK, raw; NTFS, ext, FAT, exFAT) in S3 or S3-compatible storage, without downloading them. One caller scans an object into a manifest of member pointers, with each file's metadata. Other callers fetch any one file from its pointer alone, usually with one ranged GET.

Python 3.11+. Depends on `msgspec`, `isal` and `obstore`. MIT license. Extras: `deepfetch[aes]` (encrypted zip and 7z), `deepfetch[brotli]`, `deepfetch[deflate64]` (through LGPL `inflate64`) and `deepfetch[zstd]` (Zstandard below Python 3.14).

## Install

```
pip install "deepfetch[aes,brotli,deflate64,zstd] @ git+<repository URL>@<branch or tag>"
```

The extras add encrypted Archives, Brotli, Deflate64 and Zstandard; the [guide](docs/guide.md#install) says when each is needed.

## Use

```python
import deepfetch

async with deepfetch.Client() as client:            # S3, from the AWS_* environment variables
    scan = await client.scan("evidence", "mail-export.zip")
    async for record in scan:
        if record.kind == "file":
            queue.send(record.path, str(scan.pointer(record)), record.meta())   # "dfp1.…"

# in a worker
async with deepfetch.Client() as client:
    data = await client.fetch(pointer)              # decoded, size and CRC checked
```

An Image (E01, Ex01, raw) lists its partitions, and `client.scan_member(pointer)` lists the files of one. To list everything at every depth (partitions, Filesystems, archives inside archives) in one loop:

```python
async for path, record, pointer in client.walk("evidence", "laptop.E01"):
    print(path, record.kind, record.size)
```

`record.meta()` is the file's metadata as the format stored it: every timestamp at its stored precision and zone, owner, mode and attributes. Sync code, such as dramatiq workers, uses `deepfetch.SyncClient`, one per process.

**[The guide](docs/guide.md)** covers the rest: fanning out across workers, Manifests, Images and their stored hashes, passwords, MinIO and other storage, the metadata fields of each format, which errors to retry, cost and tuning, and what stays compatible across releases. [examples/worker-pipeline](examples/worker-pipeline) is a complete pipeline on dramatiq, RabbitMQ, MinIO and Mongo.

## CLI

```
deepfetch ls s3://bucket/disk.E01 [--flat]
deepfetch manifest s3://bucket/dump.zip -o dump.jsonl
deepfetch manifest pointers dump.jsonl
deepfetch fetch dfp1.… -o out.bin [--first N] [--raw]
deepfetch pointer decode dfp1.…
deepfetch pointer key dfp1.…
deepfetch check-store s3://bucket/prefix
```

`ls` prints every file at every depth, tab-separated: path, kind, size and pointer. `--local ROOT` reads `ROOT/bucket/key` from disk. `check-store` runs every storage call deepfetch depends on against an endpoint and prints pass or fail for each.

## What it reads

- Zip, including Zip64, data descriptors, bytes in front of the zip, CP437, UTF-8 and Unicode Path names, duplicate names, directories and symlinks.
- Stored, Deflate (isal), Deflate64, BZIP2, LZMA, XZ and Zstandard. Other methods, such as PPMd, raise `UnsupportedCompressionMethod` before any request, and `raw=True` still returns the stored bytes. Callers can plug in decoders.
- Split archives and Images: spanned zips (`dump.z01` … `dump.zip`), found from the last part, and byte-split sets (`dump.zip.001`, `disk.dd.001` …), found from the first: `client.scan("bucket", "disk.dd.001")`. A list of keys names the parts explicitly.
- tar (ustar, GNU, PAX), gzip, bare xz, bzip2 and Zstandard streams, and archives nested to any depth: zip in zip, tar.gz, tar in zip, zip in tar. `client.scan_member(pointer)` scans the archive inside a member. The format is detected from the bytes.
- Seek checkpoints for tar inside gzip or inside a Deflate member: `client.scan(..., checkpoints="s3://bucket/key.dfi")` writes a checkpoint index on Linux and macOS, so a fetch decodes from a nearby checkpoint instead of from the start. Without one, a fetch decodes and discards up to `discard_limit` (64 MiB by default) and raises `DiscardLimitExceeded` past it.
- Disk images: E01 and Ex01 (found from the first segment, every segment followed), raw dd, MBR and GPT partition tables, and NTFS. `client.scan("bucket", "disk.E01")` lists the partitions, and `client.scan_member(partition_pointer)` lists the NTFS files with paths. LZNT1 and CompactOS (WOF) compressed files decode, and named streams are listed. Images in many segments get short pointers through a source series.
- 7z: solid and non-solid, LZMA, LZMA2, BZip2, Deflate, Deflate64, Copy, Delta, the BCJ, ARM, ARMT, PPC, SPARC and IA64 filters, and 7zAES with an encrypted header (`scan(..., password=...)`, `deepfetch[aes]`). A 7z can sit inside any other format, and any format inside a 7z. PPMd, BCJ2, ARM64 and RISC-V raise `UnsupportedCompressionMethod`.
- ext2, ext3 and ext4 Filesystems, raw, in a partition (MBR type 83 or GPT Linux data) or in an E01: every file, directory and symbolic link with its path. Extents, block maps, holes, uninitialized extents and inline data read. The journal is not replayed and fscrypt data is not decrypted.
- FAT12, FAT16, FAT32 and exFAT Filesystems, on a raw volume, in a partition or inside an E01: in-use files and directories with long and Unicode names. Deleted files are not listed.
- Encrypted zip members, ZipCrypto and WinZip AES, decrypt with `password=` on `fetch`, `stream` and `scan_member`. AES needs `deepfetch[aes]`. A wrong password raises `WrongPassword`.
- File metadata from every format: NTFS `$STANDARD_INFORMATION` and `$FILE_NAME` times to 100 ns, ext times to the nanosecond with creation time, FAT and exFAT times with their zones, zip NTFS and Unix extra fields, PAX times, 7z times and attributes.
- An E01 or Ex01 scan's `header.image` holds the media MD5 and SHA-1 the imager stored, and the case number, examiner, acquisition date and other acquisition fields.
- Every read is pinned to the archive's ETag. A replaced archive raises `ObjectChanged`.

[docs/spec/0.2.md](docs/spec/0.2.md), [0.3.md](docs/spec/0.3.md), [0.4.md](docs/spec/0.4.md), [0.5.md](docs/spec/0.5.md), [0.6.md](docs/spec/0.6.md), [0.7.md](docs/spec/0.7.md), [0.8.md](docs/spec/0.8.md), [0.9.md](docs/spec/0.9.md) and [1.0.md](docs/spec/1.0.md) list what each release adds.

## Develop

See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports go through [SECURITY.md](SECURITY.md).

```
uv venv --python 3.11 && uv pip install -e ".[dev]"
.venv/Scripts/python -m pytest -q
```

The S3 tests run against moto. Set `DEEPFETCH_TEST_S3_ENDPOINT` plus AWS credentials to run them against a real S3-compatible server too.

To run the S3 suite and `check-store` against a local RustFS, an S3-compatible server, as CI does:

```
docker run -d --name deepfetch-s3 -p 127.0.0.1:9000:9000 \
  -e RUSTFS_ACCESS_KEY=deepfetch -e RUSTFS_SECRET_KEY=deepfetch-secret rustfs/rustfs:1.0.7
export AWS_ACCESS_KEY_ID=deepfetch AWS_SECRET_ACCESS_KEY=deepfetch-secret AWS_DEFAULT_REGION=us-east-1
DEEPFETCH_TEST_S3_ENDPOINT=http://127.0.0.1:9000 python -m pytest -q tests/test_storage_s3.py
AWS_ENDPOINT_URL=http://127.0.0.1:9000 AWS_ALLOW_HTTP=true AWS_VIRTUAL_HOSTED_STYLE_REQUEST=false \
  deepfetch check-store s3://deepfetch-test/ci
```

`.github/workflows/ci.yml` runs the suite on Linux, macOS and Windows, these S3 server steps, and a checked build of the package.
