Merge branch '2.4' into 2.4.49

Conflicts:
	app/Controller/AppController.php
pull/1387/head
Iglocska 2016-07-22 13:29:27 +02:00
commit e65bc0db53
17 changed files with 219 additions and 135 deletions

View File

@ -137,7 +137,7 @@ sudo cp /var/www/MISP/INSTALL/apache.misp.ssl /etc/apache2/sites-available/misp-
# If a valid SSL certificate is not already created for the server, create a self-signed certificate:
openssl req -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/C=<Country>/ST=<State>/L=<Locality>/O=<Organization>/OU=<Organizational Unit Name>/CN=<QDN.here>/emailAddress=admin@<your.FQDN.here>" \
-subj "/C=<Country>/ST=<State>/L=<Locality>/O=<Organization>/OU=<Organizational Unit Name>/CN=<your.FQDN.here>/emailAddress=admin@<your.FQDN.here>" \
-keyout /etc/ssl/private/misp.local.key -out /etc/ssl/private/misp.local.crt
# Otherwise, copy the SSLCertificateFile, SSLCertificateKeyFile, and SSLCertificateChainFile to /etc/ssl/private/. (Modify path and config to fit your environment)

View File

@ -718,7 +718,7 @@ CREATE TABLE IF NOT EXISTS `users` (
`authkey` varchar(40) COLLATE utf8_bin DEFAULT NULL,
`invited_by` int(11) NOT NULL DEFAULT 0,
`gpgkey` longtext COLLATE utf8_bin,
`certif_public` longtext COLLATE utf8_bin NOT NULL DEFAULT '',
`certif_public` longtext COLLATE utf8_bin,
`nids_sid` int(15) NOT NULL DEFAULT 0,
`termsaccepted` tinyint(1) NOT NULL DEFAULT 0,
`newsread` int(11) unsigned DEFAULT 0,

View File

@ -4,7 +4,7 @@ $config = array (
'Security' =>
array (
'level' => 'medium',
'salt' => 'Rooraenietu8Eeyo<Qu2eeNfterd-dd+',
'salt' => '',
'cipherSeed' => '',
//'auth'=>array('CertAuth.Certificate'), // additional authentication methods
),

View File

@ -1,7 +1,11 @@
<?php
class UserInitShell extends AppShell {
public $uses = array('User', 'Role', 'Organisation');
public $uses = array('User', 'Role', 'Organisation', 'Server');
public function main() {
if (!Configure::read('Security.salt')) {
$this->loadModel('Server');
$this->Server->serverSettingsSaveValue('Security.salt', $this->User->generateRandomPassword(32));
}
$this->Role->Behaviors->unload('SysLogLogable.SysLogLogable');
$this->User->Behaviors->unload('SysLogLogable.SysLogLogable');
// populate the DB with the first role (site admin) if it's empty

View File

@ -46,6 +46,8 @@ class AppController extends Controller {
public $helpers = array('Utility');
private $__jsVersion = '2.4.49';
public $phpmin = '5.5.9';
public $phprec = '5.6.0';
// Used for _isAutomation(), a check that returns true if the controller & action combo matches an action that is a non-xml and non-json automation method
// This is used to allow authentication via headers for methods not covered by _isRest() - as that only checks for JSON and XML formats
@ -81,6 +83,11 @@ class AppController extends Controller {
$this->loadModel('User');
$auth_user_fields = $this->User->describeAuthFields();
//if fresh installation (salt empty) generate a new salt
if (!Configure::read('Security.salt')) {
$this->loadModel('Server');
$this->Server->serverSettingsSaveValue('Security.salt', $this->User->generateRandomPassword(32));
}
// check if Apache provides kerberos authentication data
$envvar = Configure::read('ApacheSecureAuth.apacheEnv');
if (isset($_SERVER[$envvar])) {
@ -270,7 +277,7 @@ class AppController extends Controller {
}
if ($this->Session->check(AuthComponent::$sessionKey)) {
if (!$this->Auth->user('termsaccepted') && (!in_array($this->request->here, array($base_dir.'/users/terms', $base_dir.'/users/logout', $base_dir.'/users/login')))) {
if (!empty(Configure::read('MISP.terms_file')) && !$this->Auth->user('termsaccepted') && (!in_array($this->request->here, array($base_dir.'/users/terms', $base_dir.'/users/logout', $base_dir.'/users/login')))) {
if ($this->_isRest()) throw new MethodNotAllowedException('You have not accepted the terms of use yet, please log in via the web interface and accept them.');
$this->redirect(array('controller' => 'users', 'action' => 'terms', 'admin' => false));
} else if ($this->Auth->user('change_pw') && (!in_array($this->request->here, array($base_dir.'/users/terms', $base_dir.'/users/change_pw', $base_dir.'/users/logout', $base_dir.'/users/login')))) {

View File

@ -2312,7 +2312,8 @@ class AttributesController extends AppController {
$attribute = $this->Attribute->fetchAttributes($this->Auth->user(), array('conditions' => array('Attribute.id' => $id)));
if (empty($attribute)) throw new NotFoundException('Invalid Attribute');
$this->loadModel('Server');
$modules = $this->Server->getEnabledModules();
$this->loadModel('Module');
$modules = $this->Module->getEnabledModules();
$validTypes = array();
if (isset($modules['hover_type'][$attribute[0]['Attribute']['type']])) {
$validTypes = $modules['hover_type'][$attribute[0]['Attribute']['type']];
@ -2337,10 +2338,12 @@ class AttributesController extends AppController {
$data = array('module' => $type, $attribute[0]['Attribute']['type'] => $attribute[0]['Attribute']['value']);
if (!empty($options)) $data['config'] = $options;
$data = json_encode($data);
try {
$response = $httpSocket->post($url . ':' . $port . '/query', $data);
$result = json_decode($response->body, true);
} catch (Exception $e) {
$result = $this->Module->queryModuleServer('/query', $data, true);
if ($result) {
if (!is_array($result)) {
$resultArray[] = array($type => $result);
}
} else {
$resultArray[] = array($type => 'Enrichment service not reachable.');
continue;
}

View File

@ -728,8 +728,8 @@ class EventsController extends AppController {
}
}
if (Configure::read('Plugin.Enrichment_services_enable')) {
$this->loadModel('Server');
$modules = $this->Server->getEnabledModules();
$this->loadModel('Module');
$modules = $this->Module->getEnabledModules();
$this->set('modules', $modules);
}
$this->set('deleted', (isset($this->params['named']['deleted']) && $this->params['named']['deleted']) ? true : false);
@ -835,8 +835,8 @@ class EventsController extends AppController {
}
if (Configure::read('Plugin.Enrichment_services_enable')) {
$this->loadModel('Server');
$modules = $this->Server->getEnabledModules();
$this->loadModel('Module');
$modules = $this->Module->getEnabledModules();
$this->set('modules', $modules);
}
$this->set('contributors', $contributors);
@ -1365,6 +1365,9 @@ class EventsController extends AppController {
throw new MethodNotAllowedException('You don\'t have the permission to do that.');
}
}
$success = true;
$message = '';
$errors = array();
// only allow form submit CSRF protection.
if ($this->request->is('post') || $this->request->is('put')) {
// Performs all the actions required to publish an event
@ -1372,11 +1375,12 @@ class EventsController extends AppController {
if (!Configure::read('MISP.background_jobs')) {
if (!is_array($result)) {
// redirect to the view event page
$this->Session->setFlash(__('Event published without alerts.', true));
$message = 'Event published without alerts';
} else {
$lastResult = array_pop($result);
$resultString = (count($result) > 0) ? implode(', ', $result) . ' and ' . $lastResult : $lastResult;
$this->Session->setFlash(__(sprintf('Event published but not pushed to %s, re-try later. If the issue persists, make sure that the correct sync user credentials are used for the server link and that the sync user on the remote server has authentication privileges.', $resultString), true));
$errors['failed_servers'] = $result;
$message = sprintf('Event published but not pushed to %s, re-try later. If the issue persists, make sure that the correct sync user credentials are used for the server link and that the sync user on the remote server has authentication privileges.', $resultString);
}
} else {
// update the DB to set the published flag
@ -1385,9 +1389,21 @@ class EventsController extends AppController {
$event['Event']['published'] = 1;
$event['Event']['publish_timestamp'] = time();
$this->Event->save($event, array('fieldList' => $fieldList));
$this->Session->setFlash(__('Job queued.'));
$message = 'Job queued';
}
if ($this->_isRest()) {
$this->set('name', 'Publish');
$this->set('message', $message);
if (!empty($errors)) {
$this->set('errors', $errors);
}
$this->set('url', '/events/alert/' . $id);
$this->set('id', $id);
$this->set('_serialize', array('name', 'message', 'url', 'id', 'errors'));
} else {
$this->Session->setFlash($message);
$this->redirect(array('action' => 'view', $id));
}
$this->redirect(array('action' => 'view', $id));
} else {
$this->set('id', $id);
$this->set('type', 'publish');
@ -1414,6 +1430,9 @@ class EventsController extends AppController {
throw new MethodNotAllowedException('You don\'t have the permission to do that.');
}
}
$success = true;
$message = '';
$errors = array();
// only allow form submit CSRF protection
if ($this->request->is('post') || $this->request->is('put')) {
// send out the email
@ -1424,30 +1443,47 @@ class EventsController extends AppController {
if (!is_array($result)) {
// redirect to the view event page
if (Configure::read('MISP.background_jobs')) {
$this->Session->setFlash(__('Job queued.', true));
$message = 'Job queued.';
} else {
$this->Session->setFlash(__('Email sent to all participants.', true));
$message = 'Email sent to all participants.';
}
} else {
$lastResult = array_pop($result);
$resultString = (count($result) > 0) ? implode(', ', $result) . ' and ' . $lastResult : $lastResult;
$this->Session->setFlash(__(sprintf('Not published given no connection to %s but email sent to all participants.', $resultString), true));
$errors['failed_servers'] = $result;
$message = sprintf('Not published given no connection to %s but email sent to all participants.', $resultString);
}
} else if (!is_bool($emailResult)) {
// Performs all the actions required to publish an event
$result = $this->Event->publishRouter($id, null, $this->Auth->user());
if (!is_array($result)) {
// redirect to the view event page
$this->Session->setFlash(__('Published but no email sent given GnuPG is not configured.', true));
$message = 'Published but no email sent given GnuPG is not configured.';
$errors['GnuPG'] = 'GnuPG not set up.';
} else {
$lastResult = array_pop($result);
$resultString = (count($result) > 0) ? implode(', ', $result) . ' and ' . $lastResult : $lastResult;
$this->Session->setFlash(__(sprintf('Not published given no connection to %s but no email sent given GnuPG is not configured.', $resultString), true));
$errors['failed_servers'] = $result;
$errors['GnuPG'] = 'GnuPG not set up.';
$message = sprintf('Not published given no connection to %s but no email sent given GnuPG is not configured.', $resultString);
}
} else {
$this->Session->setFlash(__('Sending of email failed', true), 'default', array(), 'error');
$message = 'Sending of email failed';
$errors['email'] = 'The sending of emails failed.';
}
if ($this->_isRest()) {
$this->set('name', 'Alert');
$this->set('message', $message);
if (!empty($errors)) {
$this->set('errors', $errors);
}
$this->set('url', '/events/alert/' . $id);
$this->set('id', $id);
$this->set('_serialize', array('name', 'message', 'url', 'id', 'errors'));
} else {
$this->Session->setFlash($message);
$this->redirect(array('action' => 'view', $id));
}
$this->redirect(array('action' => 'view', $id));
} else {
$this->set('id', $id);
$this->set('type', 'alert');
@ -3537,8 +3573,8 @@ class EventsController extends AppController {
$attribute = $this->Event->Attribute->fetchAttributes($this->Auth->user(), array('conditions' => array('Attribute.id' => $attribute_id)));
if (empty($attribute)) throw new MethodNotAllowedException('Attribute not found or you are not authorised to see it.');
if ($this->request->is('ajax')) {
$this->loadModel('Server');
$modules = $this->Server->getEnabledModules();
$this->loadModel('Module');
$modules = $this->Module->getEnabledModules();
if (!is_array($modules) || empty($modules)) throw new MethodNotAllowedException('No valid enrichment options found for this attribute.');
$temp = array();
foreach ($modules['modules'] as &$module) {
@ -3550,8 +3586,8 @@ class EventsController extends AppController {
foreach (array('attribute_id', 'modules') as $viewVar) $this->set($viewVar, $$viewVar);
$this->render('ajax/enrichmentChoice');
} else {
$this->loadModel('Server');
$modules = $this->Server->getEnabledModules();
$this->loadModel('Module');
$modules = $this->Module->getEnabledModules();
if (!is_array($modules) || empty($modules)) throw new MethodNotAllowedException('No valid enrichment options found for this attribute.');
$options = array();
$found = false;
@ -3565,20 +3601,11 @@ class EventsController extends AppController {
}
}
}
if (!$found) throw new MethodNotAllowedException('No valid enrichment options found for this attribute.');
$url = Configure::read('Plugin.Enrichment_services_url') ? Configure::read('Plugin.Enrichment_services_url') : $this->Server->serverSettings['Plugin']['Enrichment_services_url']['value'];
$port = Configure::read('Plugin.Enrichment_services_port') ? Configure::read('Plugin.Enrichment_services_port') : $this->Server->serverSettings['Plugin']['Enrichment_services_port']['value'];
App::uses('HttpSocket', 'Network/Http');
$httpSocket = new HttpSocket();
$data = array('module' => $module, $attribute[0]['Attribute']['type'] => $attribute[0]['Attribute']['value'], 'event_id' => $attribute[0]['Attribute']['event_id']);
if (!empty($options)) $data['config'] = $options;
$data = json_encode($data);
try {
$response = $httpSocket->post($url . ':' . $port . '/query', $data);
$result = json_decode($response->body, true);
} catch (Exception $e) {
return 'Enrichment service not reachable.';
}
$result = $this->Module->queryModuleServer('/query', $data);
if (!$result) return 'Enrichment service not reachable.';
if (isset($result['error'])) $this->Session->setFlash($result['error']);
if (!is_array($result)) throw new Exception($result);
$resultArray = array();

View File

@ -690,7 +690,7 @@ class ServersController extends AppController {
)
);
foreach ($phpSettings as $setting => &$settingArray) {
$settingArray['value'] = ini_get($setting);
if ($settingArray['unit']) $settingArray['value'] = intval(rtrim($settingArray['value'], $settingArray['unit']));
@ -752,6 +752,9 @@ class ServersController extends AppController {
$this->set('workerIssueCount', $workerIssueCount);
$priorityErrorColours = array(0 => 'red', 1 => 'yellow', 2 => 'green');
$this->set('priorityErrorColours', $priorityErrorColours);
$this->set('phpversion', phpversion());
$this->set('phpmin', $this->phpmin);
$this->set('phprec', $this->phprec);
}
}

View File

@ -356,7 +356,7 @@ class AppModel extends Model {
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
break;
case '2.4.39':
$sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `gpgkey`;";
$sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin AFTER `gpgkey`;";
$sqlArray[] = 'ALTER TABLE `logs` MODIFY COLUMN `title` text, MODIFY COLUMN `change` text;';
break;
case '2.4.40':

View File

@ -1896,7 +1896,7 @@ class Event extends AppModel {
// edit timestamp newer than existing event timestamp
if (!isset($data['Event']['timestamp']) || $data['Event']['timestamp'] > $existingEvent['Event']['timestamp']) {
if (!isset($data['Event']['timestamp'])) $data['Event']['timestamp'] = $date;
if ($data['Event']['distribution'] == 4) {
if (isset($data['Event']['distribution']) && $data['Event']['distribution'] == 4) {
if (!isset($data['Event']['SharingGroup'])) {
if (!isset($data['Event']['sharing_group_id'])) return(array('error' => 'Event could not be saved: Sharing group chosen as the distribution level, but no sharing group specified. Make sure that the event includes a valid sharing_group_id or change to a different distribution level.'));
if (!$this->SharingGroup->checkIfAuthorised($user, $data['Event']['sharing_group_id'])) return(array('error' => 'Event could not be saved: Invalid sharing group or you don\'t have access to that sharing group.'));
@ -1912,7 +1912,7 @@ class Event extends AppModel {
if ($existingEvent['Event']['orgc_id'] === $user['org_id']
|| ($user['Role']['perm_sync'] && $existingEvent['Event']['locked']) || $user['Role']['perm_site_admin']) {
if ($user['Role']['perm_sync']) {
if ($data['Event']['distribution'] == 4 && !$this->SharingGroup->checkIfAuthorised($user, $data['Event']['sharing_group_id'])) {
if (isset($data['Event']['distribution']) && $data['Event']['distribution'] == 4 && !$this->SharingGroup->checkIfAuthorised($user, $data['Event']['sharing_group_id'])) {
return (array('error' => 'Event could not be saved: The sync user has to have access to the sharing group in order to be able to edit it.'));
}
}

View File

@ -5,60 +5,75 @@ class Module extends AppModel {
public $useTable = false;
public function getEnrichmentModules() {
if (!Configure::read('Plugin.Enrichment_services_enable')) return 'Enrichment service not enabled.';
$url = Configure::read('Plugin.Enrichment_services_url') ? Configure::read('Plugin.Enrichment_services_url') : $this->serverSettings['Plugin']['Enrichment_services_url']['value'];
$port = Configure::read('Plugin.Enrichment_services_port') ? Configure::read('Plugin.Enrichment_services_port') : $this->serverSettings['Plugin']['Enrichment_services_port']['value'];
App::uses('HttpSocket', 'Network/Http');
$httpSocket = new HttpSocket();
try {
$response = $httpSocket->get($url . ':' . $port . '/modules');
} catch (Exception $e) {
return 'Enrichment service not reachable.';
}
$modules = json_decode($response->body, true);
public function getModules($type = false) {
$modules = $this->queryModuleServer('/modules');
if (!$modules) return 'Module service not reachable.';
if (!empty($modules)) {
$result = array('modules' => $modules);
foreach ($modules as &$module) {
if ($module['type'] !== 'expansion') continue;
foreach ($module['mispattributes']['input'] as $attribute) {
$result['types'][$attribute][] = $module['name'];
}
}
return $result;
} else return 'The enrichment service reports that it found no enrichment modules.';
} else return 'The module service reports that it found no modules.';
}
public function getEnabledModules() {
$modules = $this->getEnrichmentModules();
public function getEnabledModules($type = false) {
$modules = $this->getModules($type);
if (is_array($modules)) {
foreach ($modules['modules'] as $k => &$module) {
if (!Configure::read('Plugin.Enrichment_' . $module['name'] . '_enabled')) {
if (!Configure::read('Plugin.Enrichment_' . $module['name'] . '_enabled') || ($type && in_array($type, $module['meta']['module-type']))) {
unset($modules['modules'][$k]);
}
}
}
} else return 'The modules system reports that it found no suitable modules.';
if (!isset($modules) || empty($modules)) $modules = array();
if (isset($modules['modules']) && !empty($modules['modules'])) $modules['modules'] = array_values($modules['modules']);
$types = array();
$hover_types = array();
if (!is_array($modules)) return array();
foreach ($modules['modules'] as $temp) {
foreach ($temp['mispattributes']['input'] as $input) {
if (!isset($temp['meta']['module-type']) || in_array('expansion', $temp['meta']['module-type'])) $types[$input][] = $temp['name'];
if (isset($temp['meta']['module-type']) && in_array('hover', $temp['meta']['module-type'])) $hover_types[$input][] = $temp['name'];
if (isset($temp['meta']['module-type']) && in_array('import', $temp['meta']['module-type'])) $modules['import'] = $temp['name'];
else if (isset($temp['meta']['module-type']) && in_array('export', $temp['meta']['module-type'])) $modules['export'] = $temp['name'];
else {
foreach ($temp['mispattributes']['input'] as $input) {
if (!isset($temp['meta']['module-type']) || in_array('expansion', $temp['meta']['module-type'])) $modules['types'][$input][] = $temp['name'];
if (isset($temp['meta']['module-type']) && in_array('hover', $temp['meta']['module-type'])) $modules['hover_type'][$input][] = $temp['name'];
}
}
}
$modules['types'] = $types;
$modules['hover_type'] = $hover_types;
return $modules;
}
public function sendRequest() {
private function __getModuleServer() {
$this->Server = ClassRegistry::init('Server');
if (!Configure::read('Plugin.Enrichment_services_enable')) return false;
$url = Configure::read('Plugin.Enrichment_services_url') ? Configure::read('Plugin.Enrichment_services_url') : $this->Server->serverSettings['Plugin']['Enrichment_services_url']['value'];
$port = Configure::read('Plugin.Enrichment_services_port') ? Configure::read('Plugin.Enrichment_services_port') : $this->Server->serverSettings['Plugin']['Enrichment_services_port']['value'];
return $url . ':' . $port;
}
public function queryModuleServer($uri, $post = false, $hover = false) {
$url = $this->__getModuleServer();
if (!$url) return false;
App::uses('HttpSocket', 'Network/Http');
if ($hover) {
$httpSocket = new HttpSocket(array('timeout' => Configure::read('Plugin.Enrichment_hover_timeout') ? Configure::read('Plugin.Enrichment_hover_timeout') : 2));
} else {
$httpSocket = new HttpSocket(array('timeout' => Configure::read('Plugin.Enrichment_timeout') ? Configure::read('Plugin.Enrichment_timeout') : 5));
}
try {
if ($post) $response = $httpSocket->post($url . $uri, $post);
else $response = $httpSocket->get($url . $uri);
return json_decode($response->body, true);
} catch (Exception $e) {
return false;
}
}
public function queryModule() {
public function getModuleSettings() {
$modules = $this->getModules();
$result = array();
if (!empty($modules['modules'])) {
foreach ($modules['modules'] as $module) {
$result[$module['name']][0] = array('name' => 'enabled', 'type' => 'boolean');
if (isset($module['meta']['config'])) foreach ($module['meta']['config'] as $conf) $result[$module['name']][] = array('name' => $conf, 'type' => 'string');
}
}
return $result;
}
}

View File

@ -1034,6 +1034,14 @@ class Server extends AppModel {
'test' => 'testBool',
'type' => 'boolean'
),
'Enrichment_timeout' => array(
'level' => 1,
'description' => 'Set a timeout for the enrichment services',
'value' => 5,
'errorMessage' => '',
'test' => 'testForEmpty',
'type' => 'numeric'
),
'Enrichment_hover_enable' => array(
'level' => 0,
'description' => 'Enable/disable the hover over information retrieved from the enrichment modules',
@ -1042,6 +1050,14 @@ class Server extends AppModel {
'test' => 'testBool',
'type' => 'boolean'
),
'Enrichment_hover_timeout' => array(
'level' => 1,
'description' => 'Set a timeout for the hover services',
'value' => 2,
'errorMessage' => '',
'test' => 'testForEmpty',
'type' => 'numeric'
),
'CustomAuth_custom_password_reset' => array(
'level' => 2,
'description' => 'Provide your custom authentication users with an external URL to the authentication system to reset their passwords.',
@ -1739,9 +1755,10 @@ class Server extends AppModel {
}
public function getCurrentServerSettings() {
$this->Module = ClassRegistry::init('Module');
$serverSettings = $this->serverSettings;
if (Configure::read('Plugin.Enrichment_services_enable')) {
$results = $this->__getEnrichmentSettings();
$results = $this->Module->getModuleSettings();
foreach ($results as $module => $data) {
foreach ($data as $result) {
$setting = array('level' => 1, 'errorMessage' => '');
@ -1764,10 +1781,11 @@ class Server extends AppModel {
}
public function serverSettingsRead($unsorted = false) {
$this->Module = ClassRegistry::init('Module');
$serverSettings = $this->getCurrentServerSettings();
$currentSettings = Configure::read();
if (Configure::read('Plugin.Enrichment_services_enable')) {
$results = $this->__getEnrichmentSettings();
$results = $this->Module->getModuleSettings();
foreach ($results as $module => $data) {
foreach ($data as $result) {
$setting = array('level' => 1, 'errorMessage' => '');
@ -2888,53 +2906,4 @@ class Server extends AppModel {
}
return $validServers;
}
public function getEnrichmentModules() {
if (!Configure::read('Plugin.Enrichment_services_enable')) return 'Enrichment service not enabled.';
$url = Configure::read('Plugin.Enrichment_services_url') ? Configure::read('Plugin.Enrichment_services_url') : $this->serverSettings['Plugin']['Enrichment_services_url']['value'];
$port = Configure::read('Plugin.Enrichment_services_port') ? Configure::read('Plugin.Enrichment_services_port') : $this->serverSettings['Plugin']['Enrichment_services_port']['value'];
App::uses('HttpSocket', 'Network/Http');
$httpSocket = new HttpSocket();
try {
$response = $httpSocket->get($url . ':' . $port . '/modules');
} catch (Exception $e) {
return 'Enrichment service not reachable.';
}
$modules = json_decode($response->body, true);
if (!empty($modules)) {
$result = array('modules' => $modules);
foreach ($modules as &$module) {
if ($module['type'] !== 'expansion') continue;
foreach ($module['mispattributes']['input'] as $attribute) {
$result['types'][$attribute][] = $module['name'];
}
}
return $result;
} else return 'The enrichment service reports that it found no enrichment modules.';
}
public function getEnabledModules() {
$modules = $this->getEnrichmentModules();
if (is_array($modules)) {
foreach ($modules['modules'] as $k => &$module) {
if (!Configure::read('Plugin.Enrichment_' . $module['name'] . '_enabled')) {
unset($modules['modules'][$k]);
}
}
}
if (!isset($modules) || empty($modules)) $modules = array();
if (isset($modules['modules']) && !empty($modules['modules'])) $modules['modules'] = array_values($modules['modules']);
$types = array();
$hover_types = array();
if (!is_array($modules)) return array();
foreach ($modules['modules'] as $temp) {
foreach ($temp['mispattributes']['input'] as $input) {
if (!isset($temp['meta']['module-type']) || in_array('expansion', $temp['meta']['module-type'])) $types[$input][] = $temp['name'];
if (isset($temp['meta']['module-type']) && in_array('hover', $temp['meta']['module-type'])) $hover_types[$input][] = $temp['name'];
}
}
$modules['types'] = $types;
$modules['hover_type'] = $hover_types;
return $modules;
}
}

View File

@ -431,8 +431,7 @@ class User extends AppModel {
return $key;
}
public function generateRandomPassword() {
$length = 12;
public function generateRandomPassword($length = 12) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+=!@#$%&*()<>/?';
$charLen = strlen($characters) - 1;
$key = '';

View File

@ -253,7 +253,7 @@
else $editable = '';
?>
<div id = "<?php echo $currentType; ?>_<?php echo $object['id']; ?>_value_solid" class="inline-field-solid" <?php echo $editable; ?>>
<span <?php if (Configure::read('Plugin.Enrichment_hover_enable') && isset($modules) && isset($modules['hover_type'][$object['type']])) echo 'onMouseOver="hoverModuleExpand(\'' . $currentType . '\', \'' . $object['id'] . '\');";'?>>
<span <?php if (Configure::read('Plugin.Enrichment_hover_enable') && isset($modules) && isset($modules['hover_type'][$object['type']])) echo 'class="eventViewAttributeHover" data-object-type="' . h($currentType) . '" data-object-id="' . h($object['id']) . '"'?>>
<?php
$sigDisplay = $object['value'];
if ('attachment' == $object['type'] || 'malware-sample' == $object['type'] ) {
@ -506,6 +506,7 @@ attributes or the appropriate distribution level. If you think there is a mistak
<script type="text/javascript">
var currentUri = "<?php echo isset($currentUri) ? h($currentUri) : '/events/viewEventAttributes/' . h($event['Event']['id']); ?>";
var ajaxResults = [];
var timer;
var deleted = <?php echo (isset($deleted) && $deleted) ? 'true' : 'false';?>;
$(document).ready(function(){
popoverStartup();

View File

@ -76,6 +76,19 @@
?>
</div>
<h3>PHP Settings</h3>
<?php
$phpcolour = 'green';
$phptext = 'Up to date';
if (version_compare($phpversion, $phprec) < 1) {
$phpcolour = 'orange';
$phptext = 'Update highly recommended';
if (version_compare($phpversion, $phpmin) < 1) {
$phpcolour = 'red';
$phptext = 'Version unsupported, update ASAP';
}
}
?>
<p><span class="bold">PHP Version (><?php echo $phprec; ?> recommended): </span><span class="<?php echo $phpcolour; ?>"><?php echo h($phpversion) . ' (' . $phptext . ')';?></span></p>
<p>The following settings might have a negative impact on certain functionalities of MISP with their current and recommended minimum settings. You can adjust these in your php.ini. Keep in mind that the recommendations are not requirements, just recommendations. Depending on usage you might want to go beyond the recommended values.</p>
<?php
foreach ($phpSettings as $settingName => &$phpSetting):

@ -1 +1 @@
Subproject commit 24c2cad8d8d537544d5af6e4aa62758be0b24ab5
Subproject commit ea8d785e58eac3eab8f7335fb7a41c5c4e69c819

View File

@ -2442,3 +2442,46 @@ function hoverModuleExpand(type, id) {
});
}
}
function runHoverLookup(type, id) {
$.ajax({
success:function (html) {
ajaxResults[type + "_" + id] = html;
$('.popover').remove();
$('#' + type + '_' + id + '_container').popover({
title: 'Lookup results:',
content: html,
placement: 'left',
html: true,
trigger: 'hover',
container: 'body'
}).popover('show');
},
cache: false,
url:"/" + type + "s/hoverEnrichment/" + id,
});
}
$(".eventViewAttributeHover").mouseenter(function() {
$('.popover').remove();
type = $(this).attr('data-object-type');
id = $(this).attr('data-object-id');
if (type + "_" + id in ajaxResults) {
$('#' + type + '_' + id + '_container').popover({
title: 'Lookup results:',
content: ajaxResults[type + "_" + id],
placement: 'left',
html: true,
trigger: 'hover',
container: 'body'
}).popover('show');
} else {
timer = setTimeout(function() {
runHoverLookup(type, id)
},
500
);
}
}).mouseleave(function() {
clearTimeout(timer);
});