fix: Opening the json blobs as bytes was buggy

pull/202/merge
Raphaël Vinot 2018-08-08 10:18:51 +02:00
parent e2ddb48f18
commit 3b42497967
4 changed files with 6 additions and 6 deletions

View File

@ -995,8 +995,8 @@ class PyMISP(object):
"""Helper to prepare a search query"""
if query.get('error') is not None:
return query
if controller not in ['events', 'attributes']:
raise Exception('Invalid controller. Can only be {}'.format(', '.join(['events', 'attributes'])))
if controller not in ['events', 'attributes', 'objects']:
raise ValueError('Invalid controller. Can only be {}'.format(', '.join(['events', 'attributes', 'objects'])))
url = urljoin(self.root_url, '{}/{}'.format(controller, path.lstrip('/')))
if ASYNC_OK and async_callback:

View File

@ -435,7 +435,7 @@ class MISPEvent(AbstractMISP):
if hasattr(json_event, 'read'):
# python2 and python3 compatible to find if we have a file
json_event = json_event.read()
if isinstance(json_event, basestring):
if isinstance(json_event, (basestring, bytes)):
json_event = json.loads(json_event)
if json_event.get('response'):
event = json_event.get('response')[0]

View File

@ -31,7 +31,7 @@
"name": "file",
"sharing_group_id": 0,
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": 12,
"template_version": 13,
"uuid": "a"
},
{

View File

@ -23,7 +23,7 @@
"name": "file",
"sharing_group_id": 0,
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": 12,
"template_version": 13,
"uuid": "a"
},
{
@ -48,7 +48,7 @@
"name": "file",
"sharing_group_id": 0,
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": 12,
"template_version": 13,
"uuid": "b"
}
]