Merge branch 'master' of github.com:MISP/PyMISP

pull/77/head
Raphaël Vinot 2017-04-07 17:31:27 +02:00
commit 1dda8eb40a
4 changed files with 10 additions and 11 deletions

View File

@ -26,9 +26,7 @@ def download_last(m, last, out=None):
exit(0) exit(0)
else: else:
with open(out, 'w') as f: with open(out, 'w') as f:
for e in result['response']: f.write(json.dumps(result['response']))
f.write(json.dumps(e) + '\n')
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Download latest events from a MISP instance.') parser = argparse.ArgumentParser(description='Download latest events from a MISP instance.')

View File

@ -31,3 +31,8 @@
* [Pygal](https://github.com/Kozea/pygal/) * [Pygal](https://github.com/Kozea/pygal/)
* [Matplotlib](https://github.com/matplotlib/matplotlib) * [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)

View File

@ -7,21 +7,17 @@ import argparse
from io import open from io import open
# Usage for pipe masters: ./last.py -l 5h | jq .
def init(url, key): def init(url, key):
return PyMISP(url, key, True, 'json', debug=True) return PyMISP(url, key, True, 'json', debug=True)
def up_event(m, event, content): def up_event(m, event, content):
with open(content, 'r') as f: with open(content, 'r') as f:
result = m.update_event(event, f.read()) result = m.update_event(event, f.read())
print(result) print(result)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Get an event from a MISP instance.') parser = argparse.ArgumentParser(description="Update a MISP event.")
parser.add_argument("-e", "--event", required=True, help="Event ID to get.") parser.add_argument("-e", "--event", required=True, help="Event ID to update.")
parser.add_argument("-i", "--input", required=True, help="Input file") parser.add_argument("-i", "--input", required=True, help="Input file")
args = parser.parse_args() args = parser.parse_args()

View File

@ -413,7 +413,7 @@ class PyMISP(object):
raise PyMISPError("Unable to find the ID of the event to update") raise PyMISPError("Unable to find the ID of the event to update")
for a in attributes: for a in attributes:
if proposal: if proposal:
response = self.proposal_add(eventID_to_update, json.dumps(a, cls=EncodeUpdate)) response = self.proposal_add(eventID_to_update, a)
else: else:
session = self.__prepare_session() session = self.__prepare_session()
url = urljoin(self.root_url, 'attributes/add/{}'.format(eventID_to_update)) 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)) url = urljoin(self.root_url, 'shadow_attributes/{}/{}'.format(path, id))
if path in ['add', 'edit']: if path in ['add', 'edit']:
query = {'request': {'ShadowAttribute': attribute}} 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': elif path == 'view':
response = session.get(url) response = session.get(url)
else: # accept or discard else: # accept or discard