Commit 1abbb32c authored by jvoisin's avatar jvoisin

Nested archives are not supported by the GUI

parent 5d8f4b5c
......@@ -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
......
......@@ -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
============
......
......@@ -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 '../'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment