mirror of https://github.com/MISP/MISP
chg: [diagnostics] Report on Vendor dependencies
parent
84d620fd9a
commit
5b1bc40ba0
|
@ -3996,21 +3996,29 @@ class Server extends AppModel
|
|||
try {
|
||||
$composer = FileAccessTool::readJsonFromFile(APP . DS . 'composer.json');
|
||||
$extensions = [];
|
||||
$dependencies = [];
|
||||
foreach ($composer['require'] as $require => $foo) {
|
||||
if (substr($require, 0, 4) === 'ext-') {
|
||||
$extensions[substr($require, 4)] = true;
|
||||
}
|
||||
else if (mb_strpos($require, '/') !== false) { // external dependencies have namespaces, so a /
|
||||
$dependencies[$require] = true;
|
||||
}
|
||||
}
|
||||
foreach ($composer['suggest'] as $suggest => $reason) {
|
||||
if (substr($suggest, 0, 4) === 'ext-') {
|
||||
$extensions[substr($suggest, 4)] = $reason;
|
||||
}
|
||||
else if (mb_strpos($suggest, '/') !== false) { // external dependencies have namespaces, so a /
|
||||
$dependencies[$suggest] = $reason;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->logException('Could not load extensions from composer.json', $e, LOG_NOTICE);
|
||||
$extensions = ['redis' => '', 'gd' => '', 'ssdeep' => '', 'zip' => '', 'intl' => '']; // Default extensions
|
||||
}
|
||||
|
||||
// check PHP extensions
|
||||
$results = ['cli' => false];
|
||||
foreach ($extensions as $extension => $reason) {
|
||||
$results['extensions'][$extension] = [
|
||||
|
@ -4022,9 +4030,9 @@ class Server extends AppModel
|
|||
'info' => $reason === true ? null : $reason,
|
||||
];
|
||||
}
|
||||
if (is_readable(APP . '/files/scripts/selftest.php')) {
|
||||
if (is_readable(APP . DS . 'files' . DS . 'scripts' . DS . 'selftest.php')) {
|
||||
try {
|
||||
$execResult = ProcessTool::execute(['php', APP . '/files/scripts/selftest.php', json_encode(array_keys($extensions))]);
|
||||
$execResult = ProcessTool::execute(['php', APP . DS . 'files' . DS . 'scripts' . DS . 'selftest.php', json_encode(array_keys($extensions))]);
|
||||
} catch (Exception $e) {
|
||||
// pass
|
||||
}
|
||||
|
@ -4037,6 +4045,7 @@ class Server extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
// version check
|
||||
$minimalVersions = [
|
||||
'redis' => '2.2.8', // because of sAddArray method
|
||||
];
|
||||
|
@ -4052,6 +4061,22 @@ class Server extends AppModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check PHP dependencies, installed in the Vendor directory, just check presence of the folder
|
||||
foreach ($dependencies as $dependency => $reason) {
|
||||
try {
|
||||
$version = \Composer\InstalledVersions::getVersion($dependency);
|
||||
} catch (Exception $e) {
|
||||
$version = false;
|
||||
}
|
||||
$results['dependencies'][$dependency] = [
|
||||
'version' => $version,
|
||||
'version_outdated' => false,
|
||||
'required' => $reason === true,
|
||||
'info' => $reason === true ? null : $reason,
|
||||
];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
|
|
@ -238,6 +238,40 @@ $humanReadableFilesize = function ($bytes, $dec = 2) {
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<h4><?= __('PHP Dependencies') ?></h4>
|
||||
<p><?= _("Dependencies located in the Vendor folder. You can use composer to install them: 'php composer.phar help' ") ?></p>
|
||||
<table class="table table-condensed table-bordered" style="width: 40vw">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= __('Dependency') ?></th>
|
||||
<th><?= __('Required') ?></th>
|
||||
<th><?= __('Why to install') ?></th>
|
||||
<th><?= __('Installed') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($extensions['dependencies'] as $dependency => $info): ?>
|
||||
<tr>
|
||||
<td class="bold"><?= h($dependency) ?></td>
|
||||
<td><?= $info['required'] ? '<i class="black fa fa-check" role="img" aria-label="' . __('Yes') . '"></i>' : '<i class="black fa fa-times" role="img" aria-label="' . __('No') . '"></i>' ?></td>
|
||||
<td><?= $info['info'] ?></td>
|
||||
<td><?php
|
||||
$version = $info["version"];
|
||||
$outdated = $info["version_outdated"];
|
||||
if ($version && !$outdated) {
|
||||
echo '<i class="green fa fa-check" role="img" aria-label="' . __('Yes') . '"></i> (' . h($version) .')';
|
||||
} else {
|
||||
echo '<i class="red fa fa-times" role="img" aria-label="' . __('No') . '"></i>';
|
||||
if ($outdated) {
|
||||
echo '<br>' . __("Version %s installed, but required at least %s", h($version), h($info['required_version']));
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="width:400px;">
|
||||
<?= $this->element('/genericElements/IndexTable/index_table', array(
|
||||
'data' => array(
|
||||
|
|
Loading…
Reference in New Issue