Describe the bug
When the preload hook is triggered, the hook function of the module iris_check_module fails.
app_1 | 2022-04-12 10:25:43 :: CRITICAL :: module_handler :: call_modules_hook :: Failed to run hook on_preload_ioc_create with module iris_check_module. Error 0
To Reproduce
Steps to reproduce the behavior:
- Enable iris_check_module hooks
- Goto Case->Iocs
- Create an IOC
- See error
Expected behavior
Should not return any error or additional log message.
Additional context
The module expects a list of data in the hook function, but we send only the data as it is (a dictionary). We should either modify the call_modules_hook function is iris_engine/module_handler, to send a list of data just like the asynchronous hooks, or edit the iris_check_module to handle hooks differently when it's either asynchronous or not (preload is not asynchronous).
Example of (dirty) patch (./source/app/iris_engine/module_handler/module_handler.py):
else:
# Direct call. Should be fast
log.info(f'Calling module {module.module_name} for hook {hook_name}')
try:
mod_inst = instantiate_module_from_name(module_name=module.module_name)
status = mod_inst.hooks_handler(hook_name, module.manual_hook_ui_name, data=data)
except Exception as e:
log.critical(f"Failed to run hook {hook_name} with module {module.module_name}. Error {str(e)}")
continue
if status.is_success():
data = status.get_data()
else:
# Direct call. Should be fast
log.info(f'Calling module {module.module_name} for hook {hook_name}')
try:
mod_inst = instantiate_module_from_name(module_name=module.module_name)
data = [data]
status = mod_inst.hooks_handler(hook_name, module.manual_hook_ui_name, data=data)
except Exception as e:
log.critical(f"Failed to run hook {hook_name} with module {module.module_name}. Error {str(e)}")
continue
if status.is_success():
data = status.get_data()
data = data[0]
Describe the bug
When the preload hook is triggered, the hook function of the module iris_check_module fails.
app_1 | 2022-04-12 10:25:43 :: CRITICAL :: module_handler :: call_modules_hook :: Failed to run hook on_preload_ioc_create with module iris_check_module. Error 0To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should not return any error or additional log message.
Additional context
The module expects a list of data in the hook function, but we send only the data as it is (a dictionary). We should either modify the call_modules_hook function is iris_engine/module_handler, to send a list of data just like the asynchronous hooks, or edit the iris_check_module to handle hooks differently when it's either asynchronous or not (preload is not asynchronous).
Example of (dirty) patch (./source/app/iris_engine/module_handler/module_handler.py):