mirror of https://github.com/MISP/MISP
Merge pull request #8277 from tomking2/feature/restSearch_SharingGroup
Add in new RestAPI parameter to filter by sharing group on Event or Attribute searchpull/8063/merge
commit
204ec386b2
|
@ -48,7 +48,7 @@ class RestResponseComponent extends Component
|
|||
'restSearch' => array(
|
||||
'description' => "Search MISP using a list of filter parameters and return the data in the selected format. The search is available on an event and an attribute level, just select the scope via the URL (/events/restSearch vs /attributes/restSearch). Besides the parameters listed, other, format specific ones can be passed along (for example: requested_attributes and includeContext for the CSV export). This API allows pagination via the page and limit parameters.",
|
||||
'mandatory' => array('returnFormat'),
|
||||
'optional' => array('page', 'limit', 'value' , 'type', 'category', 'org', 'tags', 'date', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp', 'timestamp', 'attribute_timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'includeEventTags', 'event_timestamp', 'threat_level_id', 'eventinfo', 'includeProposals', 'includeDecayScore', 'includeFullModel', 'decayingModel', 'excludeDecayed', 'score', 'first_seen', 'last_seen'),
|
||||
'optional' => array('page', 'limit', 'value' , 'type', 'category', 'org', 'tags', 'date', 'last', 'eventid', 'withAttachments', 'uuid', 'publish_timestamp', 'timestamp', 'attribute_timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'includeEventTags', 'event_timestamp', 'threat_level_id', 'eventinfo', 'sharinggroup', 'includeProposals', 'includeDecayScore', 'includeFullModel', 'decayingModel', 'excludeDecayed', 'score', 'first_seen', 'last_seen'),
|
||||
'params' => array()
|
||||
),
|
||||
'addTag' => array(
|
||||
|
@ -88,7 +88,7 @@ class RestResponseComponent extends Component
|
|||
'restSearch' => array(
|
||||
'description' => "Search MISP using a list of filter parameters and return the data in the selected format. The search is available on an event and an attribute level, just select the scope via the URL (/events/restSearch vs /attributes/restSearch). Besides the parameters listed, other, format specific ones can be passed along (for example: requested_attributes and includeContext for the CSV export). This API allows pagination via the page and limit parameters.",
|
||||
'mandatory' => array('returnFormat'),
|
||||
'optional' => array('page', 'limit', 'value', 'type', 'category', 'org', 'tag', 'tags', 'searchall', 'date', 'last', 'eventid', 'withAttachments', 'metadata', 'uuid', 'published', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'sgReferenceOnly', 'eventinfo', 'excludeLocalTags', 'threat_level_id'),
|
||||
'optional' => array('page', 'limit', 'value', 'type', 'category', 'org', 'tag', 'tags', 'searchall', 'date', 'last', 'eventid', 'withAttachments', 'metadata', 'uuid', 'published', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'sgReferenceOnly', 'eventinfo', 'sharinggroup', 'excludeLocalTags', 'threat_level_id'),
|
||||
'params' => array()
|
||||
),
|
||||
'addTag' => array(
|
||||
|
|
|
@ -3154,6 +3154,7 @@ class Attribute extends AppModel
|
|||
}
|
||||
$simple_params = array(
|
||||
'Attribute' => array(
|
||||
'sharinggroup' => array('function' => 'set_filter_sharing_group'),
|
||||
'value' => array('function' => 'set_filter_value'),
|
||||
'category' => array('function' => 'set_filter_simple_attribute'),
|
||||
'type' => array('function' => 'set_filter_type'),
|
||||
|
@ -3169,6 +3170,7 @@ class Attribute extends AppModel
|
|||
'comment' => array('function' => 'set_filter_comment')
|
||||
),
|
||||
'Event' => array(
|
||||
'sharinggroup' => array('function' => 'set_filter_sharing_group'),
|
||||
'eventid' => array('function' => 'set_filter_eventid'),
|
||||
'eventinfo' => array('function' => 'set_filter_eventinfo'),
|
||||
'ignore' => array('function' => 'set_filter_ignore'),
|
||||
|
|
|
@ -2553,6 +2553,19 @@ class Event extends AppModel
|
|||
return $container;
|
||||
}
|
||||
|
||||
public function set_filter_sharing_group(&$params, $conditions, $options)
|
||||
{
|
||||
if (!empty($params['sharinggroup'])) {
|
||||
$params['sharinggroup'] = $this->convert_filters($params['sharinggroup']);
|
||||
if ($options['scope'] === 'Attribute') {
|
||||
$conditions = $this->generic_add_filter($conditions, $params['sharinggroup'], ['Event.sharing_group_id', 'Attribute.sharing_group_id']);
|
||||
} else {
|
||||
$conditions = $this->generic_add_filter($conditions, $params['sharinggroup'], 'Event.sharing_group_id');
|
||||
}
|
||||
}
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
public function set_filter_org(&$params, $conditions, $options)
|
||||
{
|
||||
if (!empty($params['org'])) {
|
||||
|
|
|
@ -2868,6 +2868,8 @@ components:
|
|||
eventinfo:
|
||||
description: "Quick event description"
|
||||
type: string
|
||||
sharinggroup:
|
||||
$ref: "#/components/schemas/SharingGroupIDRestSearchFilter"
|
||||
decayingModel:
|
||||
description: "Specify the decaying model from which the decaying score should be calculated"
|
||||
type: string
|
||||
|
@ -5375,6 +5377,13 @@ components:
|
|||
type: string
|
||||
example: "tlp:amber"
|
||||
|
||||
SharingGroupIDRestSearchFilter:
|
||||
description: "Sharing group ID(s), either as single string or list of IDs"
|
||||
nullable: true
|
||||
items:
|
||||
type: string
|
||||
example: "1"
|
||||
|
||||
MetadataRestSearchFilter:
|
||||
description: "Will only return the metadata of the given query scope, contained data is omitted."
|
||||
nullable: true
|
||||
|
@ -6202,6 +6211,8 @@ components:
|
|||
description: "Extends the response with the base64 representation of the attachment, if there is one"
|
||||
type: boolean
|
||||
default: false
|
||||
sharinggroup:
|
||||
$ref: "#/components/schemas/SharingGroupIDRestSearchFilter"
|
||||
metadata:
|
||||
$ref: "#/components/schemas/MetadataRestSearchFilter"
|
||||
uuid:
|
||||
|
|
Loading…
Reference in New Issue