new: [API] set default behaviour to require to_ids and published set to 1 to be included in exports

- doesn't affect MISP json and xml formats
pull/3626/head
iglocska 2018-09-06 00:20:03 +02:00
parent 2fdeebd209
commit 289b13be88
4 changed files with 20 additions and 2 deletions

View File

@ -2115,6 +2115,16 @@ class AttributesController extends AppController
if ($returnFormat === 'download') {
$returnFormat = 'json';
}
App::uses($validFormats[$returnFormat][1], 'Export');
$exportTool = new $validFormats[$returnFormat][1]();
if (empty($exportTool->non_restrictive_export)) {
if (!isset($filters['to_ids'])) {
$filters['to_ids'] = 1;
}
if (!isset($filters['published'])) {
$filters['published'] = 1;
}
}
$conditions = $this->Attribute->buildFilterConditions($this->Auth->user(), $filters);
$params = array(
'conditions' => $conditions,
@ -2136,8 +2146,6 @@ class AttributesController extends AppController
// this is where the new code path for the export modules will go
throw new MethodNotFoundException('Invalid export format.');
}
App::uses($validFormats[$returnFormat][1], 'Export');
$exportTool = new $validFormats[$returnFormat][1]();
$exportToolParams = array(
'user' => $this->Auth->user(),
'params' => $params,

View File

@ -3055,6 +3055,14 @@ class EventsController extends AppController
'returnFormat' => $returnFormat,
'scope' => 'Event'
);
if (empty($exportTool->non_restrictive_export)) {
if (!isset($filters['to_ids'])) {
$filters['to_ids'] = 1;
}
if (!isset($filters['published'])) {
$filters['published'] = 1;
}
}
$final = $exportTool->header($exportToolParams);
$eventCount = count($eventid);
$i = 0;

View File

@ -3,6 +3,7 @@
class JsonExport
{
private $__converter = false;
public $non_restrictive_export = true;
public function handler($data, $options = array())
{

View File

@ -3,6 +3,7 @@
class XmlExport
{
private $__converter = false;
public $non_restrictive_export = true;
public function handler($data, $options = array())
{