fix: Disable pseudofile support in py2, skip tests.

pull/151/head
Raphaël Vinot 2017-12-09 13:35:44 +01:00
parent 52e079fea2
commit 7946e2ef83
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import six
from . import FileObject, PEObject, ELFObject, MachOObject
from ..exceptions import MISPObjectException
import logging
@ -53,6 +55,10 @@ def make_binary_objects(filepath=None, pseudofile=None, filename=None):
try:
if filepath:
lief_parsed = lief.parse(filepath=filepath)
else:
if six.PY2:
logger.critical('Pseudofile is not supported in python2. Just update.')
lief_parsed = None
else:
lief_parsed = lief.parse(raw=pseudofile.getvalue(), name=filename)
if isinstance(lief_parsed, lief.PE.Binary):
@ -79,7 +85,7 @@ def make_binary_objects(filepath=None, pseudofile=None, filename=None):
logger.warning('Type error: {}'.format(e))
except lief.exception as e:
logger.warning('Lief exception: {}'.format(e))
except FileTypeNotImplemented as e: # noqa
except FileTypeNotImplemented as e:
logger.warning(e)
if not HAS_LIEF:
logger.warning('Please install lief, documentation here: https://github.com/lief-project/LIEF')

View File

@ -5,6 +5,7 @@ import unittest
import requests_mock
import json
import os
import six
from io import BytesIO
import pymisp as pm
@ -243,6 +244,8 @@ class TestOffline(unittest.TestCase):
return json.dumps(to_return, cls=MISPEncode)
def test_objects_pseudofile(self, m):
if six.PY2:
return unittest.SkipTest()
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
try:
for path in paths: