Thanks for helping make archive handling less exciting.
git clone <this repository>
cd zipcheck
python -m pip install -e ".[dev]"
python -m pytest
ruff check src tests tools
mypy src/zipcheckPython 3.10+ is required. Runtime code must stay dependency-free; if a feature ever needs a third-party package, put it in an optional extra and make the feature degrade gracefully when that extra is not installed.
- Never extract member data. Parsers may read metadata, and may decompress a bounded prefix into memory for nested-archive inspection. They must never write extracted content to disk, emit temp files, or call external archive tools.
- Never allocate from a declared size. A header claiming 10 TiB must not cause a 10 TiB allocation. Read in fixed-size chunks and stop at a cap.
- Fail closed. If metadata cannot be read reliably, the result must be
unknown— notclean. - No exceptions escape
scan_file. Malformed input is normal input. - Add a test for every parser change. Prefer a metadata-only fixture (a few dozen bytes) over a real bomb.
- Keep the output stable. JSON field names are part of the public API.
- Add magic/extension routing in
detect.py. - Add a parser module under
src/zipcheck/formats/exposingscan(fp, size, limits, deadline) -> Facts. - Read sizes from headers or indexes. If the format has no size field, use
formats/probe.pywith a bounded output and explain the limitation in the module docstring. - Register it in
engine.PARSERSand decide whether nested inspection is feasible. - Add tests: a clean sample, a declared-huge sample, and a malformed sample.
- Document where the size lives in
docs/metadata-map.mdand add the format to the README table.
- Emit a
Findingwith a stablecode, a severity, and a human explanation. - Policy thresholds belong in
Limits, not hard-coded in a parser. - Keep false positives explainable: "this is a large expansion", not "this is malware".
- Update the rules table in
README.md.
Use tests/helpers.py to build archives. Tests must not contain or download
live bombs. If a real archive is essential to reproduce a bug, minimise it to a
metadata-only file first.
For integration testing against real bombs, use tools/generate_samples.py
inside a disposable VM/container. The generated files are small on disk but
enormous when extracted.
Hypothesis property tests run with the normal suite. The coverage-guided Atheris harness is Linux-only:
python -m pip install -e .[fuzz]
python fuzz/generate_seeds.py fuzz/corpus
python fuzz/fuzz_scan.py fuzz/corpus -max_total_time=120The weekly fuzz workflow runs the same harness and uploads crashing inputs.
- Bump
__version__insrc/zipcheck/__init__.py; the package version is read from that attribute. Add aCHANGELOG.mdentry. - Run the full gate:
pytest,mypy src/zipcheck,ruff check src tests tools,python -m buildandtwine check dist/*. - Commit, then tag and push
vX.Y.Z..github/workflows/release.ymlbuilds and smoke-tests the sdist/wheel, publishes to PyPI through OIDC trusted publishing, and creates a GitHub release. - One-time setup: register a trusted publisher on PyPI for owner
spaxe-dev, repositoryzipcheck, workflowrelease.yml, environmentpypi; create the samepypienvironment in the GitHub repository. - For AUR, wait for the GitHub release, update
pkgverand checksums inpackaging/aur/PKGBUILD, then runupdpkgsumsandmakepkg --printsrcinfo > .SRCINFObefore pushing to the AUR repository.
ruff check src tests toolsmust pass.mypy src/zipcheckmust pass.- Line length 100.
- Type hints on public functions.
- Comments explain why, not what.
See SECURITY.md for how to report parser vulnerabilities privately.