fix: Fixed an issue where the diagnostics complained about STIX not being installed if the stixtest.py was not readable

pull/1709/head
Iglocska 2016-11-27 11:39:03 +01:00
parent 8f2eafb4a0
commit 6df592b6e0
4 changed files with 70 additions and 26 deletions

View File

@ -611,7 +611,8 @@ class ServersController extends AppController {
'Security' => array('count' => 0, 'errors' => 0, 'severity' => 5),
'Plugin' => array('count' => 0, 'errors' => 0, 'severity' => 5)
);
$writeableErrors = array(0 => 'OK', 1 => 'doesn\'t exist', 2 => 'is not writeable');
$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 GPG', 3 => 'FAIL: Issues with the key/passphrase', 4 => 'FAIL: encrypt 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.');
@ -735,9 +736,10 @@ class ServersController extends AppController {
// check whether the files are writeable
$writeableDirs = $this->Server->writeableDirsDiagnostics($diagnostic_errors);
$writeableFiles = $this->Server->writeableFilesDiagnostics($diagnostic_errors);
$readableFiles = $this->Server->readableFilesDiagnostics($diagnostic_errors);
$viewVars = array(
'diagnostic_errors', 'tabs', 'tab', 'issues', 'finalSettings', 'writeableErrors', 'writeableDirs', 'writeableFiles'
'diagnostic_errors', 'tabs', 'tab', 'issues', 'finalSettings', 'writeableErrors', 'readableErrors', 'writeableDirs', 'writeableFiles', 'readableFiles'
);
$viewVars = array_merge($viewVars, $additionalViewVars);
foreach ($viewVars as $viewVar) $this->set($viewVar, ${$viewVar});

View File

@ -2567,20 +2567,33 @@ class Server extends AppModel {
public function writeableFilesDiagnostics(&$diagnostic_errors) {
$writeableFiles = array(
'Config' . DS . 'config.php' => 0
APP . 'Config' . DS . 'config.php' => 0,
);
foreach ($writeableFiles as $path => &$error) {
if (!file_exists(APP . $path)) {
if (!file_exists($path)) {
$error = 1;
continue;
}
if (!is_writeable(APP . $path)) {
if (!is_writeable($path)) {
$error = 2;
$diagnostic_errors++;
}
}
return $writeableFiles;
}
public function readableFilesDiagnostics(&$diagnostic_errors) {
$readableFiles = array(
APP . 'files' . DS . 'scripts' . DS . 'stixtest.py' => 0
);
foreach ($readableFiles as $path => &$error) {
if (!is_readable($path)) {
$error = 1;
continue;
}
}
return $readableFiles;
}
public function stixDiagnostics(&$diagnostic_errors, &$stixVersion, &$cyboxVersion) {
$result = array();

View File

@ -1,7 +1,7 @@
<div style="border:1px solid #dddddd; margin-top:1px; width:95%; padding:10px">
<h3>MISP version</h3>
<p>Since version 2.3.14, every version of MISP includes a json file with the current version. This is checked against the latest tag on github, if there is a version mismatch the tool will warn you about it. Make sure that you update MISP regularly.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<span>Currently installed version.....
<?php
@ -47,7 +47,7 @@
<h3>Writeable Directories and files</h3>
<p>The following directories and files have to be writeable for MISP to function properly. Make sure that the apache user has write privileges for the directories below.</p>
<p><b>Directories</b></p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
foreach ($writeableDirs as $dir => $error) {
$colour = 'green';
@ -61,8 +61,8 @@
?>
</div>
<br />
<p><b>Files</b></p>
<div style="background-color:#f7f7f9;width:300px;">
<p><b>Writeable Files</b></p>
<div style="background-color:#f7f7f9;width:400px;">
<?php
foreach ($writeableFiles as $file => $error) {
$colour = 'green';
@ -71,10 +71,25 @@
$message = 'File ' . $message;
$colour = 'red';
}
echo 'app/' . $file . '.....<span style="color:' . $colour . ';">' . $message . '</span><br />';
echo $file . '.....<span style="color:' . $colour . ';">' . $message . '</span><br />';
}
?>
</div>
<p><b>Readable Files</b></p>
<div style="background-color:#f7f7f9;width:400px;">
<?php
foreach ($readableFiles as $file => $error) {
$colour = 'green';
$message = $readableErrors[$error];
if ($error > 0) {
$message = 'File ' . $message;
$colour = 'red';
}
echo $file . '.....<span style="color:' . $colour . ';">' . $message . '</span><br />';
}
?>
</div>
<h3>PHP Settings</h3>
<?php
$phpcolour = 'green';
@ -126,7 +141,7 @@
<?php
foreach (array('web', 'cli') as $context):
?>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<b><?php echo ucfirst(h($context));?></b><br />
<?php
if (isset($extensions[$context]['extensions'])):
@ -151,16 +166,30 @@
<p>Mitre's STIX and Cybox python libraries have to be installed in order for MISP's STIX export to work. Make sure that you install them (as described in the MISP installation instructions) if you receive an error below.<br />
If you run into any issues here, make sure that both STIX and CyBox are installed as described in the INSTALL.txt file. The required versions are:<br /><b>STIX</b>: <?php echo $stix['stix']['expected'];?><br /><b>CyBox</b>: <?php echo $stix['cybox']['expected'];?><br />
Other versions might work but are not tested / recommended.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
if ($stix['operational'] == 0) $colour = 'red';
echo 'STIX and Cybox libraries....<span style="color:' . $colour . ';">' . $stixOperational[$stix['operational']] . '</span><br />';
if ($stix['operational'] == 1) {
foreach (array('stix', 'cybox') as $package) {
$colour = 'green';
if ($stix[$package]['status'] == 0) $colour = 'red';
echo strtoupper($package) . ' library version....<span style="color:' . $colour . ';">' . ${$package . 'Version'}[$stix[$package]['status']] . '</span><br />';
$testReadError = false;
foreach ($readableFiles as $file => $data) {
if (substr($file, -strlen('/stixtest.py')) == '/stixtest.py') {
if ($data > 0) {
$colour = 'red';
echo 'STIX and CyBox.... <span class="red">Could not read test script (stixtest.py).</span>';
$testReadError = true;
}
}
}
if (!$testReadError) {
if ($stix['operational'] == 0) {
$colour = 'red';
}
echo 'STIX and Cybox libraries....<span style="color:' . $colour . ';">' . $stixOperational[$stix['operational']] . '</span><br />';
if ($stix['operational'] == 1) {
foreach (array('stix', 'cybox') as $package) {
$colour = 'green';
if ($stix[$package]['status'] == 0) $colour = 'red';
echo strtoupper($package) . ' library version....<span style="color:' . $colour . ';">' . ${$package . 'Version'}[$stix[$package]['status']] . '</span><br />';
}
}
}
?>
@ -169,7 +198,7 @@
GnuPG
</h3>
<p>This tool tests whether your GnuPG is set up correctly or not.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
$message = $gpgErrors[$gpgStatus];
@ -183,7 +212,7 @@
ZeroMQ
</h3>
<p>This tool tests whether the ZeroMQ extension is installed and functional.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
$message = $zmqErrors[$zmqStatus];
@ -202,7 +231,7 @@
Proxy
</h3>
<p>This tool tests whether your HTTP proxy settings are correct.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
$message = $proxyErrors[$proxyStatus];
@ -219,7 +248,7 @@
<?php
foreach ($moduleTypes as $type):
?>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
if (isset($moduleErrors[$moduleStatus[$type]])) {
@ -240,7 +269,7 @@
Session table
</h3>
<p>This tool checks how large your database's session table is. <br />Sessions in CakePHP rely on PHP's garbage collection for cleanup and in certain distributions this can be disabled by default resulting in an ever growing cake session table. <br />If you are affected by this, just click the clean session table button below.</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
<?php
$colour = 'green';
$message = $sessionErrors[$sessionStatus];
@ -265,7 +294,7 @@
Orphaned attributes
</h3>
<p>In some rare cases attributes can remain in the database after an event is deleted becoming orphaned attributes. This means that they do not belong to any event, which can cause issues with the correlation engine (known cases include event deletion directly in the database without cleaning up the attributes and situtations involving a race condition with an event deletion happening before all attributes are synchronised over).</p>
<div style="background-color:#f7f7f9;width:300px;">
<div style="background-color:#f7f7f9;width:400px;">
Orphaned attributes....<span id="orphanedAttributeCount"><span style="color:orange;">Run the test below</span></span>
</div><br />
<span class="btn btn-inverse" style="padding-top:1px;padding-bottom:1px;" onClick="checkOrphanedAttributes();">Check for orphaned attributes</span><br /><br />

View File

@ -1,5 +1,5 @@
<div class="server index">
<?php if ($writeableFiles['Config/config.php'] != 0): ?>
<?php if ($writeableFiles[APP . 'Config/config.php'] != 0): ?>
<div class="bold" style="background-color:red;width:100%;color:white;"><span style="padding-left:10px;">Warning: app/Config/config.php is not writeable. This means that any setting changes made here will NOT be saved.</span></div>
<?php endif; ?>
<h2>Server settings</h2>