mirror of https://github.com/MISP/PyMISP
set_sightings
Maybe I didn't use it correctly but the method set_sightings didn't work for me. It's working now but I'm not sure whether sending a request for every sighting in the list is the best solution.pull/162/head
parent
0ff2120511
commit
72597c1b8a
|
@ -1295,17 +1295,16 @@ class PyMISP(object):
|
|||
return self._check_response(response)
|
||||
|
||||
def set_sightings(self, sightings):
|
||||
"""Push a sighting (python dictionary)"""
|
||||
to_post = []
|
||||
"""Push a sighting (python dictionary or MISPSighting) or a list of sightings"""
|
||||
if not isinstance(sightings, list):
|
||||
sightings = [sightings]
|
||||
for sighting in sightings:
|
||||
if isinstance(sighting, MISPSighting):
|
||||
to_post.append(sighting.to_json())
|
||||
to_post = sighting.to_json()
|
||||
elif isinstance(sighting, dict):
|
||||
to_post.append(json.dumps(sightings))
|
||||
to_post = json.dumps(sighting)
|
||||
url = urljoin(self.root_url, 'sightings/add/')
|
||||
response = self.__prepare_request('POST', url, json.dumps(to_post))
|
||||
response = self.__prepare_request('POST', url, to_post)
|
||||
return self._check_response(response)
|
||||
|
||||
def sighting_per_json(self, json_file):
|
||||
|
|
Loading…
Reference in New Issue