dtrx-py / dtrx

Do The Right Extraction
GNU General Public License v3.0
224 stars 10 forks source link

Fix file extension false match #15

Closed noahp closed 2 years ago

noahp commented 2 years ago

See #13 for details.

The extension matcher will match a file named exactly like an extension, eg cpio, and extraction will be attempted. Normally the extraction will fail, but running cpio to extract certain cpio binaries (for example the busybox version installed in Alpine linux Docker images) can hang indefinitely.

This patch applies the patch supplied by @erhan- in this comment, and adds a test fixture that fails prior to the fix (hangs indefinitely) and passes after.

The test fixture was generated by:

docker pull alpine:3.13.6
docker image save alpine:3.13.6 -o alpine.tar.gz
dtrx -rn alpine.tar.gz  # this will hang without this patch; ctrl-c
cp alpine/f7055e235a8665ac2ae79f29bd773c7a40b409e9c5d71905fb6bcb6458d9b66a/layer/usr/bin/cpio ./
tar -czvf tests/test-cpio.tar.gz cpio

In the test harness (tests/compare.py) add a timeout when issuing the dtrx command, to catch this failure without stalling until CI timeout.

Fixes #13