From 4d2861780ee1a445f10dc581d783af8ff5731376 Mon Sep 17 00:00:00 2001 From: Student CIRCL Date: Mon, 3 Apr 2017 17:07:52 +0200 Subject: [PATCH 1/5] Treemap.py requirements updated in the README.MD file --- examples/situational-awareness/README.md | 5 +++++ 1 file changed, 5 insertions(+) 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) + From 75fa1de2e492d436fd7457288698e115f9b2472c Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Tue, 4 Apr 2017 10:07:29 +0100 Subject: [PATCH 2/5] fix: don't double-json-encode when sending proposals --- pymisp/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 51f49ddcaaa080ce4bff1fcb676beceed5dd456f Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 6 Apr 2017 14:20:00 +0200 Subject: [PATCH 3/5] Updated last.py to dump json results straight away Output was not usable with cli utilities such as: ```cat results.json | python -m simplejson.tool```. It's now usable and works perfectly. --- examples/last.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/last.py b/examples/last.py index 75f8162..4af048c 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.') From dd3ce6c758377671323a17551b9c9c7080de5fb7 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 6 Apr 2017 14:23:04 +0200 Subject: [PATCH 4/5] Update last.py --- examples/last.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/last.py b/examples/last.py index 4af048c..f7e5773 100755 --- a/examples/last.py +++ b/examples/last.py @@ -26,7 +26,7 @@ def download_last(m, last, out=None): exit(0) else: with open(out, 'w') as f: - f.write(json.dumps(result['response'])) + f.write(json.dumps(result['response'])) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Download latest events from a MISP instance.') From 3da2a54ea1e5f951c48f481a1857f619324c057c Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Fri, 7 Apr 2017 16:09:38 +0100 Subject: [PATCH 5/5] fix: Update script had `latest`'s docstrings --- examples/up.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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()