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
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from . import FileObject, PEObject, ELFObject, MachOObject
|
from . import FileObject, PEObject, ELFObject, MachOObject
|
||||||
from ..exceptions import MISPObjectException
|
from ..exceptions import MISPObjectException
|
||||||
import logging
|
import logging
|
||||||
|
@ -53,6 +55,10 @@ def make_binary_objects(filepath=None, pseudofile=None, filename=None):
|
||||||
try:
|
try:
|
||||||
if filepath:
|
if filepath:
|
||||||
lief_parsed = lief.parse(filepath=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:
|
else:
|
||||||
lief_parsed = lief.parse(raw=pseudofile.getvalue(), name=filename)
|
lief_parsed = lief.parse(raw=pseudofile.getvalue(), name=filename)
|
||||||
if isinstance(lief_parsed, lief.PE.Binary):
|
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))
|
logger.warning('Type error: {}'.format(e))
|
||||||
except lief.exception as e:
|
except lief.exception as e:
|
||||||
logger.warning('Lief exception: {}'.format(e))
|
logger.warning('Lief exception: {}'.format(e))
|
||||||
except FileTypeNotImplemented as e: # noqa
|
except FileTypeNotImplemented as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
if not HAS_LIEF:
|
if not HAS_LIEF:
|
||||||
logger.warning('Please install lief, documentation here: https://github.com/lief-project/LIEF')
|
logger.warning('Please install lief, documentation here: https://github.com/lief-project/LIEF')
|
||||||
|
|
|
@ -5,6 +5,7 @@ import unittest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import six
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import pymisp as pm
|
import pymisp as pm
|
||||||
|
@ -243,6 +244,8 @@ class TestOffline(unittest.TestCase):
|
||||||
return json.dumps(to_return, cls=MISPEncode)
|
return json.dumps(to_return, cls=MISPEncode)
|
||||||
|
|
||||||
def test_objects_pseudofile(self, m):
|
def test_objects_pseudofile(self, m):
|
||||||
|
if six.PY2:
|
||||||
|
return unittest.SkipTest()
|
||||||
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
|
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
|
||||||
try:
|
try:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
|
|
Loading…
Reference in New Issue