summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2014-01-06 12:10:10 +0000
committerjvoisin2014-01-06 12:10:10 +0000
commit1abbb32ccb8747c8d30b8fcde6a0e2898816fc69 (patch)
treebb65a908b0dffcc5077784501db7a47f6f3d9a6b
parent5d8f4b5c82f13e533248d88faefdd1cadebb1eb6 (diff)
Nested archives are not supported by the GUI
-rw-r--r--MAT/archive.py13
-rw-r--r--README.security5
-rw-r--r--test/libtest.py3
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):
167 current_file.gname = '' 167 current_file.gname = ''
168 return current_file 168 return current_file
169 169
170 def remove_all(self): 170 def remove_all(self, exclude_list=[]):
171 tarin = tarfile.open(self.filename, 'r' + self.compression, encoding='utf-8') 171 tarin = tarfile.open(self.filename, 'r' + self.compression, encoding='utf-8')
172 tarout = tarfile.open(self.output, 'w' + self.compression, encoding='utf-8') 172 tarout = tarfile.open(self.output, 'w' + self.compression, encoding='utf-8')
173 for item in tarin.getmembers(): 173 for item in tarin.getmembers():
@@ -208,6 +208,7 @@ class TarStripper(GenericArchiveStripper):
208 ''' 208 '''
209 if list_unsupported: 209 if list_unsupported:
210 ret_list = [] 210 ret_list = []
211 tmp_len = len(self.tempdir) + 1 # trim the tempfile path
211 tarin = tarfile.open(self.filename, 'r' + self.compression) 212 tarin = tarfile.open(self.filename, 'r' + self.compression)
212 for item in tarin.getmembers(): 213 for item in tarin.getmembers():
213 if not self.is_file_clean(item) and not list_unsupported: 214 if not self.is_file_clean(item) and not list_unsupported:
@@ -217,14 +218,18 @@ class TarStripper(GenericArchiveStripper):
217 if item.isfile(): 218 if item.isfile():
218 class_file = mat.create_class_file(complete_name, False, add2archive=self.add2archive) 219 class_file = mat.create_class_file(complete_name, False, add2archive=self.add2archive)
219 if class_file: 220 if class_file:
220 if not class_file.is_clean() and not list_unsupported: 221 if not class_file.is_clean():
221 return False 222 # We don't support nested archives
223 if list_unsupported:
224 if isinstance(class_file, GenericArchiveStripper):
225 ret_list.append(complete_name[tmp_len:])
226 else:
227 return False
222 else: 228 else:
223 logging.error('%s\'s format is not supported or harmless' % item.name) 229 logging.error('%s\'s format is not supported or harmless' % item.name)
224 basename, ext = os.path.splitext(complete_name) 230 basename, ext = os.path.splitext(complete_name)
225 if ext not in parser.NOMETA: 231 if ext not in parser.NOMETA:
226 if list_unsupported: 232 if list_unsupported:
227 tmp_len = len(self.tempdir) + 1 # trim the tempfile path
228 ret_list.append(complete_name[tmp_len:]) 233 ret_list.append(complete_name[tmp_len:])
229 else: 234 else:
230 return False 235 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
23Formats that are not in the test suite are not well-tested, 23Formats that are not in the test suite are not well-tested,
24please do not trust the MAT about them! 24please do not trust the MAT about them!
25 25
26Archives handling
27-----------------
28MAT's GUI does not handle (for now?) nested archives;
29it will treat them like unsupported format.
30
26 31
27Threat Model 32Threat Model
28============ 33============
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):
132 def test_get_unsupported(self): 132 def test_get_unsupported(self):
133 tarpath = os.path.join(self.tmpdir, "test.tar.bz2") 133 tarpath = os.path.join(self.tmpdir, "test.tar.bz2")
134 tar = tarfile.open(tarpath, "w") 134 tar = tarfile.open(tarpath, "w")
135 for clean,dirty in self.file_list[:4]: # we don't test thoses 135 for clean,_ in self.file_list[:4]: # we don't test thoses
136 tar.add(dirty)
137 tar.add(clean) 136 tar.add(clean)
138 for f in ('../mat.desktop', '../README.security', '../setup.py'): 137 for f in ('../mat.desktop', '../README.security', '../setup.py'):
139 tar.add(f, f[3:]) # trim '../' 138 tar.add(f, f[3:]) # trim '../'