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
Sami Mokaddem 2022-07-20 15:19:33 +02:00
parent 4211cdd15d
commit 2011bf3670
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
16 changed files with 58 additions and 1 deletions

View File

@ -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;

View File

@ -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']);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 = [

View File

@ -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;

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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',

View File

@ -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

View File

@ -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> \