diff --git a/.travis.yml b/.travis.yml index 54a7025..8410026 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,11 +41,11 @@ install: - sudo apt-get install rar # Prepare tests # Malware from theZoo - - git clone https://github.com/Rafiot/theZoo.git - - pushd theZoo/malwares/Binaries - - python unpackall.py - - popd - - mv theZoo/malwares/Binaries/out tests/uncategorized/ + # - git clone https://github.com/Rafiot/theZoo.git + # - pushd theZoo/malwares/Binaries + # - python unpackall.py + # - popd + # - mv theZoo/malwares/Binaries/out tests/uncategorized/the_zoo/ # Path traversal attacks - git clone https://github.com/jwilk/path-traversal-samples - pushd path-traversal-samples @@ -56,17 +56,21 @@ install: - make - popd - popd - - mv path-traversal-samples/zip/*.zip tests/uncategorized/ - - mv path-traversal-samples/rar/*.rar tests/uncategorized/ + - mv path-traversal-samples/zip/*.zip tests/uncategorized/path_traversal_zip + - mv path-traversal-samples/rar/*.rar tests/uncategorized/path_traversal_rar # Office docs - git clone https://github.com/eea/odfpy.git - - mv odfpy/tests/examples/* tests/uncategorized/ + - mv odfpy/tests/examples/* tests/uncategorized/odfpy - pushd tests/uncategorized/ + - mkdir olefile && pushd olefile - wget https://bitbucket.org/decalage/olefileio_pl/raw/3073963b640935134ed0da34906fea8e506460be/Tests/images/test-ole-file.doc + - popd + - mkdir fraunhofer && pushd fraunhofer - wget --no-check-certificate https://www.officedissector.com/corpus/fraunhoferlibrary.zip - unzip -o fraunhoferlibrary.zip - rm fraunhoferlibrary.zip - popd + - popd # - pushd tests/dangerous/ # - 7z x -p42 42.zip # - popd diff --git a/kittengroomer/helpers.py b/kittengroomer/helpers.py index 0f2cb1b..4ef8d6f 100644 --- a/kittengroomer/helpers.py +++ b/kittengroomer/helpers.py @@ -240,7 +240,8 @@ class FileBase(object): self.set_property('symlink_path', os.readlink(file_path)) else: try: - mt = magic.from_file(file_path, mime=True) + with open(file_path, 'rb') as file: + mt = magic.from_buffer(file, mime=True) # libmagic will always return something, even if it's just 'data' except UnicodeEncodeError as e: raise UnicodeEncodeError(e)