mirror of https://github.com/MISP/PyMISP
chg: allow to pass a json string to direct_call
parent
af56ab6bb8
commit
6bf904f6ce
|
@ -356,6 +356,26 @@
|
||||||
"misp.direct_call('attributes/add/2167', {'type': 'ip-dst', 'value': '8.8.8.8'})\n"
|
"misp.direct_call('attributes/add/2167', {'type': 'ip-dst', 'value': '8.8.8.8'})\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# The URL of the MISP instance to connect to\n",
|
||||||
|
"misp_url = 'http://127.0.0.1:8080/'\n",
|
||||||
|
"# Can be found in the MISP web interface under \n",
|
||||||
|
"# http://+MISP_URL+/users/view/me -> Authkey\n",
|
||||||
|
"misp_key = 'fk5BodCZw8owbscW8pQ4ykMASLeJ4NYhuAbshNjo'\n",
|
||||||
|
"# Should PyMISP verify the MISP certificate\n",
|
||||||
|
"misp_verifycert = False\n",
|
||||||
|
"\n",
|
||||||
|
"from pymisp import PyMISP\n",
|
||||||
|
"\n",
|
||||||
|
"misp = PyMISP(misp_url, misp_key, misp_verifycert)\n",
|
||||||
|
"misp.direct_call('attributes/add/2167', '{\"type\": \"ip-dst\", \"value\": \"8.8.8.9\"}')\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|
|
@ -402,9 +402,11 @@ class PyMISP(object):
|
||||||
return self._check_response(response)
|
return self._check_response(response)
|
||||||
|
|
||||||
def direct_call(self, url, data):
|
def direct_call(self, url, data):
|
||||||
'''Very lightweight call that posts a data blob (python dictionary) on the URL'''
|
'''Very lightweight call that posts a data blob (python dictionary or json string) on the URL'''
|
||||||
url = urljoin(self.root_url, url)
|
url = urljoin(self.root_url, url)
|
||||||
response = self._prepare_request('POST', url, json.dumps(data))
|
if isinstance(data, dict):
|
||||||
|
data = json.dumps(data)
|
||||||
|
response = self._prepare_request('POST', url, data)
|
||||||
return self._check_response(response)
|
return self._check_response(response)
|
||||||
|
|
||||||
# ##############################################
|
# ##############################################
|
||||||
|
|
Loading…
Reference in New Issue