mirror of https://github.com/MISP/MISP
chg: [workflow] Added support of misp_core_format in triggers and modules
Allow trigger to specify if their passed data is compliant with the MISP core format from the RFC. As for module, they can specify if they expect data under the MISP core format to be working properly.pull/8530/head
parent
4211cdd15d
commit
2011bf3670
|
@ -596,6 +596,12 @@ class Workflow extends AppModel
|
|||
|
||||
public function attachNotificationToModules(array $modules, array $workflow): array
|
||||
{
|
||||
$trigger_is_misp_core_format = false;
|
||||
$triggers_id = $this->workflowGraphTool->extractTriggersFromWorkflow($workflow['Workflow']['data'], false);
|
||||
if (!empty($triggers_id)) {
|
||||
$triggerClass = $this->loaded_classes['trigger'][$triggers_id[0]];
|
||||
$trigger_is_misp_core_format = !empty($triggerClass->misp_core_format);
|
||||
}
|
||||
foreach ($modules as $moduleType => $modulesByType) {
|
||||
foreach ($modulesByType as $i => $module) {
|
||||
$modules[$moduleType][$i]['notifications'] = !empty($module['notifications']) ? $module['notifications'] : [
|
||||
|
@ -614,6 +620,19 @@ class Workflow extends AppModel
|
|||
'__show_in_node' => true,
|
||||
];
|
||||
}
|
||||
if ($moduleType != 'blocks_trigger') {
|
||||
if (!$trigger_is_misp_core_format && !empty($module['expect_misp_core_format'])) {
|
||||
$modules[$moduleType][$i]['notifications']['warning'][] = [
|
||||
'text' => __('Potential data format issue'),
|
||||
'description' => __('This module might not work properly as it expect data compliant with the MISP core format.'),
|
||||
'details' => [
|
||||
__('This module expect data to be compliant with the MISP core format, however the data passed by the trigger might not be under this format.')
|
||||
],
|
||||
'__show_in_sidebar' => true,
|
||||
'__show_in_node' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $modules;
|
||||
|
|
|
@ -40,6 +40,9 @@ class Module_misp_module extends WorkflowBaseActionModule
|
|||
if (!empty($misp_module_config['mispattributes']['blocking'])) {
|
||||
$this->blocking = !empty($misp_module_config['mispattributes']['blocking']);
|
||||
}
|
||||
if (!empty($misp_module_config['mispattributes']['expect_misp_core_format'])) {
|
||||
$this->expect_misp_core_format = !empty($misp_module_config['mispattributes']['expect_misp_core_format']);
|
||||
}
|
||||
if (!empty($misp_module_config['mispattributes']['support_filters'])) {
|
||||
$this->support_filters = !empty($misp_module_config['mispattributes']['support_filters']);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ class WorkflowBaseModule
|
|||
public $is_misp_module = false;
|
||||
public $blocking = false;
|
||||
public $is_custom = false;
|
||||
public $expect_misp_core_format = false;
|
||||
public $id = 'to-override';
|
||||
public $name = 'to-override';
|
||||
public $version = '0.1';
|
||||
|
@ -214,6 +215,7 @@ class WorkflowBaseModule
|
|||
class WorkflowBaseTriggerModule extends WorkflowBaseModule
|
||||
{
|
||||
public $blocking = false;
|
||||
public $misp_core_format = false;
|
||||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_enrich_event extends WorkflowBaseActionModule
|
|||
public $inputs = 1;
|
||||
public $outputs = 1;
|
||||
public $support_filters = true;
|
||||
public $expect_misp_core_format = true;
|
||||
public $params = [];
|
||||
|
||||
private $Module;
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_distribution_if extends WorkflowBaseLogicModule
|
|||
public $inputs = 1;
|
||||
public $outputs = 2;
|
||||
public $html_template = 'if';
|
||||
public $expect_misp_core_format = true;
|
||||
public $params = [];
|
||||
|
||||
private $Attribute;
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_organisation_if extends WorkflowBaseLogicModule
|
|||
public $inputs = 1;
|
||||
public $outputs = 2;
|
||||
public $html_template = 'if';
|
||||
public $expect_misp_core_format = true;
|
||||
public $params = [];
|
||||
|
||||
private $Organisation;
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_published_if extends WorkflowBaseLogicModule
|
|||
public $inputs = 1;
|
||||
public $outputs = 2;
|
||||
public $html_template = 'if';
|
||||
public $expect_misp_core_format = true;
|
||||
public $params = [];
|
||||
|
||||
private $operators = [
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_tag_if extends WorkflowBaseLogicModule
|
|||
public $inputs = 1;
|
||||
public $outputs = 2;
|
||||
public $html_template = 'if';
|
||||
public $expect_misp_core_format = true;
|
||||
public $params = [];
|
||||
|
||||
private $Tag;
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_attribute_after_save extends WorkflowBaseTriggerModule
|
|||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = false;
|
||||
public $misp_core_format = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_enrichment_before_query extends WorkflowBaseTriggerModule
|
|||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = true;
|
||||
public $misp_core_format = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_object_after_save extends WorkflowBaseTriggerModule
|
|||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = false;
|
||||
public $misp_core_format = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ class Module_publish extends WorkflowBaseTriggerModule
|
|||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = true;
|
||||
public $misp_core_format = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -33,6 +33,15 @@
|
|||
'element' => 'boolean',
|
||||
'colors' => true,
|
||||
],
|
||||
[
|
||||
'name' => __('MISP Core format'),
|
||||
'sort' => 'expect_misp_core_format',
|
||||
'class' => 'short',
|
||||
'data_path' => 'expect_misp_core_format',
|
||||
'element' => 'boolean',
|
||||
'colors' => true,
|
||||
'title' => __('Does this module expect data compliant with the MISP core format'),
|
||||
],
|
||||
[
|
||||
'name' => __('misp-module'),
|
||||
'sort' => 'is_misp_module',
|
||||
|
|
|
@ -16,10 +16,21 @@
|
|||
],
|
||||
[
|
||||
'name' => __('Blocking Workflow'),
|
||||
'class' => 'short',
|
||||
'sort' => 'blocking',
|
||||
'data_path' => 'blocking',
|
||||
'element' => 'boolean',
|
||||
'colors' => true,
|
||||
'title' => __('Can the workflow block the execution of the operation calling the trigger')
|
||||
],
|
||||
[
|
||||
'name' => __('MISP Core format'),
|
||||
'class' => 'short',
|
||||
'sort' => 'misp_core_format',
|
||||
'data_path' => 'misp_core_format',
|
||||
'element' => 'boolean',
|
||||
'colors' => true,
|
||||
'title' => __('Is the data compliant with the MISP Core format.')
|
||||
],
|
||||
[
|
||||
'name' => __('Workflow ID'),
|
||||
|
@ -37,6 +48,7 @@
|
|||
'element' => 'booleanOrNA',
|
||||
'boolean_reverse' => true,
|
||||
'colors' => true,
|
||||
'title' => __('Only enabled workflows will be executed when their trigger is called')
|
||||
],
|
||||
];
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
|
@ -47,7 +47,10 @@ var dotBlock_trigger = doT.template(' \
|
|||
<strong style="margin-left: 0.25em;"> \
|
||||
{{=it.name}} \
|
||||
</strong> \
|
||||
<span style="margin-left: auto;"> \
|
||||
<span style="margin-left: auto; display: flex; align-items: center;"> \
|
||||
{{? it.misp_core_format }} \
|
||||
<img src="/img/misp-logo-no-text.png" alt="Icon of {{=it.name}}" width="18" height="18" style="margin: auto 0;" title="The data passed by this trigger is compliant with the MISP core format"> \
|
||||
{{?}} \
|
||||
<span class="block-notification-container"> \
|
||||
{{=it._block_notification_html}} \
|
||||
</span> \
|
||||
|
|
Loading…
Reference in New Issue