mirror of https://github.com/MISP/MISP
Merge branch '2.4' of https://github.com/MISP/MISP into 2.4
commit
0559b766cb
|
@ -35,5 +35,5 @@
|
|||
url = https://github.com/MISP/misp-noticelist
|
||||
[submodule "Plugin/DebugKit"]
|
||||
path = Plugin/DebugKit
|
||||
url = git://github.com/cakephp/debug_kit.git
|
||||
url = https://github.com/cakephp/debug_kit.git
|
||||
branch = 2.2
|
||||
|
|
|
@ -26,7 +26,7 @@ before_install:
|
|||
install:
|
||||
- sudo add-apt-repository -y ppa:deadsnakes/ppa
|
||||
- sudo apt-get -y update
|
||||
- sudo apt-get -y install python3.6 python3-pip python3.6-dev python3-nose libxml2-dev libzmq3-dev zlib1g-dev apache2 curl php-mysql php-dev php-cli libapache2-mod-php libfuzzy-dev
|
||||
- sudo apt-get -y install python3.6 python3-pip python3.6-dev python3-nose libxml2-dev libzmq3-dev zlib1g-dev apache2 curl php-mysql php-dev php-cli libapache2-mod-php libfuzzy-dev php-mbstring
|
||||
- sudo apt-get -y dist-upgrade
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- sudo python3.6 get-pip.py
|
||||
|
|
2
PyMISP
2
PyMISP
|
@ -1 +1 @@
|
|||
Subproject commit ba02c6c7663b65109b9878539e6efe66b2ffa5c6
|
||||
Subproject commit 1dc2f664d19960825e20cb7a991580536ac5e6f8
|
|
@ -2116,6 +2116,9 @@ class AttributesController extends AppController
|
|||
if ($returnFormat === 'download') {
|
||||
$returnFormat = 'json';
|
||||
}
|
||||
if (!isset($validFormats[$returnFormat][1])) {
|
||||
throw new NotFoundException('Invalid output format.');
|
||||
}
|
||||
App::uses($validFormats[$returnFormat][1], 'Export');
|
||||
$exportTool = new $validFormats[$returnFormat][1]();
|
||||
if (empty($exportTool->non_restrictive_export)) {
|
||||
|
@ -2181,6 +2184,7 @@ class AttributesController extends AppController
|
|||
fwrite($tmpfile, $exportTool->footer($exportToolParams));
|
||||
fseek($tmpfile, 0);
|
||||
$final = fread($tmpfile, fstat($tmpfile)['size']);
|
||||
fclose($tmpfile);
|
||||
$responseType = $validFormats[$returnFormat][0];
|
||||
return $this->RestResponse->viewData($final, $responseType, false, true);
|
||||
}
|
||||
|
|
|
@ -379,6 +379,15 @@ class RestResponseComponent extends Component
|
|||
return $this->__sendResponse($data, 200, $format, $raw, $download);
|
||||
}
|
||||
|
||||
public function sendFile($path, $format = false, $download = false, $name = 'download') {
|
||||
$cakeResponse = new CakeResponse(array(
|
||||
'status' => 200,
|
||||
'type' => $format
|
||||
));
|
||||
$cakeResponse->file($path, array('name' => $name, 'download' => true));
|
||||
return $cakeResponse;
|
||||
}
|
||||
|
||||
public function throwException($code, $message, $url = '', $format = false, $raw = false)
|
||||
{
|
||||
$message = array(
|
||||
|
|
|
@ -996,6 +996,7 @@ class EventsController extends AppController
|
|||
}
|
||||
$conditions['includeFeedCorrelations'] = true;
|
||||
$conditions['includeAllTags'] = true;
|
||||
$conditions['includeGranularCorrelations'] = 1;
|
||||
$results = $this->Event->fetchEvent($this->Auth->user(), $conditions);
|
||||
if (empty($results)) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
|
@ -1382,6 +1383,9 @@ class EventsController extends AppController
|
|||
$this->set('extended', 0);
|
||||
}
|
||||
$conditions['includeFeedCorrelations'] = true;
|
||||
if (!$this->_isRest()) {
|
||||
$conditions['includeGranularCorrelations'] = 1;
|
||||
}
|
||||
$results = $this->Event->fetchEvent($this->Auth->user(), $conditions);
|
||||
if (empty($results)) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
|
@ -3002,6 +3006,43 @@ class EventsController extends AppController
|
|||
return $this->response;
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive a list of eventids in the id=>count format
|
||||
* Chunk them by the attribute count to fit the memory limits
|
||||
*
|
||||
*/
|
||||
private function __clusterEventIds($exportTool, $eventIds) {
|
||||
$memory_in_mb = $this->Event->Attribute->convert_to_memory_limit_to_mb(ini_get('memory_limit'));
|
||||
$memory_scaling_factor = isset($exportTool->memory_scaling_factor) ? $exportTool->memory_scaling_factor : 100;
|
||||
$limit = $memory_in_mb * $memory_scaling_factor;
|
||||
$eventIdList = array();
|
||||
$continue = true;
|
||||
$i = 0;
|
||||
$current_chunk_size = 0;
|
||||
while (!empty($eventIds)) {
|
||||
foreach ($eventIds as $id => $count) {
|
||||
if ($current_chunk_size == 0 && $count > $limit) {
|
||||
$eventIdList[$i][] = $id;
|
||||
$current_chunk_size = $count;
|
||||
unset($eventIds[$id]);
|
||||
$i++;
|
||||
break;
|
||||
} else {
|
||||
if (($current_chunk_size + $count) > $limit) {
|
||||
$i++;
|
||||
$current_chunk_size = 0;
|
||||
break;
|
||||
} else {
|
||||
$current_chunk_size += $count;
|
||||
$eventIdList[$i][] = $id;
|
||||
unset($eventIds[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $eventIdList;
|
||||
}
|
||||
|
||||
// Use the REST interface to search for attributes or events. Usage:
|
||||
// MISP-base-url/events/restSearch/[api-key]/[value]/[type]/[category]/[orgc]
|
||||
// value, type, category, orgc are optional
|
||||
|
@ -3019,13 +3060,13 @@ class EventsController extends AppController
|
|||
'ordered_url_params' => compact($paramArray)
|
||||
);
|
||||
$validFormats = array(
|
||||
'openioc' => array('xml', 'OpeniocExport'),
|
||||
'json' => array('json', 'JsonExport'),
|
||||
'xml' => array('xml', 'XmlExport'),
|
||||
'suricata' => array('txt', 'NidsSuricataExport'),
|
||||
'snort' => array('txt', 'NidsSnortExport'),
|
||||
'rpz' => array('rpz', 'RPZExport'),
|
||||
'text' => array('text', 'TextExport')
|
||||
'openioc' => array('xml', 'OpeniocExport', 'ioc'),
|
||||
'json' => array('json', 'JsonExport', 'json'),
|
||||
'xml' => array('xml', 'XmlExport', 'xml'),
|
||||
'suricata' => array('txt', 'NidsSuricataExport', 'rules'),
|
||||
'snort' => array('txt', 'NidsSnortExport', 'rules'),
|
||||
'rpz' => array('rpz', 'RPZExport', 'rpz'),
|
||||
'text' => array('text', 'TextExport', 'txt')
|
||||
);
|
||||
$exception = false;
|
||||
$filters = $this->_harvestParameters($filterData, $exception);
|
||||
|
@ -3044,13 +3085,38 @@ class EventsController extends AppController
|
|||
if ($returnFormat === 'download') {
|
||||
$returnFormat = 'json';
|
||||
}
|
||||
$eventid = $this->Event->filterEventIds($user, $filters);
|
||||
if (!isset($validFormats[$returnFormat])) {
|
||||
// this is where the new code path for the export modules will go
|
||||
throw new MethodNotFoundException('Invalid export format.');
|
||||
if (!isset($validFormats[$returnFormat][1])) {
|
||||
throw new NotFoundException('Invalid output format.');
|
||||
}
|
||||
App::uses($validFormats[$returnFormat][1], 'Export');
|
||||
$exportTool = new $validFormats[$returnFormat][1]();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
if (isset($filters['ignore'])) {
|
||||
$filters['to_ids'] = array(0, 1);
|
||||
$filters['published'] = array(0, 1);
|
||||
}
|
||||
if (isset($filters['searchall'])) {
|
||||
$filters['tags'] = $filters['searchall'];
|
||||
$filters['eventinfo'] = $filters['searchall'];
|
||||
$filters['value'] = $filters['searchall'];
|
||||
$filters['comment'] = $filters['searchall'];
|
||||
}
|
||||
if (!empty($filters['quickfilter']) && !empty($filters['value'])) {
|
||||
$filters['tags'] = $filters['value'];
|
||||
$filters['eventinfo'] = $filters['value'];
|
||||
$filters['comment'] = $filters['value'];
|
||||
}
|
||||
$filters['include_attribute_count'] = 1;
|
||||
$eventid = $this->Event->filterEventIds($user, $filters);
|
||||
$eventids_chunked = $this->__clusterEventIds($exportTool, $eventid);
|
||||
if (!empty($exportTool->additional_params)) {
|
||||
$filters = array_merge($filters, $exportTool->additional_params);
|
||||
}
|
||||
|
@ -3069,14 +3135,15 @@ class EventsController extends AppController
|
|||
$filters['published'] = 1;
|
||||
}
|
||||
}
|
||||
$final = $exportTool->header($exportToolParams);
|
||||
$tmpfile = tmpfile();
|
||||
fwrite($tmpfile, $exportTool->header($exportToolParams));
|
||||
$eventCount = count($eventid);
|
||||
$i = 0;
|
||||
if (!empty($filters['withAttachments'])) {
|
||||
$filters['includeAttachments'] = 1;
|
||||
}
|
||||
foreach ($eventid as $k => $currentEventId) {
|
||||
$filters['eventid'] = $currentEventId;
|
||||
foreach ($eventids_chunked as $chunk_index => $chunk) {
|
||||
$filters['eventid'] = $chunk;
|
||||
if (!empty($filters['tags']['NOT'])) {
|
||||
$filters['blockedAttributeTags'] = $filters['tags']['NOT'];
|
||||
}
|
||||
|
@ -3085,20 +3152,25 @@ class EventsController extends AppController
|
|||
$filters,
|
||||
true
|
||||
);
|
||||
if (!empty($result)) {
|
||||
$this->loadModel('Whitelist');
|
||||
$result = $this->Whitelist->removeWhitelistedFromArray($result, false);
|
||||
$temp = $exportTool->handler($result[0], $exportToolParams);
|
||||
if ($temp !== '') {
|
||||
if ($k !== 0) {
|
||||
$final .= $exportTool->separator($exportToolParams);
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $event) {
|
||||
$this->loadModel('Whitelist');
|
||||
$result = $this->Whitelist->removeWhitelistedFromArray($result, false);
|
||||
$temp = $exportTool->handler($event, $exportToolParams);
|
||||
if ($temp !== '') {
|
||||
if ($i !== 0) {
|
||||
$temp = $exportTool->separator($exportToolParams) . $temp;
|
||||
}
|
||||
fwrite($tmpfile, $temp);
|
||||
$i++;
|
||||
}
|
||||
$final .= $temp;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$final .= $exportTool->footer($exportToolParams);
|
||||
fwrite($tmpfile, $exportTool->footer($exportToolParams));
|
||||
fseek($tmpfile, 0);
|
||||
$final = fread($tmpfile, fstat($tmpfile)['size']);
|
||||
fclose($tmpfile);
|
||||
$responseType = $validFormats[$returnFormat][0];
|
||||
return $this->RestResponse->viewData($final, $responseType, false, true);
|
||||
}
|
||||
|
@ -4361,7 +4433,10 @@ class EventsController extends AppController
|
|||
|
||||
public function viewGraph($id)
|
||||
{
|
||||
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $id));
|
||||
$event = $this->Event->fetchEvent($this->Auth->user(), array(
|
||||
'eventid' => $id,
|
||||
'includeGranularCorrelations' => 1
|
||||
));
|
||||
if (empty($event)) {
|
||||
throw new MethodNotAllowedException(__('Invalid Event.'));
|
||||
}
|
||||
|
@ -4371,10 +4446,11 @@ class EventsController extends AppController
|
|||
$this->set('id', $id);
|
||||
}
|
||||
|
||||
|
||||
public function viewEventGraph()
|
||||
{
|
||||
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $id));
|
||||
$event = $this->Event->fetchEvent($this->Auth->user(), array(
|
||||
'eventid' => $id
|
||||
));
|
||||
if (empty($event)) {
|
||||
throw new MethodNotAllowedException(__('Invalid Event.'));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
private function __expandEvent($id)
|
||||
{
|
||||
$event = $this->__eventModel->fetchEvent($this->__user, array('eventid' => $id, 'flatten' => 0, 'includeTagRelations' => 1, 'includeGalaxy' => 1));
|
||||
$event = $this->__eventModel->fetchEvent($this->__user, array('eventid' => $id, 'flatten' => 0, 'includeTagRelations' => 1, 'includeGalaxy' => 1, 'includeGranularCorrelations' => 1));
|
||||
if (empty($event)) {
|
||||
return $this->__json;
|
||||
}
|
||||
|
|
|
@ -3662,12 +3662,6 @@ class Attribute extends AppModel
|
|||
$params['to_ids'] = array(0, 1);
|
||||
$params['published'] = array(0, 1);
|
||||
}
|
||||
if (isset($params['searchall'])) {
|
||||
$params['tags'] = $params['searchall'];
|
||||
$params['eventinfo'] = $params['searchall'];
|
||||
$params['value'] = $params['searchall'];
|
||||
$params['comment'] = $params['searchall'];
|
||||
}
|
||||
$simple_params = array(
|
||||
'Attribute' => array(
|
||||
'value' => array('function' => 'set_filter_value'),
|
||||
|
|
|
@ -705,7 +705,7 @@ class Event extends AppModel
|
|||
$relatedEvents = $this->find(
|
||||
'all',
|
||||
array('conditions' => $conditions,
|
||||
'recursive' => 0,
|
||||
'recursive' => -1,
|
||||
'order' => 'Event.date DESC',
|
||||
'fields' => $fields,
|
||||
'contain' => array(
|
||||
|
@ -1297,16 +1297,6 @@ class Event extends AppModel
|
|||
public function filterEventIds($user, &$params = array())
|
||||
{
|
||||
$conditions = $this->createEventConditions($user);
|
||||
if (isset($params['ignore'])) {
|
||||
$params['to_ids'] = array(0, 1);
|
||||
$params['published'] = array(0, 1);
|
||||
}
|
||||
if (isset($params['searchall'])) {
|
||||
$params['tags'] = $params['searchall'];
|
||||
$params['eventinfo'] = $params['searchall'];
|
||||
$params['value'] = $params['searchall'];
|
||||
$params['comment'] = $params['searchall'];
|
||||
}
|
||||
$simple_params = array(
|
||||
'Event' => array(
|
||||
'eventid' => array('function' => 'set_filter_eventid', 'pop' => true),
|
||||
|
@ -1365,11 +1355,22 @@ class Event extends AppModel
|
|||
}
|
||||
}
|
||||
}
|
||||
$results = array_values($this->find('list', array(
|
||||
'conditions' => $conditions,
|
||||
$fields = array('Event.id');
|
||||
if (!empty($params['include_attribute_count'])) {
|
||||
$fields[] = 'Event.attribute_count';
|
||||
}
|
||||
$find_params = array(
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1,
|
||||
'fields' => array('Event.id')
|
||||
)));
|
||||
'fields' => $fields
|
||||
);
|
||||
if (isset($params['limit'])) {
|
||||
$find_params['limit'] = $params['limit'];
|
||||
if (isset($params['page'])) {
|
||||
$find_params['page'] = $params['page'];
|
||||
}
|
||||
}
|
||||
$results = $this->find('list', $find_params);
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
@ -1669,16 +1670,14 @@ class Event extends AppModel
|
|||
'ThreatLevel' => array(
|
||||
'fields' => array('ThreatLevel.name')
|
||||
),
|
||||
'Org' => array('fields' => $fieldsOrg),
|
||||
'Orgc' => array('fields' => $fieldsOrg),
|
||||
'Attribute' => array(
|
||||
'fields' => $fieldsAtt,
|
||||
'conditions' => $conditionsAttributes,
|
||||
'order' => false,
|
||||
'AttributeTag' => array(
|
||||
'Tag' => array('conditions' => $tagConditions, 'order' => false),
|
||||
'order' => false
|
||||
),
|
||||
'AttributeTag' => array(
|
||||
'Tag' => array('conditions' => $tagConditions, 'order' => false),
|
||||
'order' => false
|
||||
),
|
||||
'order' => false
|
||||
),
|
||||
'Object' => array(
|
||||
'fields' => $fieldsObj,
|
||||
|
@ -1695,10 +1694,10 @@ class Event extends AppModel
|
|||
'Org' => array('fields' => $fieldsOrg),
|
||||
'order' => false
|
||||
),
|
||||
'EventTag' => array(
|
||||
'Tag' => array('conditions' => $tagConditions, 'order' => false),
|
||||
'order' => false
|
||||
)
|
||||
'EventTag' => array(
|
||||
'Tag' => array('conditions' => $tagConditions, 'order' => false),
|
||||
'order' => false
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($flatten) {
|
||||
|
@ -1715,7 +1714,6 @@ class Event extends AppModel
|
|||
if (empty($results)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Do some refactoring with the event
|
||||
$this->Sighting = ClassRegistry::init('Sighting');
|
||||
$userEmails = array();
|
||||
|
@ -1725,29 +1723,8 @@ class Event extends AppModel
|
|||
'Object' => array('name', 'meta-category')
|
||||
);
|
||||
foreach ($results as $eventKey => &$event) {
|
||||
if (!empty($event['Object'])) {
|
||||
foreach ($event['Object'] as $k => $object) {
|
||||
if (!empty($object['ObjectReference'])) {
|
||||
foreach ($object['ObjectReference'] as $k2 => $reference) {
|
||||
$type = array('Attribute', 'Object')[$reference['referenced_type']];
|
||||
$temp = $this->{$type}->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => array_merge($fields['common'], $fields[array('Attribute', 'Object')[$reference['referenced_type']]]),
|
||||
'conditions' => array('id' => $reference['referenced_id'])
|
||||
));
|
||||
if (!empty($temp)) {
|
||||
if (!$isSiteAdmin && $user['org_id'] != $event['Event']['orgc_id']) {
|
||||
if ($temp[$type]['distribution'] == 0 || ($temp[$type]['distribution'] == 4 && !in_array($temp[$type]['sharing_group_id'], $sgsids))) {
|
||||
unset($object['ObjectReference'][$k2]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$event['Object'][$k]['ObjectReference'][$k2][$type] = $temp[$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->__attachReferences($user, $event, $sgids, $fields);
|
||||
$event = $this->Orgc->attachOrgsToEvent($event, $fieldsOrg);
|
||||
if (!$options['sgReferenceOnly'] && $event['Event']['sharing_group_id']) {
|
||||
$event['SharingGroup'] = $sharingGroupData[$event['Event']['sharing_group_id']]['SharingGroup'];
|
||||
}
|
||||
|
@ -1762,8 +1739,10 @@ class Event extends AppModel
|
|||
// Let's find all the related events and attach it to the event itself
|
||||
$results[$eventKey]['RelatedEvent'] = $this->getRelatedEvents($user, $event['Event']['id'], $sgids);
|
||||
// Let's also find all the relations for the attributes - this won't be in the xml export though
|
||||
$results[$eventKey]['RelatedAttribute'] = $this->getRelatedAttributes($user, $event['Event']['id'], $sgids);
|
||||
$results[$eventKey]['RelatedShadowAttribute'] = $this->getRelatedAttributes($user, $event['Event']['id'], $sgids, true);
|
||||
if (!empty($options['includeGranularCorrelations'])) {
|
||||
$results[$eventKey]['RelatedAttribute'] = $this->getRelatedAttributes($user, $event['Event']['id'], $sgids);
|
||||
$results[$eventKey]['RelatedShadowAttribute'] = $this->getRelatedAttributes($user, $event['Event']['id'], $sgids, true);
|
||||
}
|
||||
if (isset($event['ShadowAttribute']) && !empty($event['ShadowAttribute']) && isset($options['includeAttachments']) && $options['includeAttachments']) {
|
||||
foreach ($event['ShadowAttribute'] as $k => $sa) {
|
||||
if ($this->ShadowAttribute->typeIsAttachment($sa['type'])) {
|
||||
|
@ -1918,6 +1897,7 @@ class Event extends AppModel
|
|||
|
||||
private function __attachSharingGroups($doAttach, $data, $sharingGroupData)
|
||||
{
|
||||
if (!$doAttach) return $data;
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v['distribution'] == 4) {
|
||||
$data[$k]['SharingGroup'] = $sharingGroupData[$v['sharing_group_id']]['SharingGroup'];
|
||||
|
@ -2075,6 +2055,9 @@ class Event extends AppModel
|
|||
public function set_filter_to_ids(&$params, $conditions, $options)
|
||||
{
|
||||
if (isset($params['to_ids'])) {
|
||||
if ($params['to_ids'] === 'exclude') {
|
||||
$params['to_ids'] = 0;
|
||||
}
|
||||
$conditions['AND']['Attribute.to_ids'] = $params['to_ids'];
|
||||
}
|
||||
return $conditions;
|
||||
|
@ -5259,4 +5242,31 @@ class Event extends AppModel
|
|||
return ($this->processFreeTextData($user, $attributes, $id, $default_comment = '', $force = false, $adhereToWarninglists = false));
|
||||
}
|
||||
}
|
||||
|
||||
private function __attachReferences($user, &$event, $sgids, $fields)
|
||||
{
|
||||
if (!empty($event['Object'])) {
|
||||
foreach ($event['Object'] as $k => $object) {
|
||||
if (!empty($object['ObjectReference'])) {
|
||||
foreach ($object['ObjectReference'] as $k2 => $reference) {
|
||||
$type = array('Attribute', 'Object')[$reference['referenced_type']];
|
||||
$temp = $this->{$type}->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => array_merge($fields['common'], $fields[array('Attribute', 'Object')[$reference['referenced_type']]]),
|
||||
'conditions' => array('id' => $reference['referenced_id'])
|
||||
));
|
||||
if (!empty($temp)) {
|
||||
if (!$user['Role']['perm_site_admin'] && $user['org_id'] != $event['Event']['orgc_id']) {
|
||||
if ($temp[$type]['distribution'] == 0 || ($temp[$type]['distribution'] == 4 && !in_array($temp[$type]['sharing_group_id'], $sgsids))) {
|
||||
unset($object['ObjectReference'][$k2]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$event['Object'][$k]['ObjectReference'][$k2][$type] = $temp[$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class GalaxyCluster extends AppModel
|
|||
)
|
||||
);
|
||||
|
||||
private $__clusterCache = array();
|
||||
|
||||
public $hasMany = array(
|
||||
'GalaxyElement' => array('dependent' => true),
|
||||
|
@ -144,6 +145,9 @@ class GalaxyCluster extends AppModel
|
|||
if (is_numeric($name)) {
|
||||
$conditions = array('GalaxyCluster.id' => $name);
|
||||
}
|
||||
if (isset($this->__clusterCache[$name])) {
|
||||
return $this->__clusterCache[$name];
|
||||
}
|
||||
$objects = array('Galaxy', 'GalaxyElement');
|
||||
$cluster = $this->find('first', array(
|
||||
'conditions' => $conditions,
|
||||
|
@ -179,6 +183,7 @@ class GalaxyCluster extends AppModel
|
|||
}
|
||||
$cluster['GalaxyCluster']['meta'] = $elements;
|
||||
}
|
||||
$this->__clusterCache[$name] = $cluster;
|
||||
return $cluster;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ class Organisation extends AppModel
|
|||
),
|
||||
);
|
||||
|
||||
private $__orgCache = array();
|
||||
|
||||
public $validate = array(
|
||||
'name' => array(
|
||||
'unique' => array(
|
||||
|
@ -372,6 +374,31 @@ class Organisation extends AppModel
|
|||
'conditions' => $conditions,
|
||||
'recursive' => -1
|
||||
));
|
||||
return (empty($org)) ? false : $org;
|
||||
return (empty($org)) ? false : $org[$this->alias];
|
||||
}
|
||||
|
||||
public function attachOrgsToEvent($event, $fields)
|
||||
{
|
||||
if (empty($this->__orgCache[$event['Event']['orgc_id']])) {
|
||||
$temp = $this->find('first', array(
|
||||
'conditions' => array('id' => $event['Event']['orgc_id']),
|
||||
'recursive' => -1,
|
||||
'fields' => $fields
|
||||
));
|
||||
if (!empty($temp)) $temp = $temp[$this->alias];
|
||||
$this->__orgCache[$event['Event']['orgc_id']] = $temp;
|
||||
}
|
||||
$event['Orgc'] = $this->__orgCache[$event['Event']['orgc_id']];
|
||||
if (empty($this->__orgCache[$event['Event']['org_id']])) {
|
||||
$temp = $this->find('first', array(
|
||||
'conditions' => array('id' => $event['Event']['org_id']),
|
||||
'recursive' => -1,
|
||||
'fields' => $fields
|
||||
));
|
||||
if (!empty($temp)) $temp = $temp[$this->alias];
|
||||
$this->__orgCache[$event['Event']['org_id']] = $temp;
|
||||
}
|
||||
$event['Org'] = $this->__orgCache[$event['Event']['org_id']];
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ class SharingGroup extends AppModel
|
|||
)
|
||||
);
|
||||
|
||||
private $__sgoCache = array();
|
||||
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
{
|
||||
|
@ -163,10 +165,7 @@ class SharingGroup extends AppModel
|
|||
array(
|
||||
'fields' => array('SharingGroup.*'),
|
||||
'contain' => array(
|
||||
'Organisation' => array('fields' => $fieldsOrg),
|
||||
'SharingGroupOrg' => array(
|
||||
'Organisation' => array('fields' => $fieldsOrg),
|
||||
),
|
||||
'SharingGroupOrg',
|
||||
'SharingGroupServer' => array(
|
||||
'Server' => array('fields' => $fieldsServer),
|
||||
)
|
||||
|
@ -179,6 +178,26 @@ class SharingGroup extends AppModel
|
|||
'fields' => $fieldsSharingGroup[$permissionTree]['fields'],
|
||||
'order' => 'SharingGroup.name ASC'
|
||||
));
|
||||
foreach ($sgs as &$sg) {
|
||||
if (!isset($this->__sgoCache[$sg['SharingGroup']['org_id']])) {
|
||||
$this->__sgoCache[$sg['SharingGroup']['org_id']] = $this->Organisation->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => $fieldsOrg,
|
||||
'conditions' => array('id' => $sg['SharingGroup']['org_id'])
|
||||
));
|
||||
}
|
||||
$sg['Organisation'] = $this->__sgoCache[$sg['SharingGroup']['org_id']];
|
||||
foreach ($sg['SharingGroupOrg'] as &$sgo) {
|
||||
if (!isset($this->__sgoCache[$sgo['org_id']])) {
|
||||
$this->__sgoCache[$sgo['org_id']] = $this->Organisation->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => $fieldsOrg,
|
||||
'conditions' => array('id' => $sgo['org_id'])
|
||||
));
|
||||
}
|
||||
$sgo['Organisation'] = $this->__sgoCache[$sgo['org_id']];
|
||||
}
|
||||
}
|
||||
return $sgs;
|
||||
} elseif ($scope == 'name') {
|
||||
$sgs = $this->find('list', array(
|
||||
|
|
|
@ -273,31 +273,33 @@ class User extends AppModel
|
|||
{
|
||||
if (Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_user_notifications_enable')) {
|
||||
$pubSubTool = $this->getPubSubTool();
|
||||
$user = $this->data;
|
||||
if (!isset($user['User'])) {
|
||||
$user['User'] = $user;
|
||||
}
|
||||
$action = $created ? 'edit' : 'add';
|
||||
if (isset($user['User']['action'])) {
|
||||
$action = $user['User']['action'];
|
||||
}
|
||||
if (isset($user['User']['id'])) {
|
||||
$user = $this->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditons' => array('User.id' => $user['User']['id']),
|
||||
'fields' => array('id', 'email', 'last_login', 'org_id', 'termsaccepted', 'autoalert', 'newsread', 'disabled'),
|
||||
'contain' => array(
|
||||
'Organisation' => array(
|
||||
'fields' => array('Organisation.id', 'Organisation.name', 'Organisation.description', 'Organisation.uuid', 'Organisation.nationality', 'Organisation.sector', 'Organisation.type', 'Organisation.local')
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
if (isset($user['User']['password'])) {
|
||||
unset($user['User']['password']);
|
||||
unset($user['User']['confirm_password']);
|
||||
}
|
||||
$pubSubTool->modified($user, 'user', $action);
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->data;
|
||||
if (!isset($user['User'])) {
|
||||
$user['User'] = $user;
|
||||
}
|
||||
$action = $created ? 'edit' : 'add';
|
||||
if (isset($user['User']['action'])) {
|
||||
$action = $user['User']['action'];
|
||||
}
|
||||
if (isset($user['User']['id'])) {
|
||||
$user = $this->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('User.id' => $user['User']['id']),
|
||||
'fields' => array('id', 'email', 'last_login', 'org_id', 'termsaccepted', 'autoalert', 'newsread', 'disabled'),
|
||||
'contain' => array(
|
||||
'Organisation' => array(
|
||||
'fields' => array('Organisation.id', 'Organisation.name', 'Organisation.description', 'Organisation.uuid', 'Organisation.nationality', 'Organisation.sector', 'Organisation.type', 'Organisation.local')
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
if (isset($user['User']['password'])) {
|
||||
unset($user['User']['password']);
|
||||
unset($user['User']['confirm_password']);
|
||||
}
|
||||
$pubSubTool->modified($user, 'user', $action);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class ApacheShibbAuthenticate extends BaseAuthenticate {
|
|||
//Get user role from its list of groups
|
||||
list($roleChanged, $roleId) = $this->getUserRoleFromGroup($groupTag, $groupRoleMatching, $roleId);
|
||||
if($roleId < 0) {
|
||||
CakeLog::write('error', 'No role was assigned, no egorup matched the configuration.');
|
||||
CakeLog::write('error', 'No role was assigned, no egroup matched the configuration.');
|
||||
return false; //Deny if the user is not in any egroup
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Client SSO Authentication (Shibboleth based) for CakePHP
|
||||
|
||||
This plugin enables CakePHP applications to use Single Sing-On to authenticate its users. It gets the information given by Apache environment variables.
|
||||
This plugin enables CakePHP applications to use Single Sign-On to authenticate its users. It gets the information given by Apache environment variables.
|
||||
|
||||
|
||||
## Usage
|
||||
|
@ -20,7 +20,7 @@ Uncomment the following line to enable SSO authorization
|
|||
|
||||
And configure it. MailTag, OrgTag and GroupTag are the string that represent the key for the values needed by the plugin.
|
||||
For example if you are using ADFS OrgTag will be ADFS_FEDERATION, GroupTag will be ADFS_GROUP, etc. meaning the key for the values needed.
|
||||
DefaultRoleId and DefaultOrg are values that come by default just in case they are not defined or obtained from the environment variables.
|
||||
DefaultOrg are values that come by default just in case they are not defined or obtained from the environment variables.
|
||||
The GroupRoleMatching is an array that allows the definition and correlation between groups and roles in MISP, being them updated
|
||||
if the groups are updated (i.e. a user that was admin and their groups changed inside the organization will have his role changed in MISP
|
||||
upon the next login being now user or org admin respectively). The GroupSeparator is the character used to separate the different groups
|
||||
|
|
|
@ -37,7 +37,10 @@
|
|||
"to_ids" => __('By default (0) all attributes are returned that match the other filter parameters, irregardless of their to_ids setting. To restrict the returned data set to to_ids only attributes set this parameter to 1. You can only use the special "exclude" setting to only return attributes that have the to_ids flag disabled.'),
|
||||
"deleted" => __('If this parameter is set to 1, it will return soft-deleted attributes along with active ones. By using "only" as a parameter it will limit the returned data set to soft-deleted data only.'),
|
||||
"includeEventUuid" => __('Instead of just including the event ID, also include the event UUID in each of the attributes.'),
|
||||
"event_timestamp" => __('Only return attributes from events that have received a modification after the given timestamp.')
|
||||
"event_timestamp" => __('Only return attributes from events that have received a modification after the given timestamp.'),
|
||||
"sgReferenceOnly" => __('If this flag is set, sharing group objects will not be included, instead only the sharing group ID is set.'),
|
||||
"eventinfo" => __("Filter on the event's info field."),
|
||||
"searchall" => __("Search for a full or a substring (delimited by % for substrings) in the event info, event tags, attribute tags, attribute values or attribute comment fields.")
|
||||
),
|
||||
'url' => array(
|
||||
$baseurl . '/attributes/restSearch',
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6d58e288b657a941ef314aac2fef8ae6725254dd
|
||||
Subproject commit 2402c7d98f0ab23f065ae00d3d34ab6610e9a3e9
|
Loading…
Reference in New Issue