From d7194c2dae5fa7555be97d866d82641ed970231d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Thu, 30 Oct 2025 17:06:11 +0100 Subject: [PATCH] fix: moved xz unpacking from patool to 7z to fix wrong MIME detection bug --- .../plugins/unpacking/patool/code/patool.py | 3 +-- .../unpacking/patool/test/data/test.tar.xz | Bin 352 -> 0 bytes .../unpacking/patool/test/test_plugin_patool.py | 2 -- .../plugins/unpacking/sevenz/code/sevenz.py | 3 ++- .../{patool => sevenz}/test/data/test.xz | Bin .../unpacking/sevenz/test/test_plugin_sevenz.py | 14 ++++++++++---- 6 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 fact_extractor/plugins/unpacking/patool/test/data/test.tar.xz rename fact_extractor/plugins/unpacking/{patool => sevenz}/test/data/test.xz (100%) diff --git a/fact_extractor/plugins/unpacking/patool/code/patool.py b/fact_extractor/plugins/unpacking/patool/code/patool.py index 0715be79..57c60c8c 100644 --- a/fact_extractor/plugins/unpacking/patool/code/patool.py +++ b/fact_extractor/plugins/unpacking/patool/code/patool.py @@ -33,13 +33,12 @@ 'application/x-rzip', 'application/x-shar', 'application/x-tar', - 'application/x-xz', 'application/x-zoo', 'application/zpaq', 'application/zstd', 'audio/flac', ] -VERSION = '0.7.0' +VERSION = '0.8.0' TOOL_PATH = execute_shell_command('which patool').strip() diff --git a/fact_extractor/plugins/unpacking/patool/test/data/test.tar.xz b/fact_extractor/plugins/unpacking/patool/test/data/test.tar.xz deleted file mode 100644 index 1c9b049a7f9212927a008cbd09d3e07bd4451c57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 352 zcmV-m0iXW;H+ooF000E$*0e?f03iVu0001VFXf})C;tH+T>vwgO73vav_s~(q)W{v zf9$`-7t$cgNtB2Ki#6B6N-ic#Hc9m-Z!*p2nrFmpj8CBPoyF!Y8~zuP*z*BM`NX?X z;)d@(dihEP@Zx&9yg+RVlih4Q_o5a)VmKY2ZWWg-r=6dwS}wPvoAiWtN^E$lzHS0a z#v-wl)WjvHr=LX-Kqyd})zG;@n#dFEdN$E6S!bdC^}^s!5Dg0Mo>~ZCh+vG5UtS!Q z^xtFf8}`&Pw?y`;C@9^Qh_}MY4Yf91^#XuEmEbIkj^h4%A^C`X>r``$)`oGIu2vQ{ zk(AMso2LOdkFq_^0zADAjJvgC;~7eg%*-&LorV&PLE~YvE9-kd!TzuI8408FZD6Sa yvIr>UpdUepl2=4P0002|UbV6eoy4vH0lET!PyhfWFCl}m#Ao{g000001X)^=ucmSU diff --git a/fact_extractor/plugins/unpacking/patool/test/test_plugin_patool.py b/fact_extractor/plugins/unpacking/patool/test/test_plugin_patool.py index ae92ba80..73d77e26 100644 --- a/fact_extractor/plugins/unpacking/patool/test/test_plugin_patool.py +++ b/fact_extractor/plugins/unpacking/patool/test/test_plugin_patool.py @@ -26,7 +26,6 @@ def test_unpacker_selection_generic(self): ('test.tar.bz2', None), ('test.tar', None), ('test.tar.lz', None), - ('test.tar.xz', None), ('test.zoo', None), ('test.zpaq', None), ], @@ -49,7 +48,6 @@ def test_archive_extraction(self, in_file, ignore): 'test.lz4', 'test.lzo', 'test.rz', - 'test.xz', 'test.zst', ], ) diff --git a/fact_extractor/plugins/unpacking/sevenz/code/sevenz.py b/fact_extractor/plugins/unpacking/sevenz/code/sevenz.py index acd10ce0..788bce1e 100644 --- a/fact_extractor/plugins/unpacking/sevenz/code/sevenz.py +++ b/fact_extractor/plugins/unpacking/sevenz/code/sevenz.py @@ -32,6 +32,7 @@ 'application/x-vhd', 'application/x-vhdx', 'application/x-xar', + 'application/x-xz', 'application/x-zip-compressed', 'application/zip', # file systems @@ -43,7 +44,7 @@ 'filesystem/hfs', 'filesystem/ntfs', ] -VERSION = '0.11.0' +VERSION = '0.12.0' UNPACKER_EXECUTABLE = '7zzs' ZISOFS_MAGIC = bytes.fromhex('37 E4 53 96 C9 DB D6 07') diff --git a/fact_extractor/plugins/unpacking/patool/test/data/test.xz b/fact_extractor/plugins/unpacking/sevenz/test/data/test.xz similarity index 100% rename from fact_extractor/plugins/unpacking/patool/test/data/test.xz rename to fact_extractor/plugins/unpacking/sevenz/test/data/test.xz diff --git a/fact_extractor/plugins/unpacking/sevenz/test/test_plugin_sevenz.py b/fact_extractor/plugins/unpacking/sevenz/test/test_plugin_sevenz.py index bda0b217..37f97908 100644 --- a/fact_extractor/plugins/unpacking/sevenz/test/test_plugin_sevenz.py +++ b/fact_extractor/plugins/unpacking/sevenz/test/test_plugin_sevenz.py @@ -56,13 +56,19 @@ def test_extraction_password(self, test_file): ) assert meta['password'] == 'test', 'password info not set' - def test_gzip_extraction(self): - input_file = TEST_DATA_DIR / 'test.gz' + @pytest.mark.parametrize( + ('test_file', 'stream_type'), + [ + ('test.gz', 'gzip'), + ('test.xz', 'xz'), + ], + ) + def test_stream_extraction(self, test_file, stream_type): + input_file = TEST_DATA_DIR / test_file files, meta_data = self.unpacker.extract_files_from_file(str(input_file), self.tmp_dir.name) assert meta_data['plugin_used'] == '7z' assert len(files) == 1 - assert Path(files[0]).name == 'test.data' - assert 'Type = gzip' in meta_data['output'] + assert f'Type = {stream_type}' in meta_data['output'] assert 'Everything is Ok' in meta_data['output'] @pytest.mark.parametrize('file_format', ['zip', 'lzma'])