2019-11-29 10:11:30 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('Component', 'Controller');
|
|
|
|
|
|
|
|
class RestSearchComponent extends Component
|
|
|
|
{
|
2021-03-30 23:22:46 +02:00
|
|
|
//This array determines the order for ordered_url_params, as a result it is not advised to remove or change existing values
|
2019-11-29 10:11:30 +01:00
|
|
|
public $paramArray = array(
|
|
|
|
'Attribute' => array(
|
2021-03-30 23:22:46 +02:00
|
|
|
//following parameters are not used for attributes anymore: attackGalaxy
|
2019-11-29 10:11:30 +01:00
|
|
|
'returnFormat', 'value' , 'type', 'category', 'org', 'tags', 'from', 'to', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp',
|
|
|
|
'published', 'timestamp','enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id', 'includeEventTags',
|
|
|
|
'includeProposals', 'returnFormat', 'limit', 'page', 'requested_attributes', 'includeContext', 'headerless',
|
|
|
|
'includeWarninglistHits', 'attackGalaxy', 'object_relation', 'includeSightings', 'includeCorrelations', 'includeDecayScore',
|
2020-05-05 18:07:51 +02:00
|
|
|
'decayingModel', 'excludeDecayed', 'modelOverrides', 'includeFullModel', 'score', 'attribute_timestamp', 'first_seen', 'last_seen',
|
|
|
|
'threat_level_id'
|
2019-11-29 10:11:30 +01:00
|
|
|
),
|
|
|
|
'Event' => array(
|
|
|
|
'returnFormat', 'value', 'type', 'category', 'org', 'tags', 'searchall', 'from', 'to', 'last', 'eventid', 'withAttachments',
|
|
|
|
'metadata', 'uuid', 'publish_timestamp', 'timestamp', 'published', 'enforceWarninglist', 'sgReferenceOnly',
|
2020-04-06 11:49:39 +02:00
|
|
|
'limit', 'page', 'requested_attributes', 'includeContext', 'headerless', 'includeWarninglistHits', 'attackGalaxy', 'to_ids', 'deleted',
|
2020-05-05 18:07:51 +02:00
|
|
|
'excludeLocalTags', 'date', 'includeSightingdb', 'tag', 'object_relation', 'threat_level_id'
|
2019-11-29 10:11:30 +01:00
|
|
|
),
|
2020-02-29 08:57:32 +01:00
|
|
|
'Object' => array(
|
|
|
|
'returnFormat', 'value' , 'type', 'category', 'org', 'tags', 'from', 'to', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp',
|
|
|
|
'published', 'timestamp','enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id', 'includeEventTags',
|
|
|
|
'includeProposals', 'returnFormat', 'limit', 'page', 'requested_attributes', 'includeContext', 'headerless',
|
|
|
|
'includeWarninglistHits', 'attackGalaxy', 'object_relation'
|
|
|
|
),
|
2019-11-29 10:11:30 +01:00
|
|
|
'Sighting' => array(
|
|
|
|
'context', 'returnFormat', 'id', 'type', 'from', 'to', 'last', 'org_id', 'source', 'includeAttribute', 'includeEvent'
|
2020-05-26 11:17:58 +02:00
|
|
|
),
|
|
|
|
'GalaxyCluster' => array(
|
|
|
|
'page', 'limit', 'id', 'uuid', 'galaxy_id', 'galaxy_uuid', 'version', 'distribution', 'org', 'orgc', 'tag', 'custom', 'sgReferenceOnly', 'minimal',
|
2019-11-29 10:11:30 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
public function getFilename($filters, $scope, $responseType)
|
|
|
|
{
|
|
|
|
$filename = false;
|
|
|
|
if ($scope === 'Event') {
|
|
|
|
$filename = 'misp.event.';
|
|
|
|
if (!empty($filters['eventid']) && !is_array($filters['eventid'])) {
|
|
|
|
if (Validation::uuid(trim($filters['eventid']))) {
|
|
|
|
$filename .= trim($filters['eventid']);
|
|
|
|
} else if (!empty(intval(trim($filters['eventid'])))) {
|
|
|
|
$filename .= intval(trim($filters['eventid']));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$filename .= 'list';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($filename !== false) {
|
|
|
|
$filename .= '.' . $responseType;
|
|
|
|
}
|
|
|
|
return $filename;
|
|
|
|
}
|
|
|
|
}
|