new: [API] Correctly handle objects in flat exports and exposed text export to event level search

pull/3725/head
iglocska 2018-09-14 14:34:01 +02:00
parent a03b1c9d44
commit 2e7dfc9273
4 changed files with 21 additions and 2 deletions

View File

@ -3025,7 +3025,8 @@ class EventsController extends AppController
'xml' => array('xml', 'XmlExport'),
'suricata' => array('txt', 'NidsSuricataExport'),
'snort' => array('txt', 'NidsSnortExport'),
'rpz' => array('rpz', 'RPZExport')
'rpz' => array('rpz', 'RPZExport'),
'text' => array('text', 'TextExport')
);
$exception = false;
$filters = $this->_harvestParameters($filterData, $exception);
@ -3051,6 +3052,9 @@ class EventsController extends AppController
}
App::uses($validFormats[$returnFormat][1], 'Export');
$exportTool = new $validFormats[$returnFormat][1]();
if (!empty($exportTool->additional_params)) {
$filters = array_merge($filters, $exportTool->additional_params);
}
$exportToolParams = array(
'user' => $this->Auth->user(),
'params' => array(),

View File

@ -15,7 +15,8 @@ class NidsExport
'Event' => array(
'fields' => array('threat_level_id')
)
)
),
'flatten' => 1
);
public function handler($data, $options = array())

View File

@ -2,6 +2,9 @@
class OpeniocExport
{
public $additional_params = array(
'flatten' => 1
);
public function buildAll($user, $data, $scope = 'event')
{

View File

@ -2,11 +2,22 @@
class TextExport
{
public $additional_params = array(
'flatten' => 1
);
public function handler($data, $options = array())
{
if ($options['scope'] === 'Attribute') {
return $data['Attribute']['value'];
}
if ($options['scope'] === 'Event') {
$result = array();
foreach ($data['Attribute'] as $attribute) {
$result[] = $attribute['value'];
}
return implode($this->separator(), $result);
}
return '';
}