Article · python / zip / cli
What is actually inside the ZIP you are about to share?
Compare a final ZIP inventory with an independently prepared JSON list; spot a missing license and extra log without claiming content security.
You have finished a small Python utility. The code runs, the usage notes are written, and the remaining step looks routine: compress the folder and share the ZIP. During development, however, that folder collected more than release files. A debug log stayed behind. A private note was forgotten. The license lives somewhere else. A successful application test does not reveal those packaging mistakes.
Consider a deliberately small release. It should contain tool.py, README.md and LICENSE. Those three paths describe the intended package before we inspect its archive. Opening the ZIP and checking by hand is reasonable for a small project. The difficulty is repeating that check consistently when releases become routine and a familiar filename stops attracting attention.
Now suppose the final archive contains README.md and tool.py, but LICENSE was omitted. A development file named debug.log was included by accident. The download may work, the size may look plausible, and the utility may still run. None of those observations establishes that the files being sent match the files we intended to distribute.
Compare the archive
ZipScope addresses that specific question. It is an offline Python command line tool that compares the file inventory of an explicitly selected ZIP with an independently prepared JSON allowlist. It uses only the standard library. It can report differences as readable text or deterministic JSON for another checking step to consume.
The policy contains full relative file paths and a version value of 1. In this example, the files list names README.md, LICENSE and tool.py. If the archive places everything under a release directory, the policy must instead include paths such as release/README.md. ZipScope does not remove a common prefix, fold case or guess which spelling was intended.
The policy's origin matters. Generating a list from the archive being checked and treating it as approved would make both the missing license and the extra log disappear from the question. The list should represent an earlier decision about the release. Update it when the intended contents change, after review, rather than expanding it merely to silence findings.
Read the findings
From the tool directory, run python3 zipscope.py examples/demo-findings.zip examples/allowlist.json. The synthetic demonstration reports LICENSE as missing and debug.log as unexpected. It returns exit code 1. That means comparison completed and found an inventory difference. ZipScope neither deletes the log nor inserts a replacement license into the archive.
The developer then reviews the two findings, fixes the packaging process, rebuilds the ZIP and checks that final file again. The existing policy stays independent of the archive. Both input files are read-only to ZipScope. Deciding whether a log belongs in a release remains a human decision; a filename comparison cannot supply the business context behind it.
Interpret the result
Exit code 0 means the inventory matches the policy. Code 2 means comparison could not complete because an input was unreadable, malformed, unsupported or over a fixed limit. That distinction matters in a script: failure to perform a check must not become a successful match. JSON expresses the same distinction through its status field.
Directory handling is explicit. Valid directory entries are checked and counted but excluded from file comparison. Empty directories are not required by the policy, and src/tool.py does not require a separate src/ entry. Duplicate names and file/directory collisions stop comparison. Absolute paths, parent traversal, backslashes, control characters and symlink metadata are refused rather than silently rewritten.
Names are compared case-sensitively and exactly by Unicode code point. There is no Unicode normalization. Fixed bounds limit the archive to 64 MiB, its central directory to 4 MiB, the policy to 1 MiB and the inventory to 4096 entries including directories. Names have byte limits too. Only classic single-disk ZIP is supported; ZIP64 and encrypted members are outside this version's scope.
Keep content checks separate
The most important boundary is content. ZipScope does not open, decompress, extract or execute members. It reads bounded raw trailer bytes to locate metadata and parses the central directory without interpreting payloads. Local member headers, CRC values and body integrity are not validated. A password inside an allowed README.md will pass this check. A damaged body can also pass an inventory match.
Consequently, the useful result is “inventory matches policy.” Calling the ZIP safe or clean would claim more than was checked. Reports omit bodies, archive comments and raw exception messages, but filenames can themselves disclose client names or private work. Review a report before sharing it publicly, even when its terminal control characters have been escaped.
Other tools cover different parts of the workflow. Git archive creates an archive from a tree, while export-ignore controls exclusions during that creation. Gitleaks looks for secrets in content. ZipScope compares the resulting ZIP's inventory with an intended list. Each answers a separate question; none of these descriptions makes the others redundant.
For an occasional tiny release, a careful manual check may be enough. For repeated distributions, a reviewed list and a repeatable command keep the packaging decision visible. The extra log and missing license are a small example of that benefit. Content review, functional testing and the final publishing decision remain separate responsibilities after the inventory check.
Download ZipScope or view the MIT-licensed source for usage.