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(
|
2023-09-24 08:43:13 +02:00
|
|
|
'Attribute' => [
|
|
|
|
'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',
|
|
|
|
'limit',
|
|
|
|
'page',
|
|
|
|
'requested_attributes',
|
|
|
|
'includeContext',
|
|
|
|
'headerless',
|
|
|
|
'includeWarninglistHits',
|
|
|
|
'attackGalaxy',
|
|
|
|
'object_relation',
|
|
|
|
'includeSightings',
|
|
|
|
'includeCorrelations',
|
|
|
|
'includeDecayScore',
|
|
|
|
'decayingModel',
|
|
|
|
'excludeDecayed',
|
|
|
|
'modelOverrides',
|
|
|
|
'includeFullModel',
|
|
|
|
'score',
|
|
|
|
'attribute_timestamp',
|
|
|
|
'first_seen',
|
|
|
|
'last_seen',
|
|
|
|
'eventinfo',
|
|
|
|
'allow_proposal_blocking',
|
|
|
|
'flatten',
|
|
|
|
'list',
|
|
|
|
'event_ids',
|
|
|
|
'includeAllTags',
|
|
|
|
'includeAttributeUuid',
|
|
|
|
'includeGalaxy'
|
2023-09-24 09:21:32 +02:00
|
|
|
],
|
2023-09-24 08:43:13 +02:00
|
|
|
'Event' => [
|
|
|
|
'returnFormat',
|
|
|
|
'value',
|
|
|
|
'type',
|
|
|
|
'category',
|
|
|
|
'org',
|
|
|
|
'tags',
|
|
|
|
'searchall',
|
|
|
|
'from',
|
|
|
|
'to',
|
|
|
|
'last',
|
|
|
|
'eventid',
|
|
|
|
'withAttachments',
|
|
|
|
'metadata',
|
|
|
|
'uuid',
|
|
|
|
'publish_timestamp',
|
|
|
|
'timestamp',
|
|
|
|
'published',
|
|
|
|
'enforceWarninglist',
|
|
|
|
'sgReferenceOnly',
|
|
|
|
'limit',
|
|
|
|
'page',
|
|
|
|
'requested_attributes',
|
|
|
|
'includeContext',
|
|
|
|
'headerless',
|
|
|
|
'includeWarninglistHits',
|
|
|
|
'attackGalaxy',
|
|
|
|
'to_ids',
|
|
|
|
'deleted',
|
|
|
|
'excludeLocalTags',
|
|
|
|
'date',
|
|
|
|
'includeSightingdb',
|
|
|
|
'tag',
|
|
|
|
'object_relation',
|
|
|
|
'threat_level_id',
|
|
|
|
'eventinfo',
|
|
|
|
'sharinggroup',
|
|
|
|
'idList',
|
|
|
|
'includeAllTags',
|
|
|
|
'includeAttachments',
|
|
|
|
'event_uuid',
|
|
|
|
'distribution',
|
|
|
|
'sharing_group_id',
|
|
|
|
'disableSiteAdmin',
|
|
|
|
'flatten',
|
|
|
|
'blockedAttributeTags',
|
|
|
|
'eventsExtendingUuid',
|
|
|
|
'extended',
|
|
|
|
'extensionList',
|
|
|
|
'excludeGalaxy',
|
|
|
|
'includeRelatedTags',
|
|
|
|
'includeDecayScore',
|
|
|
|
'includeScoresOnEvent',
|
|
|
|
'includeFeedCorrelations',
|
|
|
|
'includeServerCorrelations',
|
|
|
|
'noEventReports',
|
|
|
|
'noShadowAttributes',
|
|
|
|
'order',
|
|
|
|
'protected'
|
2023-09-24 09:21:32 +02:00
|
|
|
],
|
2023-09-24 08:43:13 +02:00
|
|
|
'Object' => [
|
|
|
|
'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',
|
|
|
|
'limit',
|
|
|
|
'page',
|
|
|
|
'requested_attributes',
|
|
|
|
'includeContext',
|
|
|
|
'headerless',
|
|
|
|
'includeWarninglistHits',
|
|
|
|
'attackGalaxy',
|
|
|
|
'object_relation',
|
|
|
|
'metadata',
|
|
|
|
'includeAllTags'
|
2023-09-24 09:21:32 +02:00
|
|
|
],
|
2023-09-24 08:43:13 +02:00
|
|
|
'Sighting' => [
|
|
|
|
'context',
|
|
|
|
'returnFormat',
|
|
|
|
'id',
|
|
|
|
'type',
|
|
|
|
'from',
|
|
|
|
'to',
|
|
|
|
'last',
|
|
|
|
'org_id',
|
|
|
|
'source',
|
|
|
|
'includeAttribute',
|
|
|
|
'includeEvent'
|
2023-09-24 09:21:32 +02:00
|
|
|
],
|
2023-09-24 08:43:13 +02:00
|
|
|
'GalaxyCluster' => [
|
|
|
|
'page',
|
|
|
|
'limit',
|
|
|
|
'id',
|
|
|
|
'uuid',
|
|
|
|
'galaxy_id',
|
|
|
|
'galaxy_uuid',
|
|
|
|
'version',
|
|
|
|
'distribution',
|
|
|
|
'org',
|
|
|
|
'orgc',
|
|
|
|
'tag',
|
|
|
|
'custom',
|
|
|
|
'sgReferenceOnly',
|
|
|
|
'minimal',
|
|
|
|
'list',
|
|
|
|
'first',
|
|
|
|
'count'
|
2023-09-24 09:21:32 +02:00
|
|
|
],
|
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;
|
|
|
|
}
|
|
|
|
}
|