-
Notifications
You must be signed in to change notification settings - Fork 92
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Example, when using tar, there is a limit for what normal gnu tar can unpack when filenames are getting too long. There are probable other utilities that are able to unpack this just fine and therefor, files can hide from unblob by having a long filename.
To Reproduce
Steps to reproduce the behavior:
- Start unblob container:
docker run -it --rm --entrypoint=/bin/bash ghcr.io/onekey-sec/unblob:latest - Generate a long filename:
filename=$(python -c "print('X' * 300)") - Create a dummy-file:
touch a_file - Make a tar-ball, but use --transform so you won't hit limit on filesystem:
tar -cf test.tar --transform "s/a_file/${filename}/" a_file - Run unblob on the file:
unblob test.tar - See error below
unblob@a8584cb412bd:/data/output$ unblob test.tar
2023-04-24 09:11.32 [info ] Start processing file file=test.tar pid=99
2023-04-24 09:11.32 [error ] Unknown error happened while extracting chunk pid=111
Traceback (most recent call last):
File "/home/unblob/.local/lib/python3.8/site-packages/unblob/processing.py", line 379, in _extract_chunk
chunk.extract(inpath, extract_dir)
File "/home/unblob/.local/lib/python3.8/site-packages/unblob/models.py", line 95, in extract
self.handler.extract(inpath, outdir)
File "/home/unblob/.local/lib/python3.8/site-packages/unblob/models.py", line 293, in extract
self.EXTRACTOR.extract(inpath, outdir)
File "/home/unblob/.local/lib/python3.8/site-packages/unblob/handlers/archive/tar.py", line 89, in extract
tf.extractall(outdir.as_posix())
File "/usr/local/lib/python3.8/tarfile.py", line 2028, in extractall
self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),
File "/home/unblob/.local/lib/python3.8/site-packages/unblob/handlers/archive/_safe_tarfile.py", line 29, in extract
super().extract(member, path, set_attrs, numeric_owner=numeric_owner)
File "/usr/local/lib/python3.8/tarfile.py", line 2069, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
File "/usr/local/lib/python3.8/tarfile.py", line 2141, in _extract_member
self.makefile(tarinfo, targetpath)
File "/usr/local/lib/python3.8/tarfile.py", line 2182, in makefile
with bltn_open(targetpath, "wb") as target:
OSError: [Errno 36] File name too long: '/data/output/test.tar_extract/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Expected behavior
unblob being unblob, it should find a way to unpack it. Maybe use some tar functionality to replace long filenames with a sha256 of the filename?
Environment information (please complete the following information):
- OS: linux
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working