Check an archive before unpacking it, and verify checksums
Beside the generator, tfg has small tools for files you already have: whether an
archive is safe to unpack, and whether a file or a whole folder is still what its checksum says.
They run on your machine, with no upload and no account.
The short answer
tfg tool archive-scan download.zip reads the archive without unpacking anything and
ends with code 0 when it is safe, or 7 with a list of what it found.
tfg tool checksum setup.exe --expected <sum> says whether a file matches the
sum a download page gave you.
What there is
Which tools are there?
This is the list the program prints, read from it when this page is built.
tfg tool list prints the same, and tfg tool show <id> says what one
of them takes. Every tool is also on the Tools screen of the window, with the same settings.
| Tool | What it answers |
|---|---|
archive-scan |
Is this archive safe to unpack? |
checksum |
Is this file the one it claims to be? |
checksum-check |
Is every file still what its checksum file says? |
checksum-write |
How will I know later that none of these files changed? |
Archives
Is this archive safe to unpack? Zip slip and zip bombs
archive-scan looks into a ZIP, TAR, TAR.GZ or gzip file without writing anything to
disk and says whether unpacking it is safe. It reports:
- an entry that would be written outside the folder, the trap known as zip slip
- a link, a device, or two names that would land on one file
- a name a system cannot write
- an entry built to explode when unpacked, the trap known as a zip bomb
- an entry that is damaged
Archives inside the archive, such as a ZIP in a ZIP or a DOCX in a TAR, are read the same way, in memory, up to 16 deep. A trap in one of them is a trap in the whole, because a program that unpacks everything unpacks those too.
tfg tool archive-scan upload.zip
tfg tool archive-scan backup.tar.gz --unpacked_limit 500mb
--unpacked_limit also reports an archive that unpacks to more than you allow. Safe
ends with code 0, and anything found ends with 7, so a pipeline can stop on it.
One file
Is this file the one it claims to be?
checksum works out the checksum of a file and, given one to compare with, says
whether they match. It takes md5, sha1, sha256, sha512 and crc32, sha256 unless you ask, and it
tells which one you were given from its length.
tfg tool checksum installer.msi
tfg tool checksum installer.msi --expected 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
A sum that does not match ends with code 7. It answers the same question as
Get-FileHash on Windows or sha256sum on Linux, with the comparison done
for you.
A whole folder
Did anything in this folder change?
checksum-write writes the checksum of every file in a folder into SHA256SUMS beside
them, the same bytes sha256sum writes, and never over one that is already there.
checksum-check later checks every file that SHA256SUMS lists.
tfg tool checksum-write ./fixtures
tfg tool checksum-check ./fixtures/SHA256SUMS
Files it does not list are not looked at, the same as sha256sum -c, and a path that
leaves the folder is refused rather than read. The sample files come
with a SHA256SUMS you can check this way.
Next
Where to go from here
- File upload test cases puts the archive check among the other cases of an upload.
- The documentation has every command and exit code.