Merge branch 'ent-12216-Entradas-fantasma-para-elementos-de-discovery-offline' into 'develop'

Ent 12216 entradas fantasma para elementos de discovery offline

See merge request artica/pandorafms!6740
This commit is contained in:
Daniel Rodriguez 2023-12-15 09:22:10 +00:00
commit 3fe41179e0
27 changed files with 442 additions and 15 deletions

View File

@ -0,0 +1,18 @@
pandorafms.aws.ec2;Amazon EC2;cloud;1;pandorafms.aws.ec2.png;https://pandorafms.com/library/aws-ec2-discovery/
pandorafms.aws.rds;Amazon RDS;cloud;1;pandorafms.aws.rds.png;https://pandorafms.com/library/aws-rds-discovery/
pandorafms.aws.s3;Amazon S3;cloud;1;pandorafms.aws.s3.png;https://pandorafms.com/library/aws-s3-discovery/
pandorafms.azure.mc;Azure Microsoft Compute;cloud;1;pandorafms.azure.mc.png;https://pandorafms.com/library/aws-azure-discovery/
pandorafms.db2;DB2;app;1;pandorafms.db2.png;https://pandorafms.com/library/db2-discovery/
pandorafms.gcp.ce;Google Cloud Compute Engine;cloud;1;pandorafms.gcp.ce.png;https://pandorafms.com/library/google-cloud-discovery/
pandorafms.mssql;Microsoft SQL Server;app;1;pandorafms.mssql.png;https://pandorafms.com/library/mssql-discovery/
pandorafms.mysql;MySQL;app;1;pandorafms.mysql.png;https://pandorafms.com/library/mysql-discovery/
pandorafms.oracle;Oracle;app;1;pandorafms.oracle.png;https://pandorafms.com/library/oracle-discovery/
pandorafms.proxmox;Proxmox;app;0;pandorafms.proxmox.png;https://pandorafms.com/library/proxmox-discovery/
pandorafms.sap.deset;SAP R3 - Deset;app;1;pandorafms.sap.deset.png;https://pandorafms.com/library/sap-discovery/
pandorafms.vmware;VMware;app;1;pandorafms.vmware.png;https://pandorafms.com/library/vmware-discovery/
pandorafms.kubernetes;Kubernetes;app;1;pandorafms.kubernetes.png;https://pandorafms.com/library/kubernetes-discovery/
pandorafms.mongodb;MongoDB;app;1;pandorafms.mongodb.png;https://pandorafms.com/library/mongodb-discovery/
pandorafms.ovh;OVH;cloud;1;pandorafms.ovh.png;https://pandorafms.com/library/ovh-discovery/
pandorafms.vulnscan;Vulnerability Scanner;app;1;pandorafms.vulnscan.png;https://pandorafms.com/library/pandora-vulnerability-discovery/
pandorafms.postgresql;PostgreSQL;app;1;pandorafms.postgresql.png;https://pandorafms.com/library/postgresql-discovery/
pandorafms.xenserver;Xenserver;app;1;pandorafms.xenserver.png;https://pandorafms.com/library/xenserver-discovery/
1 pandorafms.aws.ec2 Amazon EC2 cloud 1 pandorafms.aws.ec2.png https://pandorafms.com/library/aws-ec2-discovery/
2 pandorafms.aws.rds Amazon RDS cloud 1 pandorafms.aws.rds.png https://pandorafms.com/library/aws-rds-discovery/
3 pandorafms.aws.s3 Amazon S3 cloud 1 pandorafms.aws.s3.png https://pandorafms.com/library/aws-s3-discovery/
4 pandorafms.azure.mc Azure Microsoft Compute cloud 1 pandorafms.azure.mc.png https://pandorafms.com/library/aws-azure-discovery/
5 pandorafms.db2 DB2 app 1 pandorafms.db2.png https://pandorafms.com/library/db2-discovery/
6 pandorafms.gcp.ce Google Cloud Compute Engine cloud 1 pandorafms.gcp.ce.png https://pandorafms.com/library/google-cloud-discovery/
7 pandorafms.mssql Microsoft SQL Server app 1 pandorafms.mssql.png https://pandorafms.com/library/mssql-discovery/
8 pandorafms.mysql MySQL app 1 pandorafms.mysql.png https://pandorafms.com/library/mysql-discovery/
9 pandorafms.oracle Oracle app 1 pandorafms.oracle.png https://pandorafms.com/library/oracle-discovery/
10 pandorafms.proxmox Proxmox app 0 pandorafms.proxmox.png https://pandorafms.com/library/proxmox-discovery/
11 pandorafms.sap.deset SAP R3 - Deset app 1 pandorafms.sap.deset.png https://pandorafms.com/library/sap-discovery/
12 pandorafms.vmware VMware app 1 pandorafms.vmware.png https://pandorafms.com/library/vmware-discovery/
13 pandorafms.kubernetes Kubernetes app 1 pandorafms.kubernetes.png https://pandorafms.com/library/kubernetes-discovery/
14 pandorafms.mongodb MongoDB app 1 pandorafms.mongodb.png https://pandorafms.com/library/mongodb-discovery/
15 pandorafms.ovh OVH cloud 1 pandorafms.ovh.png https://pandorafms.com/library/ovh-discovery/
16 pandorafms.vulnscan Vulnerability Scanner app 1 pandorafms.vulnscan.png https://pandorafms.com/library/pandora-vulnerability-discovery/
17 pandorafms.postgresql PostgreSQL app 1 pandorafms.postgresql.png https://pandorafms.com/library/postgresql-discovery/
18 pandorafms.xenserver Xenserver app 1 pandorafms.xenserver.png https://pandorafms.com/library/xenserver-discovery/

View File

@ -212,6 +212,27 @@ class Applications extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
}

View File

@ -232,6 +232,27 @@ class Cloud extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
}

View File

@ -135,6 +135,27 @@ class Custom extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
return $result;
}

View File

@ -697,6 +697,9 @@ class ManageExtensions extends HTML
$order,
);
$appsMetadata = self::loadDiscoveryAppsMetadata();
$flattenMetadata = array_merge(...array_values($appsMetadata));
$count = db_get_num_rows($sqlCount);
foreach ($data as $key => $row) {
@ -705,6 +708,15 @@ class ManageExtensions extends HTML
$logo = $this->defaultLogo;
}
$metadataImage = $flattenMetadata[$row['short_name']]['image'];
if (isset($metadataImage) === true
&& file_exists($config['homedir'].'/images/discovery/'.$metadataImage) === true
&& file_exists($this->path.'/'.$row['short_name'].'/logo.png') === false
) {
$logo = '/images/discovery/'.$metadataImage;
}
$logo = html_print_image($logo, true, ['style' => 'max-width: 30px; margin-right: 15px;']);
$data[$key]['name'] = $logo.io_safe_output($row['name']);
$data[$key]['short_name'] = $row['short_name'];
@ -1490,4 +1502,55 @@ class ManageExtensions extends HTML
}
/**
* Read metadata CSV from system and store data structure in memory.
*
* @return array Data structure.
*/
private static function loadDiscoveryAppsMetadata()
{
global $config;
// Open the CSV file for reading.
$fileHandle = fopen($config['homedir'].'/extras/discovery/DiscoveryApps.csv', 'r');
// Check if the file was opened successfully.
if ($fileHandle !== false) {
$csvData = [];
// Loop through each line in the CSV file.
while (($data = fgetcsv($fileHandle)) !== false) {
$csvData[] = explode(';', $data[0]);
}
// Close the file handle.
fclose($fileHandle);
}
$groupedArray = [];
foreach ($csvData as $item) {
$key = $item[2];
if (isset($groupedArray[$key]) === false) {
$groupedArray[$key] = [];
}
$itemShortName = $item[0];
unset($item[0]);
unset($item[2]);
$itemIns = [
'name' => $item[1],
'enterprise' => $item[3],
'image' => $item[4],
'url' => $item[5],
];
$groupedArray[$key][$itemShortName] = $itemIns;
}
return $groupedArray;
}
}

View File

@ -492,14 +492,43 @@ class Wizard
$data['url'] = '#';
}
$cnt_class = 'data_container';
$ent_icon = '';
$label_class = '';
if (isset($data['ghost_mode']) === true
&& $data['ghost_mode'] === true
) {
$cnt_class .= ' alpha50';
}
if (isset($data['mark_as_enterprise']) === true
&& $data['mark_as_enterprise'] === true
) {
$ent_icon .= html_print_div(
[
'class' => 'w20px inline margin-lr-10',
'content' => html_print_image(
'images/ent_icon.png',
true,
['class' => 'max-width-100p height_auto_important']
),
],
true
);
$label_class = 'inline';
}
?>
<li class="discovery">
<a href="<?php echo $data['url']; ?>">
<div class="data_container">
<div class="<?php echo $cnt_class; ?> ">
<?php html_print_image($data['icon']); ?>
<br><label id="text_wizard">
<br><label id="text_wizard" class="<?php echo $label_class; ?>">
<?php echo io_safe_output($data['label']); ?>
</label>
<?php echo $ent_icon; ?>
</div>
</a>
</li>
@ -514,11 +543,18 @@ class Wizard
*
* @return void Print the full list.
*/
public static function printBigButtonsList($list_data)
public static function printBigButtonsList($list_data, $return=false)
{
if ($return === true) {
ob_start();
}
echo '<ul class="bigbuttonlist">';
array_map('self::printBigButtonElement', $list_data);
echo '</ul>';
if ($return === true) {
return ob_get_clean();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -195,28 +195,200 @@ class ExtensionsDiscovery extends Wizard
/**
* Return array extensions filtered by section
*
* @return array Extensions for
* @param boolean $not_defined_only Get only those extensions that are defined in the metadata CSV and not in db.
*
* @return array Extensions
*/
public function loadExtensions()
public function loadExtensions($not_defined_only=false)
{
global $config;
// Check access.
check_login();
$extensions = [];
$rows = $this->getExtensionsApps();
foreach ($rows as $key => $extension) {
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
define('NOT_FOUND_MSG', 1);
define('ENTERPRISE_MSG', 2);
define('URL_MSG', 3);
$appsMetadata = self::loadDiscoveryAppsMetadata();
$sectionMetadata = $appsMetadata[$this->section];
$anchor = html_print_anchor(
[
'href' => 'index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert',
'content' => __('here'),
],
true
);
// Print JS required for message management.
echo '<script>
function showExtensionMsg(msgs, url, title) {
var msgs_json = JSON.parse(msgs);
var url_str = "";
if (url != false) {
url_str = `<a target="_blank" class="link-important" href="${url}">'.__('here').'</a>`;
}
$extensions[] = [
'icon' => $logo,
'label' => $extension['name'],
'url' => ui_get_full_url(
var markup = "<ul class=\'\'>";
if (msgs_json.includes('.NOT_FOUND_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('The required files for the application were not found.').'</li>";
}
if (msgs_json.includes('.ENTERPRISE_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('This discovery application is for Enterprise customers only.').'</li>";
}
if (msgs_json.includes('.URL_MSG.')) {
markup += \'<li>&nbsp;&nbsp;&nbsp;'.__('You can download this application from').' \'+url_str+\'.</li>\';
}
markup += "</ul>";
confirmDialog({
title: title,
message: markup,
hideOkButton: true,
ok: "'.__('OK').'",
cancel: "'.__('Cancel').'",
size: 550,
maxHeight: 500
});
}
</script>';
if ($not_defined_only === true) {
// Case: search for those extensions defined in metadata CSV which are not in database.
$short_names_list = array_column($rows, 'short_name');
// Traverse apps in CSV metadata file and set properly those that do not exist in database.
foreach ($sectionMetadata as $short_name => $val) {
if (in_array($short_name, $short_names_list) === false) {
$logo = $this->path.'/'.$short_name.'/'.$val['image'];
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
}
$error_msgs = [];
if (isset($val['image']) === true
&& file_exists($config['homedir'].'/images/discovery/'.$val['image']) === true
&& file_exists($config['homedir'].$this->path.'/'.$short_name.'/'.$val['image']) === false
) {
$logo = '/images/discovery/'.$val['image'];
}
$url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
);
if (enterprise_installed() === false && ((bool) $val['enterprise'] === true)) {
// Display enterprise message if console is open and extension is enterprise.
$error_msgs[] = ENTERPRISE_MSG;
}
$url_href = false;
if (isset($val['url']) === true
&& $val['url'] !== ''
) {
$url_href = $val['url'];
// Display URL message if an URL is defined in the metadata.
$error_msgs[] = URL_MSG;
}
if (empty($error_msgs) === false) {
$json_errors = json_encode($error_msgs);
// Display messages dialog if there are some.
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($val['name']).'\');';
}
$extensions[] = [
'icon' => $logo,
'label' => io_safe_input($val['name']),
'url' => $url,
'ghost_mode' => true,
'mark_as_enterprise' => (bool) $val['enterprise'],
'defined' => false,
];
}
}
} else {
foreach ($rows as $key => $extension) {
$error_msgs = [];
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
}
$mark_as_enterprise = false;
$ghostMode = false;
$url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
),
];
);
$url_href = false;
$iniFileExists = self::iniFileExists($extension['short_name']);
// Access metadata for current extension.
if (isset($sectionMetadata[$extension['short_name']]) === true) {
$itemData = $sectionMetadata[$extension['short_name']];
if (isset($itemData) === true) {
if (isset($itemData['image']) === true
&& file_exists($config['homedir'].'/images/discovery/'.$itemData['image']) === true
&& file_exists($config['homedir'].$this->path.'/'.$extension['short_name'].'/'.$this->icon) === false
) {
$logo = '/images/discovery/'.$itemData['image'];
}
$mark_as_enterprise = (bool) $itemData['enterprise'];
if ($iniFileExists === false
&& isset($itemData['url']) === true
&& $itemData['url'] !== ''
) {
$url_href = $itemData['url'];
// Display URL message if an URL is defined in the metadata.
$error_msgs[] = URL_MSG;
}
if (enterprise_installed() === false
&& (bool) $itemData['enterprise'] === true
) {
// Set ghost mode and display enterprise message if console is open and extension is enterprise.
$error_msgs[] = ENTERPRISE_MSG;
$ghostMode = true;
}
$itemName = $itemData['name'];
}
}
if ($iniFileExists === false) {
// Set ghost mode and display not found message if ini file does not exist for extension.
$error_msgs[] = NOT_FOUND_MSG;
$ghostMode = true;
}
if (empty($error_msgs) === false) {
$json_errors = json_encode($error_msgs);
// Display messages dialog if there are some.
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($itemName).'\');';
}
$extensions[] = [
'icon' => $logo,
'label' => $extension['name'],
'url' => $url,
'ghost_mode' => $ghostMode,
'mark_as_enterprise' => $mark_as_enterprise,
'defined' => true,
];
}
}
return $extensions;
@ -2553,4 +2725,69 @@ class ExtensionsDiscovery extends Wizard
}
/**
* Read metadata CSV from system and store data structure in memory.
*
* @return array Data structure.
*/
private static function loadDiscoveryAppsMetadata()
{
global $config;
// Open the CSV file for reading.
$fileHandle = fopen($config['homedir'].'/extras/discovery/DiscoveryApps.csv', 'r');
// Check if the file was opened successfully.
if ($fileHandle !== false) {
$csvData = [];
// Loop through each line in the CSV file.
while (($data = fgetcsv($fileHandle)) !== false) {
$csvData[] = explode(';', $data[0]);
}
// Close the file handle.
fclose($fileHandle);
}
$groupedArray = [];
foreach ($csvData as $item) {
$key = $item[2];
if (isset($groupedArray[$key]) === false) {
$groupedArray[$key] = [];
}
$itemShortName = $item[0];
unset($item[0]);
unset($item[2]);
$itemIns = [
'name' => $item[1],
'enterprise' => $item[3],
'image' => $item[4],
'url' => $item[5],
];
$groupedArray[$key][$itemShortName] = $itemIns;
}
return $groupedArray;
}
/**
* Check if ini file exists for extension.
*
* @param string $shortName Extension short name.
*
* @return boolean Whether or not ini file exists.
*/
public static function iniFileExists($shortName)
{
global $config;
$path = $config['homedir'].'/attachment/discovery/'.$shortName.'/discovery_definition.ini';
return file_exists($path);
}
}

View File

@ -8159,6 +8159,10 @@ div.graph div.legend table {
height: auto;
}
.height_auto_important {
height: auto !important;
}
.mx_height50px {
max-height: 50px;
}
@ -12304,6 +12308,12 @@ div.parent_graph > p.legend_background > table > tbody > tr {
color: #82b92e;
text-decoration: none;
}
.link-important {
color: #82b92e !important;
text-decoration: none !important;
}
.signature a {
color: #82b92e;
text-decoration: none;