mirror of https://github.com/MISP/MISP
chg: [worflow-trigger:sighting_after_save] Change name to after-save and make it misp_core_format compatible
parent
ceb43a345c
commit
4215c0f149
|
@ -79,7 +79,7 @@ class Sighting extends AppModel
|
|||
{
|
||||
$pubToZmq = $this->pubToZmq('sighting');
|
||||
$kafkaTopic = $this->kafkaTopic('sighting');
|
||||
$isTriggerCallable = $this->isTriggerCallable('sighting-publish');
|
||||
$isTriggerCallable = $this->isTriggerCallable('sighting-after-save');
|
||||
if ($pubToZmq || $kafkaTopic || $isTriggerCallable) {
|
||||
$sighting = $this->getSighting($this->id);
|
||||
if ($pubToZmq) {
|
||||
|
@ -95,11 +95,11 @@ class Sighting extends AppModel
|
|||
$workflowErrors = [];
|
||||
$logging = [
|
||||
'model' => 'Sighting',
|
||||
'action' => $action,
|
||||
'action' => $created ? 'add' : 'edit',
|
||||
'id' => $sighting['Sighting']['id'],
|
||||
];
|
||||
$triggerData = $sighting;
|
||||
$this->executeTrigger('sighting-publish', $triggerData, $workflowErrors, $logging);
|
||||
$this->executeTrigger('sighting-after-save', $triggerData, $workflowErrors, $logging);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
include_once APP . 'Model/WorkflowModules/WorkflowBaseModule.php';
|
||||
|
||||
class Module_sighting_after_save extends WorkflowBaseTriggerModule
|
||||
{
|
||||
public $id = 'sighting-after-save';
|
||||
public $scope = 'sighting';
|
||||
public $name = 'Sighting After Save';
|
||||
public $description = 'This trigger is called when a sighting has been saved';
|
||||
public $icon = 'eye';
|
||||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = false;
|
||||
public $misp_core_format = true;
|
||||
public $trigger_overhead = self::OVERHEAD_MEDIUM;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->trigger_overhead_message = __('This trigger is called each time a Sighting has been saved. This means that when a large quantity of Sightings are being saved (e.g. Feed pulling or synchronisation), the workflow will be run for as many time as there are Sightings.');
|
||||
}
|
||||
|
||||
|
||||
public function normalizeData(array $data)
|
||||
{
|
||||
$this->Event = ClassRegistry::init('Event');
|
||||
$this->Attribute = ClassRegistry::init('Attribute');
|
||||
|
||||
// We are missing data such as tags or objects.
|
||||
$event = $this->Event->quickFetchEvent($data['Sighting']['Event']['id']);
|
||||
$attribute = $this->Attribute->fetchAttribute($data['Sighting']['Attribute']['id']);
|
||||
|
||||
if (!empty($attribute['Object'])) {
|
||||
$event['Event']['Object'] = [$attribute['Object']];
|
||||
$event['Event']['Object'][0]['Attribute'] = [$attribute['Attribute']];
|
||||
} else {
|
||||
$event['Event']['Attribute'] = [$attribute['Attribute']];
|
||||
}
|
||||
|
||||
$event = parent::normalizeData($event);
|
||||
return $event;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
include_once APP . 'Model/WorkflowModules/WorkflowBaseModule.php';
|
||||
|
||||
class Module_sighting_publish extends WorkflowBaseTriggerModule
|
||||
{
|
||||
public $id = 'sighting-publish';
|
||||
public $scope = 'sighting';
|
||||
public $name = 'Sighting Publish';
|
||||
public $description = 'This trigger is called when a sighting has been published';
|
||||
public $icon = 'eye';
|
||||
public $inputs = 0;
|
||||
public $outputs = 1;
|
||||
public $blocking = false;
|
||||
public $misp_core_format = false;
|
||||
public $trigger_overhead = self::OVERHEAD_HIGH;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue