diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php index a1ac1b98e..570994eaf 100755 --- a/app/Controller/AppController.php +++ b/app/Controller/AppController.php @@ -462,6 +462,15 @@ class AppController extends Controller $this->set('isAclKafka', isset($role['perm_publish_kafka']) ? $role['perm_publish_kafka'] : false); $this->set('isAclDecaying', isset($role['perm_decaying']) ? $role['perm_decaying'] : false); $this->userRole = $role; + + $this->set('loggedInUserName', $this->__convertEmailToName($this->Auth->user('email'))); + if ($this->request->params['controller'] === 'users' && $this->request->params['action'] === 'dashboard') { + $notifications = $this->{$this->modelClass}->populateNotifications($this->Auth->user()); + } else { + $notifications = $this->{$this->modelClass}->populateNotifications($this->Auth->user(), 'fast'); + } + $this->set('notifications', $notifications); + if ( Configure::read('MISP.log_paranoid') || !empty(Configure::read('Security.monitored')) @@ -499,9 +508,8 @@ class AppController extends Controller } else { $this->set('me', false); } - $this->set('br', '
'); - $this->set('bold', array('', '')); - if ($this->_isSiteAdmin()) { + + if ($this->Auth->user() && $this->_isSiteAdmin()) { if (Configure::read('Session.defaults') == 'database') { $db = ConnectionManager::getDataSource('default'); $sqlResult = $db->query('SELECT COUNT(id) AS session_count FROM cake_sessions WHERE expires < ' . time() . ';'); @@ -515,13 +523,6 @@ class AppController extends Controller } } - $this->set('loggedInUserName', $this->__convertEmailToName($this->Auth->user('email'))); - if ($this->request->params['controller'] === 'users' && $this->request->params['action'] === 'dashboard') { - $notifications = $this->{$this->modelClass}->populateNotifications($this->Auth->user()); - } else { - $notifications = $this->{$this->modelClass}->populateNotifications($this->Auth->user(), 'fast'); - } - $this->set('notifications', $notifications); $this->ACL->checkAccess($this->Auth->user(), Inflector::variable($this->request->params['controller']), $this->action); if ($this->_isRest()) { $this->__rateLimitCheck(); diff --git a/app/Controller/Component/ACLComponent.php b/app/Controller/Component/ACLComponent.php index 1a55239d3..7fc2cb436 100644 --- a/app/Controller/Component/ACLComponent.php +++ b/app/Controller/Component/ACLComponent.php @@ -695,12 +695,23 @@ class ACLComponent extends Component } } - // The check works like this: - // If the user is a site admin, return true - // If the requested action has an OR-d list, iterate through the list. If any of the permissions are set for the user, return true - // If the requested action has an AND-ed list, iterate through the list. If any of the permissions for the user are not set, turn the check to false. Otherwise return true. - // If the requested action has a permission, check if the user's role has it flagged. If yes, return true - // If we fall through all of the checks, return an exception. + /** + * The check works like this: + * - If the user is a site admin, return true + * - If the requested action has an OR-d list, iterate through the list. If any of the permissions are set for the user, return true + * - If the requested action has an AND-ed list, iterate through the list. If any of the permissions for the user are not set, turn the check to false. Otherwise return true. + * - If the requested action has a permission, check if the user's role has it flagged. If yes, return true + * - If we fall through all of the checks, return an exception. + * + * @param array|null $user + * @param string $controller + * @param string $action + * @param bool $soft If true, instead of exception, HTTP error code is retuned as int. + * @return bool|int + * @throws NotFoundException + * @throws MethodNotAllowedException + * @throws InternalErrorException + */ public function checkAccess($user, $controller, $action, $soft = false) { $controller = lcfirst(Inflector::camelize($controller)); @@ -710,15 +721,12 @@ class ACLComponent extends Component $aclList[$k] = array_change_key_case($v); } $this->__checkLoggedActions($user, $controller, $action); - if ($user['Role']['perm_site_admin']) { + if ($user && $user['Role']['perm_site_admin']) { return true; } if (!isset($aclList[$controller])) { return $this->__error(404, 'Invalid controller.', $soft); } - if ($user['Role']['perm_site_admin']) { - return true; - } if (isset($aclList[$controller][$action]) && !empty($aclList[$controller][$action])) { if (in_array('*', $aclList[$controller][$action])) { return true; diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index a49c3c0b6..cad256bf5 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -1167,17 +1167,12 @@ class EventsController extends AppController $this->set('emptyEvent', $emptyEvent); // remove galaxies tags - $this->loadModel('GalaxyCluster'); $this->loadModel('Taxonomy'); - $cluster_names = $this->GalaxyCluster->find('list', array('fields' => array('GalaxyCluster.tag_name'), 'group' => array('GalaxyCluster.tag_name', 'GalaxyCluster.id'))); foreach ($event['Object'] as $k => $object) { if (isset($object['Attribute'])) { foreach ($object['Attribute'] as $k2 => $attribute) { - foreach ($attribute['AttributeTag'] as $k3 => $attributeTag) { - if (in_array($attributeTag['Tag']['name'], $cluster_names)) { - unset($event['Object'][$k]['Attribute'][$k2]['AttributeTag'][$k3]); - } - } + $this->Event->Attribute->removeGalaxyClusterTags($event['Object'][$k]['Attribute'][$k2]); + $tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']); foreach ($tagConflicts['global'] as $tagConflict) { $warningTagConflicts[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy']; @@ -1190,11 +1185,8 @@ class EventsController extends AppController } } foreach ($event['Attribute'] as $k => $attribute) { - foreach ($attribute['AttributeTag'] as $k2 => $attributeTag) { - if (in_array($attributeTag['Tag']['name'], $cluster_names)) { - unset($event['Attribute'][$k]['AttributeTag'][$k2]); - } - } + $this->Event->Attribute->removeGalaxyClusterTags($event['Attribute'][$k]); + $tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']); foreach ($tagConflicts['global'] as $tagConflict) { $warningTagConflicts[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy']; @@ -1232,8 +1224,8 @@ class EventsController extends AppController } $this->set('event', $event); $dataForView = array( - 'Attribute' => array('attrDescriptions', 'typeDefinitions', 'categoryDefinitions', 'distributionDescriptions', 'distributionLevels', 'shortDist'), - 'Event' => array('fieldDescriptions') + 'Attribute' => array('attrDescriptions' => 'fieldDescriptions', 'distributionDescriptions' => 'distributionDescriptions', 'distributionLevels' => 'distributionLevels', 'shortDist' => 'shortDist'), + 'Event' => array('eventDescriptions' => 'fieldDescriptions', 'analysisDescriptions' => 'analysisDescriptions', 'analysisLevels' => 'analysisLevels') ); foreach ($dataForView as $m => $variables) { if ($m === 'Event') { @@ -1241,8 +1233,8 @@ class EventsController extends AppController } elseif ($m === 'Attribute') { $currentModel = $this->Event->Attribute; } - foreach ($variables as $variable) { - $this->set($variable, $currentModel->{$variable}); + foreach ($variables as $alias => $variable) { + $this->set($alias, $currentModel->{$variable}); } } if (Configure::read('Plugin.Enrichment_services_enable')) { @@ -1507,20 +1499,6 @@ class EventsController extends AppController } $this->params->params['paging'] = array($this->modelClass => $params); $this->set('event', $event); - $dataForView = array( - 'Attribute' => array('attrDescriptions', 'typeDefinitions', 'categoryDefinitions', 'distributionDescriptions', 'distributionLevels'), - 'Event' => array('fieldDescriptions') - ); - foreach ($dataForView as $m => $variables) { - if ($m === 'Event') { - $currentModel = $this->Event; - } elseif ($m === 'Attribute') { - $currentModel = $this->Event->Attribute; - } - foreach ($variables as $variable) { - $this->set($variable, $currentModel->{$variable}); - } - } $extensionParams = array( 'conditions' => array( 'Event.extends_uuid' => $event['Event']['uuid'] diff --git a/app/Lib/cakephp b/app/Lib/cakephp index 5ccb12354..59e12788f 160000 --- a/app/Lib/cakephp +++ b/app/Lib/cakephp @@ -1 +1 @@ -Subproject commit 5ccb12354dfc08ca1b3e0a430e8668bf1610b5d3 +Subproject commit 59e12788fc406ee66180f41e8a2840b841c6051a diff --git a/app/Model/Server.php b/app/Model/Server.php index 7fe9c54a9..a22b8e913 100644 --- a/app/Model/Server.php +++ b/app/Model/Server.php @@ -3226,7 +3226,7 @@ class Server extends AppModel foreach ($serverSettings as $branchKey => &$branchValue) { if (isset($branchValue['branch'])) { foreach ($branchValue as $leafKey => &$leafValue) { - if ($leafValue['level'] == 3 && !(isset($currentSettings[$branchKey][$leafKey]))) { + if ($leafKey !== 'branch' && $leafValue['level'] == 3 && !(isset($currentSettings[$branchKey][$leafKey]))) { continue; } $setting = null; diff --git a/app/View/Elements/formInfo.ctp b/app/View/Elements/formInfo.ctp index 01a87121b..c48083d4c 100644 --- a/app/View/Elements/formInfo.ctp +++ b/app/View/Elements/formInfo.ctp @@ -1 +1 @@ - + diff --git a/app/View/Elements/genericElements/Form/formInfo.ctp b/app/View/Elements/genericElements/Form/formInfo.ctp index 3a60e36e8..ff5dd8d40 100644 --- a/app/View/Elements/genericElements/Form/formInfo.ctp +++ b/app/View/Elements/genericElements/Form/formInfo.ctp @@ -17,12 +17,12 @@ } } echo sprintf( - '', + ' ', h($field['field']) ); ?>