mirror of https://github.com/MISP/PyMISP
Merge branch 'master' of github.com:MISP/PyMISP
commit
a07552bb04
|
@ -20,10 +20,17 @@ if __name__ == '__main__':
|
|||
args = parser.parse_args()
|
||||
|
||||
pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
|
||||
template = pymisp.get_object_templates_list()
|
||||
if 'response' in template.keys():
|
||||
template = template['response']
|
||||
try:
|
||||
template_id = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list() if x['ObjectTemplate']['name'] == args.type][0]
|
||||
template_ids = [x['ObjectTemplate']['id'] for x in template if x['ObjectTemplate']['name'] == args.type]
|
||||
if len(template_ids) > 0:
|
||||
template_id = template_ids[0]
|
||||
else:
|
||||
raise IndexError
|
||||
except IndexError:
|
||||
valid_types = ", ".join([x['ObjectTemplate']['name'] for x in pymisp.get_object_templates_list()])
|
||||
valid_types = ", ".join([x['ObjectTemplate']['name'] for x in template])
|
||||
print ("Template for type %s not found! Valid types are: %s" % (args.type, valid_types))
|
||||
exit()
|
||||
|
||||
|
|
|
@ -336,6 +336,24 @@ class PyMISP(object):
|
|||
response = self._prepare_request('GET', url)
|
||||
return self._check_response(response)
|
||||
|
||||
def get_object(self, obj_id):
|
||||
"""Get an object
|
||||
|
||||
:param obj_id: Object id to get
|
||||
"""
|
||||
url = urljoin(self.root_url, 'objects/view/{}'.format(obj_id))
|
||||
response = self._prepare_request('GET', url)
|
||||
return self._check_response(response)
|
||||
|
||||
def get_attribute(self, att_id):
|
||||
"""Get an attribute
|
||||
|
||||
:param att_id: Attribute id to get
|
||||
"""
|
||||
url = urljoin(self.root_url, 'attributes/view/{}'.format(att_id))
|
||||
response = self._prepare_request('GET', url)
|
||||
return self._check_response(response)
|
||||
|
||||
def add_event(self, event):
|
||||
"""Add a new event
|
||||
|
||||
|
|
Loading…
Reference in New Issue