mirror of https://github.com/MISP/PyMISP
chg: Add more examples
parent
2f65995572
commit
e7684bedf4
|
@ -214,6 +214,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
"## Add the attribute to the event\n",
|
"## Add the attribute to the event\n",
|
||||||
"event.add_attribute(**attribute)\n",
|
"event.add_attribute(**attribute)\n",
|
||||||
|
"event.add_attribute(type='domain', value='circl.lu', disable_correlation=True)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"## Push the updated event to MISP\n",
|
"## Push the updated event to MISP\n",
|
||||||
"event_dict = misp.update(event)\n",
|
"event_dict = misp.update(event)\n",
|
||||||
|
@ -310,29 +311,21 @@
|
||||||
" 'subject': 'An email',\n",
|
" 'subject': 'An email',\n",
|
||||||
"}\n",
|
"}\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",
|
"# Create the MISP Object\n",
|
||||||
"misp_obj = MISPObject(object_name)\n",
|
"misp_obj = MISPObject(object_name)\n",
|
||||||
"for obj_relation, value in object_data.items():\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",
|
"\n",
|
||||||
"# Add the object to MISP\n",
|
"# Add the object to MISP\n",
|
||||||
"response = misp.add_object(event_id,\n",
|
"response = misp.add_object(event_id,\n",
|
||||||
" template_id,\n",
|
" template_id,\n",
|
||||||
" misp_obj)\n",
|
" misp_obj)\n",
|
||||||
|
"print('Event ID', event_id)\n",
|
||||||
"print(response)"
|
"print(response)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue