diff options
| -rw-r--r-- | MAT/archive.py | 10 | ||||
| -rw-r--r-- | MAT/office.py | 5 | ||||
| -rwxr-xr-x | mat-gui | 10 |
3 files changed, 19 insertions, 6 deletions
diff --git a/MAT/archive.py b/MAT/archive.py index 3c6a139..62f4ca7 100644 --- a/MAT/archive.py +++ b/MAT/archive.py | |||
| @@ -39,7 +39,7 @@ class GenericArchiveStripper(parser.GenericParser): | |||
| 39 | mat.secure_remove(path_file) | 39 | mat.secure_remove(path_file) |
| 40 | shutil.rmtree(self.tempdir) | 40 | shutil.rmtree(self.tempdir) |
| 41 | 41 | ||
| 42 | def is_clean(self, list_unsupported): | 42 | def is_clean(self, list_unsupported=False): |
| 43 | ''' Virtual method to check for harmul metadata | 43 | ''' Virtual method to check for harmul metadata |
| 44 | ''' | 44 | ''' |
| 45 | raise NotImplementedError | 45 | raise NotImplementedError |
| @@ -312,6 +312,14 @@ class TarStripper(GenericArchiveStripper): | |||
| 312 | return metadata | 312 | return metadata |
| 313 | 313 | ||
| 314 | 314 | ||
| 315 | class TerminalZipStripper(ZipStripper): | ||
| 316 | ''' Represent a terminal level archive. | ||
| 317 | This type of archive can not contain nested archives. | ||
| 318 | It is used for formats like docx, which are basically | ||
| 319 | ziped xml. | ||
| 320 | ''' | ||
| 321 | |||
| 322 | |||
| 315 | class GzipStripper(TarStripper): | 323 | class GzipStripper(TarStripper): |
| 316 | ''' Represent a tar.gz archive | 324 | ''' Represent a tar.gz archive |
| 317 | ''' | 325 | ''' |
diff --git a/MAT/office.py b/MAT/office.py index 97405b3..e4b9567 100644 --- a/MAT/office.py +++ b/MAT/office.py | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | ''' Care about office's formats | 1 | ''' Care about office's formats |
| 2 | |||
| 2 | ''' | 3 | ''' |
| 3 | 4 | ||
| 4 | import logging | 5 | import logging |
| @@ -19,7 +20,7 @@ import parser | |||
| 19 | import archive | 20 | import archive |
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | class OpenDocumentStripper(archive.ZipStripper): | 23 | class OpenDocumentStripper(archive.TerminalZipStripper): |
| 23 | ''' An open document file is a zip, with xml file into. | 24 | ''' An open document file is a zip, with xml file into. |
| 24 | The one that interest us is meta.xml | 25 | The one that interest us is meta.xml |
| 25 | ''' | 26 | ''' |
| @@ -68,7 +69,7 @@ class OpenDocumentStripper(archive.ZipStripper): | |||
| 68 | return False | 69 | return False |
| 69 | 70 | ||
| 70 | 71 | ||
| 71 | class OpenXmlStripper(archive.ZipStripper): | 72 | class OpenXmlStripper(archive.TerminalZipStripper): |
| 72 | ''' Represent an office openxml document, which is like | 73 | ''' Represent an office openxml document, which is like |
| 73 | an opendocument format, with some tricky stuff added. | 74 | an opendocument format, with some tricky stuff added. |
| 74 | It contains mostly xml, but can have media blobs, crap, ... | 75 | It contains mostly xml, but can have media blobs, crap, ... |
| @@ -409,14 +409,18 @@ non-anonymised) file to output archive')) | |||
| 409 | msg = _('Cleaning %s') % self.liststore[line][1].decode('utf-8', 'replace') | 409 | msg = _('Cleaning %s') % self.liststore[line][1].decode('utf-8', 'replace') |
| 410 | logging.info(msg) | 410 | logging.info(msg) |
| 411 | self.statusbar.push(0, msg) | 411 | self.statusbar.push(0, msg) |
| 412 | if isinstance(self.liststore[line][0].file, archive.GenericArchiveStripper): | 412 | is_archive = isinstance(self.liststore[line][0].file, archive.GenericArchiveStripper) |
| 413 | list_to_add = [] | 413 | is_terminal = isinstance(self.liststore[line][0].file, archive.TerminalZipStripper) |
| 414 | list_to_add = [] | ||
| 415 | if is_archive and not is_terminal: | ||
| 414 | unsupported_list = self.liststore[line][0].file.list_unsupported() | 416 | unsupported_list = self.liststore[line][0].file.list_unsupported() |
| 415 | if type(unsupported_list) == list and unsupported_list: | 417 | if type(unsupported_list) == list and unsupported_list: |
| 416 | logging.debug("Unsupported list: %s" % unsupported_list) | 418 | logging.debug("Unsupported list: %s" % unsupported_list) |
| 417 | filename = os.path.basename(self.liststore[line][0].file.filename) | 419 | filename = os.path.basename(self.liststore[line][0].file.filename) |
| 418 | list_to_add = self.__popup_archive(filename, unsupported_list) | 420 | list_to_add = self.__popup_archive(filename, unsupported_list) |
| 419 | if self.liststore[line][0].file.remove_all(whitelist=list_to_add): | 421 | if self.liststore[line][0].file.remove_all(whitelist=list_to_add): |
| 422 | self.liststore[line][2] = _('Clean') | ||
| 423 | elif self.liststore[line][0].file.remove_all(): | ||
| 420 | self.liststore[line][2] = _('Clean') | 424 | self.liststore[line][2] = _('Clean') |
| 421 | yield True | 425 | yield True |
| 422 | self.statusbar.push(0, _('Ready')) | 426 | self.statusbar.push(0, _('Ready')) |
