mirror of https://github.com/MISP/PyMISP
Add support for freetext import in the API.
parent
b73435949f
commit
72a484ca32
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pymisp import PyMISP
|
||||
from keys import misp_url, misp_key
|
||||
import argparse
|
||||
|
||||
from io import open
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
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()
|
||||
|
||||
pymisp = PyMISP(misp_url, misp_key)
|
||||
|
||||
with open(args.input, 'r') as f:
|
||||
result = pymisp.freetext(args.event, f.read())
|
||||
print(result)
|
|
@ -0,0 +1,5 @@
|
|||
8.8.8.8
|
||||
|
||||
google.fr
|
||||
|
||||
https://gmail.com
|
|
@ -764,6 +764,22 @@ class PyMISP(object):
|
|||
session = self.__prepare_session()
|
||||
return self.__query(session, 'edit/{}'.format(attribute_uuid), query, controller='attributes')
|
||||
|
||||
# ##############################
|
||||
# ###### Attribute update ######
|
||||
# ##############################
|
||||
|
||||
def freetext(self, event_id, string, adhereToWarninglists=False, distribution=None):
|
||||
query = {"value": string}
|
||||
wl_params = [False, True, 'soft']
|
||||
if adhereToWarninglists not in wl_params:
|
||||
raise Exception('Invalid parameter, adhereToWarninglists Can only be {}'.format(', '.join(wl_params)))
|
||||
if adhereToWarninglists:
|
||||
query['adhereToWarninglists'] = adhereToWarninglists
|
||||
if distribution is not None:
|
||||
query['distribution'] = distribution
|
||||
session = self.__prepare_session()
|
||||
return self.__query(session, 'freeTextImport/{}'.format(event_id), query, controller='events')
|
||||
|
||||
# ##############################
|
||||
# ######## REST Search #########
|
||||
# ##############################
|
||||
|
@ -1478,13 +1494,13 @@ class PyMISP(object):
|
|||
# ###########################
|
||||
# ######## Feed #########
|
||||
# ###########################
|
||||
|
||||
|
||||
def fetch_feed(self, feed_id):
|
||||
session = self.__prepare_session()
|
||||
url = urljoin(self.root_url, 'feeds/fetchFromFeed/{}'.format(feed_id))
|
||||
response = session.get(url)
|
||||
return self._check_response(response)
|
||||
|
||||
|
||||
# ###########################
|
||||
# ####### Deprecated ########
|
||||
# ###########################
|
||||
|
|
Loading…
Reference in New Issue