Skip to content

Commit 0f632ba

Browse files
committed
new: Enrich event/attribute endpoints
Related #1318
1 parent 911db91 commit 0f632ba

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pymisp/api.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,20 @@ def contact_event_reporter(self, event: MISPEvent | int | str | UUID, message: s
499499
response = self._prepare_request('POST', f'events/contact/{event_id}', data=to_post)
500500
return self._check_json_response(response)
501501

502+
def enrich_event(self, event: MISPEvent | int | str | UUID, enrich_with: str | list[str]) -> dict[str, Any]:
503+
"""Enrich an event with data from one or more module.
504+
505+
:param event: event to enrich
506+
:param enrich_with: module name or list of module names to use for enrichment
507+
"""
508+
event_id = get_uuid_or_id_from_abstract_misp(event)
509+
if isinstance(enrich_with, str):
510+
enrich_with = [enrich_with]
511+
512+
to_post = {module_name: True for module_name in enrich_with}
513+
response = self._prepare_request('POST', f'/events/enrichEvent/{event_id}', data=to_post)
514+
return self._check_json_response(response)
515+
502516
# ## END Event ###
503517

504518
# ## BEGIN Event Report ###
@@ -1102,6 +1116,20 @@ def restore_attribute(self, attribute: MISPAttribute | int | str | UUID, pythoni
11021116
a.from_dict(**response)
11031117
return a
11041118

1119+
def enrich_attribute(self, attribute: MISPAttribute | int | str | UUID, enrich_with: str | list[str]) -> dict[str, Any]:
1120+
"""Enrich an attribute with data from one or more module.
1121+
1122+
:param attribute: attribute to enrich
1123+
:param enrich_with: module name or list of module names to use for enrichment
1124+
"""
1125+
attribute_id = get_uuid_or_id_from_abstract_misp(attribute)
1126+
if isinstance(enrich_with, str):
1127+
enrich_with = [enrich_with]
1128+
1129+
to_post = {module_name: True for module_name in enrich_with}
1130+
response = self._prepare_request('POST', f'/attributes/enrich/{attribute_id}', data=to_post)
1131+
return self._check_json_response(response)
1132+
11051133
# ## END Attribute ###
11061134

11071135
# ## BEGIN Attribute Proposal ###

0 commit comments

Comments
 (0)