Merge branch '2.4' of https://github.com/MISP/MISP into 2.4

pull/5259/head
chrisr3d 2019-09-28 02:36:54 +02:00
commit 3b11f6f2a2
9 changed files with 81 additions and 21 deletions

View File

@ -159,13 +159,12 @@ class AdminShell extends AppShell
}
}
public function updateWarningLists() {
$result = $this->Galaxy->update();
if ($result) {
echo 'Warning lists updated' . PHP_EOL;
} else {
echo 'Could not update warning lists' . PHP_EOL;
}
public function updateWarningLists()
{
$result = $this->Warninglist->update();
$success = count($result['success']);
$fails = count($result['fails']);
echo "$success warninglists updated, $fails fails" . PHP_EOL;
}
public function updateNoticeLists() {

View File

@ -907,7 +907,7 @@ class ServersController extends AppController
);
$writeableErrors = array(0 => __('OK'), 1 => __('not found'), 2 => __('is not writeable'));
$readableErrors = array(0 => __('OK'), 1 => __('not readable'));
$gpgErrors = array(0 => __('OK'), 1 => __('FAIL: settings not set'), 2 => __('FAIL: Failed to load GnuPG'), 3 => __('FAIL: Issues with the key/passphrase'), 4 => __('FAIL: encrypt failed'));
$gpgErrors = array(0 => __('OK'), 1 => __('FAIL: settings not set'), 2 => __('FAIL: Failed to load GnuPG'), 3 => __('FAIL: Issues with the key/passphrase'), 4 => __('FAIL: sign failed'));
$proxyErrors = array(0 => __('OK'), 1 => __('not configured (so not tested)'), 2 => __('Getting URL via proxy failed'));
$zmqErrors = array(0 => __('OK'), 1 => __('not enabled (so not tested)'), 2 => __('Python ZeroMQ library not installed correctly.'), 3 => __('ZeroMQ script not running.'));
$stixOperational = array(0 => __('Some of the libraries related to STIX are not installed. Make sure that all libraries listed below are correctly installed.'), 1 => __('OK'));
@ -1053,6 +1053,8 @@ class ServersController extends AppController
// get the DB diagnostics
$dbDiagnostics = $this->Server->dbSpaceUsage();
$redisInfo = $this->Server->redisInfo();
$moduleTypes = array('Enrichment', 'Import', 'Export', 'Cortex');
foreach ($moduleTypes as $type) {
$moduleStatus[$type] = $this->Server->moduleDiagnostics($diagnostic_errors, $type);
@ -1063,7 +1065,7 @@ class ServersController extends AppController
$sessionStatus = $this->Server->sessionDiagnostics($diagnostic_errors, $sessionCount);
$this->set('sessionCount', $sessionCount);
$additionalViewVars = array('gpgStatus', 'sessionErrors', 'proxyStatus', 'sessionStatus', 'zmqStatus', 'stixVersion', 'cyboxVersion', 'mixboxVersion', 'maecVersion', 'stix2Version', 'pymispVersion', 'moduleStatus', 'yaraStatus', 'gpgErrors', 'proxyErrors', 'zmqErrors', 'stixOperational', 'stix', 'moduleErrors', 'moduleTypes', 'dbDiagnostics');
$additionalViewVars = array('gpgStatus', 'sessionErrors', 'proxyStatus', 'sessionStatus', 'zmqStatus', 'stixVersion', 'cyboxVersion', 'mixboxVersion', 'maecVersion', 'stix2Version', 'pymispVersion', 'moduleStatus', 'yaraStatus', 'gpgErrors', 'proxyErrors', 'zmqErrors', 'stixOperational', 'stix', 'moduleErrors', 'moduleTypes', 'dbDiagnostics', 'redisInfo');
}
// check whether the files are writeable
$writeableDirs = $this->Server->writeableDirsDiagnostics($diagnostic_errors);

View File

@ -36,7 +36,7 @@ class AppModel extends Model
public $inserted_ids = array();
private $__redisConnection = false;
private $__redisConnection = null;
private $__profiler = array();
@ -1824,14 +1824,19 @@ class AppModel extends Model
return preg_match('@^([a-z0-9_.]+[a-z0-9_.\- ]*[a-z0-9_.\-]|[a-z0-9_.])+$@i', $filename);
}
public function setupRedis()
/**
* Similar method as `setupRedis`, but this method throw exception if Redis cannot be reached.
* @return Redis
* @throws Exception
*/
public function setupRedisWithException()
{
if ($this->__redisConnection) {
return $this->__redisConnection;
}
if (!class_exists('Redis')) {
return false;
throw new Exception("Class Redis doesn't exists.");
}
$host = Configure::read('MISP.redis_host') ?: '127.0.0.1';
@ -1841,16 +1846,36 @@ class AppModel extends Model
$redis = new Redis();
if (!$redis->connect($host, $port)) {
return false;
throw new Exception("Could not connect to Redis: {$redis->getLastError()}");
}
if (!empty($pass)) {
$redis->auth($pass);
if (!$redis->auth($pass)) {
throw new Exception("Could not authenticate to Redis: {$redis->getLastError()}");
}
}
$redis->select($database);
if (!$redis->select($database)) {
throw new Exception("Could not select Redis database $database: {$redis->getLastError()}");
}
$this->__redisConnection = $redis;
return $redis;
}
/**
* Method for backward compatibility.
* @deprecated
* @see AppModel::setupRedisWithException
* @return bool|Redis
*/
public function setupRedis()
{
try {
return $this->setupRedisWithException();
} catch (Exception $e) {
return false;
}
}
public function getKafkaPubTool()
{
if (!$this->loadedKafkaPubTool) {

View File

@ -4214,7 +4214,24 @@ class Server extends AppModel
}
return $result;
}
}
public function redisInfo()
{
$output = array(
'extensionVersion' => phpversion('redis'),
'connection' => false,
);
try {
$redis = $this->setupRedisWithException();
$output['connection'] = true;
$output = array_merge($output, $redis->info());
} catch (Exception $e) {
$output['connection_error'] = $e->getMessage();
}
return $output;
}
public function writeableDirsDiagnostics(&$diagnostic_errors)

View File

@ -32,7 +32,7 @@
<div class="pull-right" style="position:relative;padding-top:9px;z-index:2;">
<?php
if (Configure::read('MISP.footer_logo')) {
if (Configure::read('MISP.footer_logo')) echo $this->Html->image('custom/' . h(Configure::read('MISP.footer_logo')), array('alt' => 'Footer Logo', 'onerror' => "this.style.display='none';", 'style' => 'height:24px'));
echo $this->Html->image('custom/' . h(Configure::read('MISP.footer_logo')), array('alt' => 'Footer Logo', 'onerror' => "this.style.display='none';", 'style' => 'height:24px'));
}
?>
</div>

View File

@ -188,7 +188,7 @@
'requirement' => $isAdmin
),
array(
'text' => __('Decaying Models'),
'text' => __('List Decaying Models'),
'url' => '/decayingModel/index',
),
array(

View File

@ -225,6 +225,19 @@
));
echo '</div>';
?>
<h3><?= __("Redis info") ?></h3>
<div style="background-color:#f7f7f9;width:400px;">
<b><?= __('PHP extension version') ?>:</b> <?= $redisInfo['extensionVersion'] ?: ('<span class="red bold">' . __('Not installed.') . '</span>') ?><br>
<?php if ($redisInfo['connection']): ?>
<b><?= __('Redis version') ?>:</b> <?= $redisInfo['redis_version'] ?><br>
<b><?= __('Memory allocator') ?>:</b> <?= $redisInfo['mem_allocator'] ?><br>
<b><?= __('Memory usage') ?>:</b> <?= $redisInfo['used_memory_human'] ?>B<br>
<b><?= __('Peak memory usage') ?>:</b> <?= $redisInfo['used_memory_peak_human'] ?>B<br>
<b><?= __('Total system memory') ?>:</b> <?= $redisInfo['total_system_memory_human'] ?>B
<?php elseif ($redisInfo['extensionVersion']): ?>
<span class="red bold">Redis is not available. <?= $redisInfo['connection_error'] ?></span>
<?php endif; ?>
</div>
<h3><?php echo __('Advanced attachment handler');?></h3>
<?php echo __('The advanced attachment tools are used by the add attachment functionality to extract additional data about the uploaded sample.');?>
<div style="background-color:#f7f7f9;width:400px;">

View File

@ -2,12 +2,12 @@
<?php
echo $this->Session->flash('auth');
?>
<table style="width:1200px;margin-left:auto;margin-right:auto;">
<table style="margin-left:auto;margin-right:auto;">
<tr>
<td style="text-align:right;width:250px;padding-right:50px">
<?php if (Configure::read('MISP.welcome_logo')) echo $this->Html->image('custom/' . h(Configure::read('MISP.welcome_logo')), array('alt' => __('Logo'), 'onerror' => "this.style.display='none';")); ?>
</td>
<td style="width:450px">
<td style="width:460px">
<span style="font-size:18px;">
<?php
if (Configure::read('MISP.welcome_text_top')) {
@ -15,7 +15,7 @@
}
?>
</span><br /><br />
<div style="width:100%;">
<div>
<?php if (Configure::read('MISP.main_logo') && file_exists(APP . '/webroot/img/custom/' . Configure::read('MISP.main_logo'))): ?>
<img src="<?php echo $baseurl?>/img/custom/<?php echo h(Configure::read('MISP.main_logo'));?>" style=" display:block; margin-left: auto; margin-right: auto;" />
<?php else: ?>
@ -34,7 +34,7 @@
endif;
echo $this->Form->create('User');
?>
<legend style="width:450px;"><?php echo __('Login');?></legend>
<legend><?php echo __('Login');?></legend>
<?php
echo $this->Form->input('email', array('autocomplete' => 'off', 'autofocus'));
echo $this->Form->input('password', array('autocomplete' => 'off'));

View File

@ -2390,3 +2390,7 @@ table tr:hover .down-expand-button {
.large-left-margin {
margin-left:8px;
}
#notice_message {
margin: 10px;
}