mirror of https://github.com/MISP/MISP
new: [workflow:baseModule] Added diagnostic support and support of arbitrary URL for webhook module
parent
5ce142ed0f
commit
f479cc858a
|
@ -785,6 +785,11 @@ class Workflow extends AppModel
|
|||
];
|
||||
}
|
||||
}
|
||||
if ($moduleType == 'modules_action') {
|
||||
$moduleClass = $this->getModuleClassByType('action', $module['id']);
|
||||
$diagnostic = $moduleClass->diagnostic();
|
||||
$modules[$moduleType][$i]['notifications'] = array_merge_recursive($modules[$moduleType][$i]['notifications'], $diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $modules;
|
||||
|
|
|
@ -209,6 +209,23 @@ class WorkflowBaseModule
|
|||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function addNotification(array $errors, string $severity, string $text, string $description='', array $details=[], bool $showInSidebar=false, bool $showInNode=false): array
|
||||
{
|
||||
$errors[$severity][] = [
|
||||
'text' => $text,
|
||||
'description' => $description,
|
||||
'details' => $details,
|
||||
'__show_in_sidebar' => $showInSidebar,
|
||||
'__show_in_node' => $showInNode,
|
||||
];
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public function diagnostic(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
class WorkflowBaseTriggerModule extends WorkflowBaseModule
|
||||
|
|
|
@ -48,6 +48,25 @@ class Module_webhook extends WorkflowBaseActionModule
|
|||
];
|
||||
}
|
||||
|
||||
public function diagnostic(): array
|
||||
{
|
||||
$errors = array_merge(parent::diagnostic(), []);
|
||||
if (empty(Configure::read('Security.rest_client_enable_arbitrary_urls'))) {
|
||||
$errors = $this->addNotification(
|
||||
$errors,
|
||||
'error',
|
||||
__('`rest_client_enable_arbitrary_urls` is turned off.'),
|
||||
__('The module will not send any request as long as `Security.rest_client_enable_arbitrary_urls` is not turned on.'),
|
||||
[
|
||||
__('This is a security measure to ensure a site-admin do not send arbitrary request to internal services')
|
||||
],
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public function exec(array $node, WorkflowRoamingData $roamingData, array &$errors = []): bool
|
||||
{
|
||||
parent::exec($node, $roamingData, $errors);
|
||||
|
|
|
@ -28,7 +28,7 @@ $classFromSeverity = [
|
|||
<?php foreach (array_keys($classFromSeverity) as $severity) : ?>
|
||||
<?php
|
||||
$visibleNotifications = array_filter($block['notifications'][$severity], function ($notification) {
|
||||
return $notification['__show_in_sidebar'];
|
||||
return !empty($notification['__show_in_sidebar']);
|
||||
});
|
||||
?>
|
||||
<?php if (!empty($visibleNotifications)) : ?>
|
||||
|
|
Loading…
Reference in New Issue