fix event_add, add example

pull/1/head
Raphaël Vinot 2014-04-12 16:17:36 +02:00
parent 483f7839c0
commit b53dac7773
2 changed files with 29 additions and 3 deletions

View File

@ -9,7 +9,7 @@ import requests
class PyMISP(object): class PyMISP(object):
def __init__(self, url, key, out_type = 'json'): def __init__(self, url, key, out_type = 'json'):
self.url = url self.url = url + '/events'
self.key = key self.key = key
self.out_type = out_type self.out_type = out_type
self.rest = self.url + '/{}' self.rest = self.url + '/{}'
@ -25,7 +25,8 @@ class PyMISP(object):
out = self.out_type out = self.out_type
session = requests.Session() session = requests.Session()
session.headers.update({'Authorization': self.key, session.headers.update({'Authorization': self.key,
'Accept': 'application/' + out}) 'Accept': 'application/' + out,
'content-type': 'text/' + out})
return session return session
@ -38,7 +39,7 @@ class PyMISP(object):
Warning, there's a limit on the number of results Warning, there's a limit on the number of results
""" """
session = self.__prepare_session() session = self.__prepare_session()
return session.get(self.url, verify=False) return session.get(self.rest, verify=False)
def get_event(self, event_id): def get_event(self, event_id):
""" """

25
pymisp/export_import.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from api import *
key_source = 'ExrJUE1UehwOWFM5FQbfNGpHTXXzWGsAeTk9ym3M'
url_source = 'https://misp.circl.lu/events'
key_dest = 'vmDndechmTUHHqsm2fsAJmmr29mOPuIkQlH4ATlW'
url_dest = 'https://misppriv.circl.lu/events'
init_server(url_source, key_source)
r = get_event(709)
source_data = unicode(r.json())
#init_server(url_dest, key_dest)
print source_data
#r = add_event(source_data.encode('utf-8'))
#print r.text