From c503836634e995f7337db335fbe3c47c82604fe3 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 12 Jan 2023 12:28:40 +0100 Subject: [PATCH] Restrict access to collections with nms license --- .../godmode/agentes/configurar_agente.php | 8 +++++--- pandora_console/godmode/menu.php | 3 ++- pandora_console/include/constants.php | 1 + pandora_console/include/functions.php | 16 ++++++++++++++++ pandora_console/include/functions_api.php | 10 ++++++++++ pandora_console/operation/agentes/ver_agente.php | 8 +++++--- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 4432fef1cd..62807fa7c9 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -485,10 +485,12 @@ if ($id_agente) { } // Collection. - $collectiontab = enterprise_hook('collection_tab'); + if ($config['license_nms'] !== 1) { + $collectiontab = enterprise_hook('collection_tab'); - if ($collectiontab == -1) { - $collectiontab = ''; + if ($collectiontab == -1) { + $collectiontab = ''; + } } // NetworkConfigManager tab. diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index fef71922e3..7e9a7964a3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -26,7 +26,8 @@ * GNU General Public License for more details. * ============================================================================ */ - +$config['license_nms'] = 1; +// ! Eliminar! // Begin. require_once 'include/config.php'; require_once 'include/functions_menu.php'; diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 96fb1c216b..18b32b6de4 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -805,6 +805,7 @@ define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management'); define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management'); define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management'); define('AUDIT_LOG_UMC', 'Warp Manager'); +define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation'); // MIMEs. define( diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7c2df5603b..a333006da8 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6342,3 +6342,19 @@ function setDownloadCookieToken() ); } } + + +/** + * Check nms license on api. + * + * @return boolean + */ +function nms_check_api() +{ + global $config; + + if ($config['license_nms'] === 1) { + returnError('license_error'); + return true; + } +} diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index db79ed3c86..f322f5c2de 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -198,6 +198,16 @@ function returnError($typeError, $returnType='string') ); break; + case 'license_error': + returnData( + $returnType, + [ + 'type' => 'string', + 'data' => __('License not allowed for this operation.'), + ] + ); + break; + default: returnData( $returnType, diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 2ee6781f00..89c7c70d8e 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1461,9 +1461,11 @@ if ($inventorytab == -1 || $inventoryCount === 0) { } // Collection. -$collectiontab = enterprise_hook('collection_tab'); -if ($collectiontab == -1) { - $collectiontab = ''; +if ($config['license_nms'] !== 1) { + $collectiontab = enterprise_hook('collection_tab'); + if ($collectiontab == -1) { + $collectiontab = ''; + } }