Unpack all archives, debug invalid mimetype

pull/2/head
Raphaël Vinot 2015-11-03 17:56:42 +01:00
parent c984c536f1
commit 2669e80ca9
3 changed files with 10 additions and 6 deletions

View File

@ -37,9 +37,11 @@ install:
- wget https://didierstevens.com/files/software/pdfid_v0_2_1.zip
- unzip pdfid_v0_2_1.zip
- python setup.py -q install
- pushd tests/src
- git clone https://github.com/ytisf/theZoo.git
- git clone https://github.com/Rafiot/theZoo.git
- pushd theZoo/malwares/Binaries
- python unpackall.py
- popd
- mv theZoo/malwares/Binaries/out tests/src/
script:
- coverage run setup.py test

0
__init__.py Normal file
View File

View File

@ -52,14 +52,16 @@ class File(FileBase):
super(File, self).__init__(src_path, dst_path)
mimetype = magic.from_file(src_path, mime=True).decode("utf-8")
self.main_type, self.sub_type = mimetype.split('/')
try:
self.main_type, self.sub_type = mimetype.split('/')
except Exception as e:
# FIXME/TEMP: checking what happen, probably bad.
print(e, src_path, mimetype)
return
a, self.extension = os.path.splitext(src_path)
self.is_recursive = False
self.log_details.update({'maintype': self.main_type, 'subtype': self.sub_type, 'extension': self.extension})
# If the mimetype matches as text/*, it will be sent to LibreOffice, no need to cross check the mime/ext
if self.main_type == 'text':
return
# Check correlation known extension => actual mime type
if propertype.get(self.extension) is not None: