onekey-sec / unblob

Extract files from any kind of container formats
https://unblob.org
Other
2.15k stars 80 forks source link

fix(extractor): improve post-extraction permission fixing. #646

Closed qkaiser closed 1 year ago

qkaiser commented 1 year ago

Previously, the fix_permission function was arbitrarily setting the permission 0o644 (rw-r--r--) to files and 0o755 (rwxr-xr-x) to directories. This was done to allow unblob to recurse into directories and read files within them in order to continue the extraction.

However, this pose a problem since unblob users may want to keep the original permissions, such as the executable flag.

We're now applying permission masks to the original permission so that we make sure unblob can work while keeping the permission attributes unblob users want to keep.

We also expanded coverage of fix_permission by covering all possible permissions permutations for files and directories.

Related to #645