wip: [enrichment] Handling module results and passing it to the view

- Work in progress on the view right now
pull/4338/head
chrisr3d 2019-03-18 18:05:18 +01:00
parent 43f0010cab
commit 81a0cd2974
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 21 additions and 2 deletions

View File

@ -5076,7 +5076,21 @@ class EventsController extends AppController
} }
unset($result['results']['Object']); unset($result['results']['Object']);
} }
// MORE MAGIC TO COME if (empty($attributes) && empty($objects)) {
$this->__handleSimplifiedFormat($attribute, $module, $options, $result, $type);
} else {
$event = array('Event' => $attribute[0]['Event']);
$event['Attribute'] = $attributes;
$event['Object'] = $objects;
$this->set('event', $event);
if (!empty($result['results'])) {
$this->__handleSimplifiedFormat($attribute, $module, $options, $result, $type, $render_name = 'resolved_misp_format');
} else {
$this->set('menuItem', 'enrichmentResults');
$this->set('title', 'Enrichment Results');
$this->render('resolved_misp_format');
}
}
} }
private function __queryOldEnrichment($attribute, $module, $options, $type) private function __queryOldEnrichment($attribute, $module, $options, $type)
@ -5099,6 +5113,11 @@ class EventsController extends AppController
if (!is_array($result)) { if (!is_array($result)) {
throw new Exception($result); throw new Exception($result);
} }
$this->__handleSimplifedFormat($attribute, $module, $options, $result, $type);
}
private function __handleSimplififedFormat($attribute, $module, $options, $result, $type, $renderName = 'resolved_attributes')
{
$resultArray = $this->Event->handleModuleResult($result, $attribute[0]['Attribute']['event_id']); $resultArray = $this->Event->handleModuleResult($result, $attribute[0]['Attribute']['event_id']);
if (isset($result['comment']) && $result['comment'] != "") { if (isset($result['comment']) && $result['comment'] != "") {
$importComment = $result['comment']; $importComment = $result['comment'];
@ -5142,7 +5161,7 @@ class EventsController extends AppController
$this->set('typeCategoryMapping', $typeCategoryMapping); $this->set('typeCategoryMapping', $typeCategoryMapping);
$this->set('title', 'Enrichment Results'); $this->set('title', 'Enrichment Results');
$this->set('importComment', $importComment); $this->set('importComment', $importComment);
$this->render('resolved_attributes'); $this->render($renderName);
} }
public function importModule($module, $eventId) public function importModule($module, $eventId)