mirror of https://github.com/MISP/PyMISP
fix: Opening the json blobs as bytes was buggy
parent
e2ddb48f18
commit
3b42497967
|
@ -995,8 +995,8 @@ class PyMISP(object):
|
||||||
"""Helper to prepare a search query"""
|
"""Helper to prepare a search query"""
|
||||||
if query.get('error') is not None:
|
if query.get('error') is not None:
|
||||||
return query
|
return query
|
||||||
if controller not in ['events', 'attributes']:
|
if controller not in ['events', 'attributes', 'objects']:
|
||||||
raise Exception('Invalid controller. Can only be {}'.format(', '.join(['events', 'attributes'])))
|
raise ValueError('Invalid controller. Can only be {}'.format(', '.join(['events', 'attributes', 'objects'])))
|
||||||
url = urljoin(self.root_url, '{}/{}'.format(controller, path.lstrip('/')))
|
url = urljoin(self.root_url, '{}/{}'.format(controller, path.lstrip('/')))
|
||||||
|
|
||||||
if ASYNC_OK and async_callback:
|
if ASYNC_OK and async_callback:
|
||||||
|
|
|
@ -435,7 +435,7 @@ class MISPEvent(AbstractMISP):
|
||||||
if hasattr(json_event, 'read'):
|
if hasattr(json_event, 'read'):
|
||||||
# python2 and python3 compatible to find if we have a file
|
# python2 and python3 compatible to find if we have a file
|
||||||
json_event = json_event.read()
|
json_event = json_event.read()
|
||||||
if isinstance(json_event, basestring):
|
if isinstance(json_event, (basestring, bytes)):
|
||||||
json_event = json.loads(json_event)
|
json_event = json.loads(json_event)
|
||||||
if json_event.get('response'):
|
if json_event.get('response'):
|
||||||
event = json_event.get('response')[0]
|
event = json_event.get('response')[0]
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"sharing_group_id": 0,
|
"sharing_group_id": 0,
|
||||||
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
||||||
"template_version": 12,
|
"template_version": 13,
|
||||||
"uuid": "a"
|
"uuid": "a"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"sharing_group_id": 0,
|
"sharing_group_id": 0,
|
||||||
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
||||||
"template_version": 12,
|
"template_version": 13,
|
||||||
"uuid": "a"
|
"uuid": "a"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"sharing_group_id": 0,
|
"sharing_group_id": 0,
|
||||||
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
|
||||||
"template_version": 12,
|
"template_version": 13,
|
||||||
"uuid": "b"
|
"uuid": "b"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue