mirror of https://github.com/MISP/PyMISP
chg: Add full example
parent
7569972ac9
commit
6514e06e0a
|
@ -386,6 +386,50 @@
|
|||
"existing_event.attributes[0].add_tag('tlp:white')\n",
|
||||
"print(existing_event.attributes[0].to_json())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Full example"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pymisp import MISPEvent, MISPObject\n",
|
||||
"from pymisp import PyMISP\n",
|
||||
"\n",
|
||||
"event = MISPEvent()\n",
|
||||
"\n",
|
||||
"event.info = 'This is my new MISP event' # Required\n",
|
||||
"event.distribution = 0 # Optional, defaults to MISP.default_event_distribution in MISP config\n",
|
||||
"event.threat_level_id = 2 # Optional, defaults to MISP.default_event_threat_level in MISP config\n",
|
||||
"event.analysis = 1 # Optional, defaults to 0 (initial analysis)\n",
|
||||
"\n",
|
||||
"mispObject = MISPObject('file')\n",
|
||||
"mispObject.add_attribute('filename', type='filename',\n",
|
||||
" value='filename.exe',\n",
|
||||
" Tag=[{'name':'tlp:amber'}]) \n",
|
||||
"event.add_object(mispObject)\n",
|
||||
"\n",
|
||||
"# The URL of the MISP instance to connect to\n",
|
||||
"misp_url = 'https://<URL>/'\n",
|
||||
"# Can be found in the MISP web interface under \n",
|
||||
"# http://+MISP_URL+/users/view/me -> Authkey\n",
|
||||
"misp_key = '<key>'\n",
|
||||
"# Should PyMISP verify the MISP certificate\n",
|
||||
"misp_verifycert = True\n",
|
||||
"\n",
|
||||
"misp = PyMISP(misp_url, misp_key, misp_verifycert)\n",
|
||||
"res = misp.add_event(event)\n",
|
||||
"existing_event = MISPEvent()\n",
|
||||
"existing_event.load(res)\n",
|
||||
"print(existing_event.to_json())"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
Loading…
Reference in New Issue