chg: Add more examples

pull/232/head
Raphaël Vinot 2018-04-24 09:45:36 +02:00
parent 2f65995572
commit e7684bedf4
1 changed files with 8 additions and 15 deletions

View File

@ -214,6 +214,7 @@
"\n",
"## Add the attribute to the event\n",
"event.add_attribute(**attribute)\n",
"event.add_attribute(type='domain', value='circl.lu', disable_correlation=True)\n",
"\n",
"## Push the updated event to MISP\n",
"event_dict = misp.update(event)\n",
@ -310,29 +311,21 @@
" 'subject': 'An email',\n",
"}\n",
"\n",
"# Retreive the template ID from the object's name\n",
"## Fetch all templates\n",
"templates = misp.get_object_templates_list()\n",
"## Get the template matching with the object's name\n",
"template_id = None\n",
"for template in templates:\n",
" cur_name = template['ObjectTemplate']['name']\n",
" cur_id = template['ObjectTemplate']['id']\n",
" if cur_name == object_name:\n",
" template_id = cur_id\n",
" break \n",
"if template_id is None:\n",
" raise Exception('No matching template')\n",
"\n",
"# Create the MISP Object\n",
"misp_obj = MISPObject(object_name)\n",
"for obj_relation, value in object_data.items():\n",
" misp_obj.add_attribute(obj_relation, **{'value': value})\n",
" if obj_relation == 'subject':\n",
" misp_obj.add_attribute(obj_relation, value=value, comment='My fancy subject', disable_correlation=True)\n",
" else: \n",
" misp_obj.add_attribute(obj_relation, value=value)\n",
"\n",
"template_id = misp.get_object_template_id(misp_obj.template_uuid)\n",
"\n",
"# Add the object to MISP\n",
"response = misp.add_object(event_id,\n",
" template_id,\n",
" misp_obj)\n",
"print('Event ID', event_id)\n",
"print(response)"
]
}