diff --git a/examples/last.py b/examples/last.py index 75f8162..f7e5773 100755 --- a/examples/last.py +++ b/examples/last.py @@ -26,9 +26,7 @@ def download_last(m, last, out=None): exit(0) else: with open(out, 'w') as f: - for e in result['response']: - f.write(json.dumps(e) + '\n') - + f.write(json.dumps(result['response'])) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Download latest events from a MISP instance.') diff --git a/examples/situational-awareness/README.md b/examples/situational-awareness/README.md index d481f76..fb896c6 100644 --- a/examples/situational-awareness/README.md +++ b/examples/situational-awareness/README.md @@ -31,3 +31,8 @@ * [Pygal](https://github.com/Kozea/pygal/) * [Matplotlib](https://github.com/matplotlib/matplotlib) +* [Pandas](https://github.com/pandas-dev/pandas) +* [SciPy](https://github.com/scipy/scipy) +* [PyTaxonomies](https://github.com/MISP/PyTaxonomies) +* [Python3-tk](https://github.com/python-git/python/blob/master/Lib/lib-tk/Tkinter.py) + diff --git a/examples/up.py b/examples/up.py index 4b3c429..b13bd65 100755 --- a/examples/up.py +++ b/examples/up.py @@ -7,21 +7,17 @@ import argparse from io import open -# Usage for pipe masters: ./last.py -l 5h | jq . - - def init(url, key): return PyMISP(url, key, True, 'json', debug=True) - def up_event(m, event, content): with open(content, 'r') as f: result = m.update_event(event, f.read()) print(result) if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Get an event from a MISP instance.') - parser.add_argument("-e", "--event", required=True, help="Event ID to get.") + parser = argparse.ArgumentParser(description="Update a MISP event.") + parser.add_argument("-e", "--event", required=True, help="Event ID to update.") parser.add_argument("-i", "--input", required=True, help="Input file") args = parser.parse_args() diff --git a/pymisp/api.py b/pymisp/api.py index ab611be..3f2c723 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -413,7 +413,7 @@ class PyMISP(object): raise PyMISPError("Unable to find the ID of the event to update") for a in attributes: if proposal: - response = self.proposal_add(eventID_to_update, json.dumps(a, cls=EncodeUpdate)) + response = self.proposal_add(eventID_to_update, a) else: session = self.__prepare_session() url = urljoin(self.root_url, 'attributes/add/{}'.format(eventID_to_update)) @@ -710,7 +710,7 @@ class PyMISP(object): url = urljoin(self.root_url, 'shadow_attributes/{}/{}'.format(path, id)) if path in ['add', 'edit']: query = {'request': {'ShadowAttribute': attribute}} - response = session.post(url, data=json.dumps(query)) + response = session.post(url, data=json.dumps(query, cls=EncodeUpdate)) elif path == 'view': response = session.get(url) else: # accept or discard