mirror of https://github.com/MISP/PyMISP
fix: Disable pseudofile support in py2, skip tests.
parent
52e079fea2
commit
7946e2ef83
|
@ -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')
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue