chg: [restsearch] Improvements to the restSearch APIs to function better with URL parameters

- fixed returnFormat for events/restSearch
- added page and limit to the list of parameters
pull/4075/head
iglocska 2019-02-01 07:56:56 +01:00
parent 41e7474a30
commit 714a5a4141
2 changed files with 17 additions and 8 deletions

View File

@ -1933,9 +1933,18 @@ class AttributesController extends AppController
$this->set('fails', $this->Attribute->checkComposites());
}
public function restSearch($returnFormat = false, $value = false, $type = false, $category = false, $org = false, $tags = false, $from = false, $to = false, $last = false, $eventid = false, $withAttachments = false, $uuid = false, $publish_timestamp = false, $published = false, $timestamp = false, $enforceWarninglist = false, $to_ids = false, $deleted = false, $includeEventUuid = false, $event_timestamp = false, $threat_level_id = false)
public function restSearch(
$returnFormat = false, $value = false, $type = false, $category = false, $org = false, $tags = false, $from = false,
$to = false, $last = false, $eventid = false, $withAttachments = false, $uuid = false, $publish_timestamp = false, $published = false,
$timestamp = false, $enforceWarninglist = false, $to_ids = false, $deleted = false, $includeEventUuid = false, $event_timestamp = false,
$threat_level_id = false
)
{
$paramArray = array('value' , 'type', 'category', 'org', 'tags', 'from', 'to', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id', 'includeEventTags', 'includeProposals', 'returnFormat', 'published');
$paramArray = array(
'value' , 'type', 'category', 'org', 'tags', 'from', 'to', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp',
'timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id',
'includeEventTags', 'includeProposals', 'returnFormat', 'published', 'limit', 'page'
);
$filterData = array(
'request' => $this->request,
'named_params' => $this->params['named'],

View File

@ -3046,7 +3046,7 @@ class EventsController extends AppController
// && - you can use && between two search values to put a logical OR between them. for value, 1.1.1.1&&2.2.2.2 would find attributes with the value being either of the two.
// ! - you can negate a search term. For example: google.com&&!mail would search for all attributes with value google.com but not ones that include mail. www.google.com would get returned, mail.google.com wouldn't.
public function restSearch(
$returnFormat = 'json',
$returnFormat = false,
$value = false,
$type = false,
$category = false,
@ -3068,7 +3068,8 @@ class EventsController extends AppController
) {
$paramArray = array(
'value', 'type', 'category', 'org', 'tag', 'tags', 'searchall', 'from', 'to', 'last', 'eventid', 'withAttachments',
'metadata', 'uuid', 'published', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'sgReferenceOnly'
'metadata', 'uuid', 'published', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'sgReferenceOnly', 'returnFormat',
'limit', 'page'
);
$filterData = array(
'request' => $this->request,
@ -3087,10 +3088,9 @@ class EventsController extends AppController
if ($user === false) {
return $exception;
}
if (isset($filters['returnFormat'])) {
if (!empty($filters['returnFormat'])) {
$returnFormat = $filters['returnFormat'];
}
if ($returnFormat === 'download') {
} else if (empty($filters['returnFormat']) || $filters['returnFormat'] === 'download'){
$returnFormat = 'json';
}
$elementCounter = 0;
@ -4029,7 +4029,7 @@ class EventsController extends AppController
'requiresPublished' => true,
'checkbox' => true,
'checkbox_text' => 'Encode Attachments',
'checkbox_set' => '/events/stix/download/' . $id . '/true.xml'
'checkbox_set' => '/events/restSearch/stix/eventid:' . $id . '/includeAttachments:1'
),
'stix_json' => array(
'url' => '/events/stix/download/' . $id . '.json',