From 1abbb32ccb8747c8d30b8fcde6a0e2898816fc69 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 6 Jan 2014 12:10:10 +0000 Subject: Nested archives are not supported by the GUI --- MAT/archive.py | 13 +++++++++---- README.security | 5 +++++ test/libtest.py | 3 +-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MAT/archive.py b/MAT/archive.py index 5b8d9a8..8112f5d 100644 --- a/MAT/archive.py +++ b/MAT/archive.py @@ -167,7 +167,7 @@ class TarStripper(GenericArchiveStripper): current_file.gname = '' return current_file - def remove_all(self): + def remove_all(self, exclude_list=[]): tarin = tarfile.open(self.filename, 'r' + self.compression, encoding='utf-8') tarout = tarfile.open(self.output, 'w' + self.compression, encoding='utf-8') for item in tarin.getmembers(): @@ -208,6 +208,7 @@ class TarStripper(GenericArchiveStripper): ''' if list_unsupported: ret_list = [] + tmp_len = len(self.tempdir) + 1 # trim the tempfile path tarin = tarfile.open(self.filename, 'r' + self.compression) for item in tarin.getmembers(): if not self.is_file_clean(item) and not list_unsupported: @@ -217,14 +218,18 @@ class TarStripper(GenericArchiveStripper): if item.isfile(): class_file = mat.create_class_file(complete_name, False, add2archive=self.add2archive) if class_file: - if not class_file.is_clean() and not list_unsupported: - return False + if not class_file.is_clean(): + # We don't support nested archives + if list_unsupported: + if isinstance(class_file, GenericArchiveStripper): + ret_list.append(complete_name[tmp_len:]) + else: + return False else: logging.error('%s\'s format is not supported or harmless' % item.name) basename, ext = os.path.splitext(complete_name) if ext not in parser.NOMETA: if list_unsupported: - tmp_len = len(self.tempdir) + 1 # trim the tempfile path ret_list.append(complete_name[tmp_len:]) else: return False diff --git a/README.security b/README.security index 1e6fad0..73f638e 100644 --- a/README.security +++ b/README.security @@ -23,6 +23,11 @@ Test suite Formats that are not in the test suite are not well-tested, please do not trust the MAT about them! +Archives handling +----------------- +MAT's GUI does not handle (for now?) nested archives; +it will treat them like unsupported format. + Threat Model ============ diff --git a/test/libtest.py b/test/libtest.py index a9ef383..e0c2f57 100644 --- a/test/libtest.py +++ b/test/libtest.py @@ -132,8 +132,7 @@ class TestArchiveProcessing(test.MATTest): def test_get_unsupported(self): tarpath = os.path.join(self.tmpdir, "test.tar.bz2") tar = tarfile.open(tarpath, "w") - for clean,dirty in self.file_list[:4]: # we don't test thoses - tar.add(dirty) + for clean,_ in self.file_list[:4]: # we don't test thoses tar.add(clean) for f in ('../mat.desktop', '../README.security', '../setup.py'): tar.add(f, f[3:]) # trim '../' -- cgit v1.3