larzarchive
zip/tar with safe extraction. Pure Python, zero dependencies.
Extracting an untrusted archive is a classic vulnerability: a member named
../../etc/cron.d/x or an absolute path escapes the destination ("Zip Slip").
larzarchive refuses those by resolving every member's real path and checking it
stays inside the target - and it skips symlink/device members in tars. A clean
create/extract/list API over the standard library, auto-detecting format.
from larzarchive import create, extract, listing
create("bundle.zip", "myfolder")
create("bundle.tar.gz", ["a.txt", "b.txt"])
extract("bundle.zip", "out/") # raises UnsafeArchive on a malicious member
listing("bundle.zip")
Why
- Safe by default.
extract()validates every member's resolved path against the destination, so path-traversal ("Zip Slip") archives raiseUnsafeArchiveinstead of overwriting files outside the target. It also skips symlink/hardlink/ device entries in tars. (safe=Falseis a documented escape hatch.) - One API, every format. zip, tar, tar.gz, tar.bz2, tar.xz - detected from the
filename.
createtakes a directory, a single file, or a list of paths (or(path, arcname)pairs). - Zero dependencies. A thin, hardened layer over
zipfile/tarfile.
Install
pip install larzarchive
Usage
from larzarchive import create, extract, listing
create("release.tar.gz", "dist") # a directory
create("files.zip", ["a.txt", "b.txt"]) # a list of files
listing("release.tar.gz") # -> member names
paths = extract("release.tar.gz", "unpacked/") # safe; returns extracted paths
Tests
python -m unittest discover -s tests -v # 7 tests incl. zip-slip + tar-slip rejection
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT (c) larz-scripter
Metadata
Release files for larzarchive 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzarchive-0.1.0.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzarchive-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / larzarchive-0.1.0.tar.gz
| Download URL | larzarchive-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f79201741badf3a9cb44606065fa5334147f78dbb566979111f4d730166e0e1e
|
|
BLAKE2b-256 checksum How to use checksums |
44e12647d9fad037a658027c8baecb0de9b5abaf3a7d811cb52c144e4daac6e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzarchive-0.1.0-py3-none-any.whl
| Download URL | larzarchive-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ace58a815a5b5a1628c0f7ef6016edfff8f413dfc565bb252e20b9aa2c7e05a
|
|
BLAKE2b-256 checksum How to use checksums |
4c100410780724fc9ac78f6a9f4536d2f8350497fe7daa72296f8d124c4792f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzarchive 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.