mirror of https://github.com/MISP/MISP
fix: [eventReport] Correctly tag event if requested + undefined variable
parent
2143cdf83d
commit
9c48f03cfe
|
@ -206,7 +206,7 @@ class EventReportsController extends AppController
|
|||
$errors = $this->EventReport->applySuggestions($this->Auth->user(), $report, $suggestionResult['contentWithSuggestions'], $suggestionResult['suggestionsMapping']);
|
||||
if (empty($errors)) {
|
||||
if (!empty($this->data['EventReport']['tag_event'])) {
|
||||
$this->AttachTagsAfterReplacements($this->Auth->User(), $contextResults['replacedContext']);
|
||||
$this->EventReport->attachTagsAfterReplacements($this->Auth->User(), $contextResults['replacedContext'], $report['EventReport']['event_id']);
|
||||
}
|
||||
$report = $this->EventReport->simpleFetchById($this->Auth->user(), $reportId);
|
||||
$data = [ 'report' => $report ];
|
||||
|
@ -230,6 +230,7 @@ class EventReportsController extends AppController
|
|||
} else {
|
||||
$report = $this->EventReport->fetchIfAuthorized($this->Auth->user(), $reportId, 'view', $throwErrors=true, $full=false);
|
||||
$dataResults = $this->EventReport->getComplexTypeToolResultWithReplacements($this->Auth->user(), $report);
|
||||
$report['EventReport']['content'] = $dataResults['replacementResult']['contentWithReplacements'];
|
||||
$contextResults = $this->EventReport->extractWithReplacements($this->Auth->user(), $report);
|
||||
$typeToCategoryMapping = $this->EventReport->Event->Attribute->typeToCategoryMapping();
|
||||
$data = [
|
||||
|
|
|
@ -717,6 +717,7 @@ class EventReport extends AppModel
|
|||
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
|
||||
$mitreAttackGalaxyId = $this->GalaxyCluster->Galaxy->getMitreAttackGalaxyId();
|
||||
$clusterContain = ['Tag'];
|
||||
$replacedContext = [];
|
||||
|
||||
if ($options['prune_deprecated']) {
|
||||
$clusterContain['Galaxy'] = ['conditions' => ['Galaxy.namespace !=' => 'deprecated']];
|
||||
|
@ -881,7 +882,7 @@ class EventReport extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
public function AttachTagsAfterReplacements($user, $replacedContext)
|
||||
public function attachTagsAfterReplacements($user, $replacedContext, $eventId)
|
||||
{
|
||||
$this->EventTag = ClassRegistry::init('EventTag');
|
||||
foreach ($replacedContext as $rawText => $tagNames) {
|
||||
|
@ -892,7 +893,7 @@ class EventReport extends AppModel
|
|||
if ($tagId === -1) {
|
||||
$tagId = $this->EventTag->Tag->captureTag(['name' => $tagName], $user);
|
||||
}
|
||||
$this->EventTag->attachTagToEvent($report['EventReport']['event_id'], $tagId);
|
||||
$this->EventTag->attachTagToEvent($eventId, $tagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ echo $this->element('genericElements/Form/genericForm', array(
|
|||
'fields' => array(
|
||||
sprintf('<h5>%s</h5>', __('Post extraction actions:')),
|
||||
array(
|
||||
'label' => __('Tag the event with element found in the report'),
|
||||
'label' => __('Tag the event with contextual elements found in the report'),
|
||||
'field' => 'tag_event',
|
||||
'type' => 'checkbox',
|
||||
'div' => array('class' => 'checkbox')
|
||||
|
|
Loading…
Reference in New Issue