diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 4ad837f943..e25a82a517 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -234,6 +234,21 @@ module_description Number of cron task files module_unit files module_end +# This module /var/log/syslog file, under the module name "syslog" +# And search for "ssh" string into it, sending only that information. +module_begin +module_name Syslog +module_description Search for ssh string into /var/log/syslog file +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end + +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end # Plugin example @@ -241,11 +256,6 @@ module_end module_plugin pandora_df -# This parses /var/log/syslog file, under the module name "syslog" -# And search for "ssh" string into it, sending only that information. - -module_plugin grep_log /var/log/syslog Syslog ssh - # Get disk space free in MB #module_begin #module_name disk_root_free @@ -270,7 +280,6 @@ module_plugin grep_log /var/log/syslog Syslog ssh #module_end # Plugin for inventory on the agent. - # module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route # Example of preconditions @@ -303,4 +312,13 @@ module_plugin grep_log /var/log/syslog Syslog ssh # This plugin runs several security checks in a Linux system -#module_plugin pandora_security_check \ No newline at end of file +#module_plugin pandora_security_check + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 621c1d24ac..27f0326da0 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -147,22 +147,23 @@ module_max_critical 20 module_end # Log events + +# Get logs from System source. module_begin module_name System Events (TermService) -module_type async_string -module_logevent module_description Log Events coming from Terminal Service +module_type log +module_logevent module_source System -module_application TermService module_end +# Get logs from Security source. module_begin -module_name Security Events (Invalid Login) -module_type async_string -module_description Security log events for invalid login attempt +module_name Security Events +module_description Security log events +module_type log module_logevent module_source Security -module_eventcode 529 module_end # Check if Dhcp service is enabled @@ -219,6 +220,12 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" # module_description Free space on drive D: (%) # module_end +# Hardening plugin for security compliance analysis. +# module_begin +# module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_hardening.exe -t 150" +# module_absoluteinterval 7d +# module_end + # Sample of Windows inventory module (ONLY ENTERPRISE)! #module_begin #module_name Inventory @@ -344,4 +351,13 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" #module_condition (3,8) cmd.exe /c echo range >> c:\log.txt #module_exec echo 5 #module_description Postcondition test module +#module_end + +# Example of collector module +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* #module_end \ No newline at end of file diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index 67e603b225..88f78e31ac 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -2179,16 +2179,7 @@ sub configure ($) { #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - if (launch_tentacle_proxy() != 0) { - return 1; - } - } else { - error ('Proxy mode can not be launched as root'); - return 1; - } + return 1 if (launch_tentacle_proxy() != 0); } # Add the plugins directory to the PATH diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 98c137741e..49e8866f9a 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -157,12 +157,32 @@ module_exec last | head -1 module_description Last Login module_end -# Plugin example +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end -# This parses /var/log/syslog file, under the module name "syslog" +# This module parses /var/log/syslog file, under the module name "syslog" # And search for "ssh" string into it, sending only that information. +module_begin +module_name Syslog +module_description Search for ssh string into /var/log/syslog file +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end -module_plugin grep_log /var/log/syslog Syslog ssh +# Plugin example # Plugin for inventory on the agent. # module_plugin inventory 1 cpu ram video nic hd cdrom software + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index b4b3c35ac8..ba9c0079a3 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -372,13 +372,32 @@ module_end #module_description XGrid #module_end +#Hardening plugin for security compliance analysis. Enable to use it. +#module_begin +#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150 +#module_absoluteinterval 7d +#module_end + +# This module parses /var/log/syslog file, under the module name "syslog" +# And search for "ssh" string into it, sending only that information. +module_begin +module_name Syslog +module_description Log collection modules +module_type log +module_regexp /var/log/syslog +module_pattern ssh +module_end + # Plugin example -# This parses /var/log/syslog file, under the module name "syslog" -# And search for "ssh" string into it, sending only that information. - -#module_plugin grep_log /var/log/syslog Syslog ssh - # Plugin for inventory on the agent. - # module_plugin inventory 1 cpu ram video nic hd cdrom software + +# Extraction module example +#module_begin +#module_name Collector +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index dd0ce08b75..aa4a2d744c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.774-231124 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 5158af8d98..5230283cd9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231124" +pandora_version="7.0NG.774-231214" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 10458ddba5..42fddd39f5 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -271,11 +271,17 @@ module_plugin pandora_netusage module_plugin autodiscover --default # Plugin for inventory on the agent. -#module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route +# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route # Log collection modules. This will collect log files for forensic analysis and store everything # This is for LOG monitoring. Different than log monitoring. -#module_plugin grep_log_module /var/log/messages Syslog \.\* +module_begin +module_name Syslog +module_description Log collection modules +module_type log +module_regexp /var/log/messages +module_pattern .* +module_end # Another samples of monitoring modules @@ -317,9 +323,9 @@ module_plugin autodiscover --default #module_absoluteinterval 7d #module_end -# Logs extraction +# Extraction module example #module_begin -#module_name Syslog +#module_name Collector #module_description Logs extraction module #module_type log #module_regexp /var/log/logfile.log diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index ebc53342ea..eea0bef2e7 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.774'; -use constant AGENT_BUILD => '231124'; +use constant AGENT_BUILD => '231214'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -4436,14 +4436,7 @@ my $PID = $$; #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - launch_tentacle_proxy(); - } else { - log_message ('error', 'Proxy mode can not be launched as root'); - exit 1; - } + launch_tentacle_proxy(); } # Advice if YAML::Tiny is allowed in this system diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 035e294a80..77dd456483 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231124 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index 2d9786d989..d6170ca2e8 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231124 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index 664ac69870..81de81c240 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231124 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index bd9985ef8d..7e3809eec3 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231124 +%define release 231214 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 1da3e088b0..6babe4a929 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231124 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 3fb5fe7f8d..6635b0c2e4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.774" -PI_BUILD="231124" +PI_BUILD="231214" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index bae2841fd5..c0a1560b38 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -179,6 +179,22 @@ module_description Total number of TCP connections active module_group Networking module_end +# Get logs from System source. +module_begin +module_name Eventlog_System +module_type log +module_logevent +module_source System +module_end + +# Get logs from Security source. +module_begin +module_name Eventlog_Security +module_type log +module_logevent +module_source Security +module_end + # Example plugin to retrieve drive usage module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs" @@ -273,22 +289,6 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default #module_type generic_data_string #module_end -# Get logs from System source. Need enterprise version. -#module_begin -#module_name Eventlog_System -#module_type log -#module_logevent -#module_source System -#module_end - -# Get logs from Security source. Need enterprise version. -#module_begin -#module_name Eventlog_Security -#module_type log -#module_logevent -#module_source Security -#module_end - # Get logs from Application source. Need enterprise version. #module_begin #module_name Eventlog_Application diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 9e8d2e364c..2849d5842a 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{231124} +{231214} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 367fee4b81..d5c47e9441 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.774 Build 231124") +#define PANDORA_VERSION ("7.0NG.774 Build 231214") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index c690b7b3a2..a7398b0f13 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.774(Build 231124))" + VALUE "ProductVersion", "(7.0NG.774(Build 231214))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 054afd4970..03471ff471 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.774-231124 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index e3673d56f7..92a964b48a 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231124" +pandora_version="7.0NG.774-231214" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index b3b9463ee6..a5dcf2cb0d 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true $_SESSION = []; session_destroy(); header_remove('Set-Cookie'); - setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + if (isset($_COOKIE[session_name()]) === true) { + setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + } if ($config['auth'] === 'saml' && empty($public_hash) === true) { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 6ed1061c11..35893b4414 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -27,17 +27,18 @@ */ global $config; -if (true) { - include_once '../include/config.php'; - include_once '../include/functions_agents.php'; - include_once '../include/functions_reporting.php'; - include_once '../include/functions_modules.php'; - include_once '../include/functions_users.php'; +if ((bool) $config['metaconsole']) { include_once $config['homedir'].'/include/config.php'; include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_reporting.php'; include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_users.php'; +} else { + include_once __DIR__.'/../include/config.php'; + include_once __DIR__.'/../include/functions_agents.php'; + include_once __DIR__.'/../include/functions_reporting.php'; + include_once __DIR__.'/../include/functions_modules.php'; + include_once __DIR__.'/../include/functions_users.php'; } @@ -106,7 +107,25 @@ if ($get_agents_module_csv === '1') { foreach ($results as $result) { foreach ($result as $key => $value) { - $out_csv .= io_safe_output($value).$divider; + if (preg_match('/Linux/i', $_SERVER['HTTP_USER_AGENT'])) { + $value = preg_replace( + '/\s+/', + ' ', + io_safe_output($value) + ); + } else { + $value = mb_convert_encoding( + preg_replace( + '/\s+/', + '', + io_safe_output($value) + ), + 'UTF-16LE', + 'UTF-8' + ); + } + + $out_csv .= $value.$divider; } $out_csv .= "\n"; diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index fce3e1a00f..38488fc9e4 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -99,7 +99,7 @@ function api_execute( if (empty($token) === true) { $data['apipass'] = $apipass; $data['user'] = $user; - $data['password'] = $password; + $data['pass'] = $password; } } diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 983e208bef..acaaadd12c 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -90,7 +90,7 @@ function dbmgr_extension_main() // Header. ui_print_standard_header( - __('Database interface'), + __('DB interface'), 'images/gm_db.png', false, '', diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index e63b719cfe..202000e0bf 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -31,7 +31,7 @@ function view_logfile($file_name, $toggle=false) } else { $file_size = filesize($file_name); - if ($memory_limit < $file_size) { + if ($memory_limit < $file_size && $memory_limit !== '-1') { $code .= '

'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')

'; $code .= '

'.__('The preview file is imposible.').'

'; } else if ($file_size > ($config['max_log_size'] * 1000)) { @@ -117,6 +117,7 @@ function pandoralogs_extension_main() view_logfile($config['homedir'].'/log/console.log', true); } + view_logfile('/var/log/php-fpm/www-error.log', true); view_logfile($logs_directory.'/pandora_server.log', true); view_logfile($logs_directory.'/pandora_server.error', true); diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 234ec4e997..03db82db4e 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1720,3 +1720,4 @@ include/functions_integriaims.php include/ajax/integria_incidents.ajax.php enterprise/operation/log/log_source.php enterprise/include/class/LogSource.class.php +include/chart_generator.php \ No newline at end of file diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 6323aec140..c0cee7d03f 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b +pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..cf3177b158 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,1112 @@ +START TRANSACTION; + +ALTER TABLE `tncm_queue` +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; + +ALTER TABLE `tncm_queue` +ADD COLUMN `snippet` TEXT NULL AFTER `scheduled`; + +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `id_agent_data_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; + +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( + `id` SERIAL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; + +ALTER TABLE `tncm_agent` +ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; + +ALTER TABLE `treport_content` +ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`; + +-- Add needed snippet script to queue tasks. +SET @type_snippet = 6; +SELECT @id_snippet := `id` FROM `tncm_script` WHERE `type` = @type_snippet; +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_snippet, @type_snippet, 'snippet'); + +-- Add new vendor and model +SET @vendor_name = 'Cisco'; +SET @model_name = 'Cisco-Generic'; +SET @template_name = 'Cisco-Generic'; +SET @agent_data_template_name = 'Cisco-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'; +SET @script_set_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'; +SET @script_set_firmware = 'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? firmware.bin\n show flash\n reload\n expect:confirm y\n config terminal\n boot system firmware.bin\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Juniper'; +SET @model_name = 'Juniper-Generic'; +SET @template_name = 'Juniper-Generic'; +SET @agent_data_template_name = 'Juniper-Generic'; +SET @script_test = 'expect:root@% cli\n exit\n'; +SET @script_get_config = 'expect:root@% cli\n expect:root> capture:show configuration | no-more\n capture:\n quit\n expect:root@% exit\n'; +SET @script_set_config = 'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'; +SET @script_get_firmware = 'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'; +SET @script_set_firmware = 'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Palo Alto'; +SET @model_name = 'Palo Alto-Generic'; +SET @template_name = 'Palo Alto-Generic'; +SET @agent_data_template_name = 'Palo Alto-Generic'; +SET @script_test = 'sleep:1 exit\n'; +SET @script_get_config = 'set cli pager off \n capture:show config running\n exit\n'; +SET @script_set_config = 'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'; +SET @script_get_firmware = 'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'; +SET @script_set_firmware = 'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'A10'; +SET @model_name = 'A10-Generic'; +SET @template_name = 'A10-Generic'; +SET @agent_data_template_name = 'A10-Generic'; +SET @script_test = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n'; +SET @script_get_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Alcatel-Lucent Enterprise'; +SET @model_name = 'Alcatel-Generic'; +SET @template_name = 'Alcatel-Generic'; +SET @agent_data_template_name = 'Alcatel-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'; +SET @script_set_config = ''; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'; +SET @script_set_firmware = ''; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Aruba'; +SET @model_name = 'Aruba-Generic'; +SET @template_name = 'Aruba-Generic'; +SET @agent_data_template_name = 'Aruba-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'copy tftp flash _TFTP_SERVER_IP_ firmware.bin.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ firmware.bin primary\n boot system flash primary\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Mikrotik'; +SET @model_name = 'Mikrotik-Generic'; +SET @template_name = 'Mikrotik-Generic'; +SET @agent_data_template_name = 'Mikrotik-Generic'; +SET @script_test = 'sleep:1 exit\n\r'; +SET @script_get_config = 'sleep:1 capture:system resource print\n\r exit\n\r'; +SET @script_set_config = 'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'; +SET @script_get_firmware = 'sleep:1 capture:/system package print\n\r exit\n\r'; +SET @script_set_firmware = 'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +ALTER TABLE `tevento` +ADD COLUMN `event_custom_id` TEXT NULL AFTER `module_status`; +-- Telegram and vonage default alerts +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=9; +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=11; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tagente' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +ALTER TABLE `tdashboard` +ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`, +ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`, +ADD COLUMN `date_to` INT NOT NULL DEFAULT 0 AFTER `date_from`; + +-- Delete table tagent_access +DROP TABLE IF EXISTS tagent_access; + +ALTER TABLE `tevent_rule` DROP COLUMN `user_comment`; +ALTER TABLE `tevent_rule` DROP COLUMN `operator_user_comment`; + +ALTER TABLE treport_content ADD check_unknowns_graph tinyint DEFAULT 0 NULL; + +ALTER TABLE `tevent_filter` ADD COLUMN `regex` TEXT NULL AFTER `private_filter_user`; +-- Update macros for plugin oracle +UPDATE `tdiscovery_apps` SET `version` = '1.1' WHERE `short_name` = 'pandorafms.oracle'; + +SET @id_app := (SELECT `id_app` FROM `tdiscovery_apps` WHERE `short_name` = 'pandorafms.oracle'); + +UPDATE `tdiscovery_apps_tasks_macros` SET `value` = 'agents_group_id=__taskGroupID__ interval=__taskInterval__ user=_dbuser_ password=_dbpass_ thick_mode=_thickMode_ client_path=_clientPath_ threads=_threads_ modules_prefix=_prefixModuleName_ execute_custom_queries=_executeCustomQueries_ analyze_connections=_checkConnections_ engine_uptime=_checkUptime_ query_stats=_queryStats_ cache_stats=_checkCache_ fragmentation_ratio=_checkFragmentation_ check_tablescpaces=_checkTablespaces_' WHERE `macro` = '_tempfileConf_' AND `id_task` IN (SELECT `id_rt` FROM `trecon_task` WHERE `id_app` = @id_app); + +INSERT IGNORE INTO `tdiscovery_apps_tasks_macros` (`id_task`, `macro`, `type`, `value`, `temp_conf`) SELECT id_rt, '_thickMode_', 'custom', 0, 0 FROM `trecon_task` WHERE `id_app` = @id_app; +INSERT IGNORE INTO `tdiscovery_apps_tasks_macros` (`id_task`, `macro`, `type`, `value`, `temp_conf`) SELECT id_rt, '_clientPath_', 'custom', '', 0 FROM `trecon_task` WHERE `id_app` = @id_app; +UPDATE `trecon_task` SET `setup_complete` = 1 WHERE `id_app` = @id_app; + +-- Update lts updates +UPDATE tconfig SET value='1' WHERE token='lts_updates'; + +SELECT @generic_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_data"; +SELECT @generic_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_proc"; +SELECT @async_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_data"; +SELECT @async_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_proc"; +UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_data WHERE `tagente_modulo`.`id_tipo_modulo` = @async_data; +UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_proc WHERE `tagente_modulo`.`id_tipo_modulo` = @async_proc; + +-- Telegram and vonage default alerts +UPDATE talert_actions SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' WHERE id=9; +UPDATE talert_actions SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' WHERE id=11; + +UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware'; + +COMMIT; diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..3095941187 --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +DELETE FROM `twelcome_tip` WHERE `title` = 'Automatic agent provision system'; + +INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Automatic agent provision system','The agent self-provisioning system allows an agent recently entered into the system to automatically apply changes to their configuration (such as moving them from group, assigning them certain values in custom fields) and of course applying certain monitoring policies. It is one of the most powerful functionalities, aimed at managing very large system parks.','https://pandorafms.com/manual/start?id=en/documentation/02_installation/05_configuration_agents#conf',1); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 28311371bf..102d8e3136 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -35,7 +35,7 @@ echo sprintf('
', $menuTypeClass); $notifications_numbers['last_id'] ).'
'; $header_welcome = ''; - if (check_acl($config['id_user'], $group, 'AW')) { + if (check_acl($config['id_user'], 0, 'AW')) { $header_welcome .= '
'; $header_welcome .= html_print_image( 'images/wizard@svg.svg', @@ -455,19 +455,28 @@ echo sprintf('
', $menuTypeClass); ); $header_logout .= '
'; + if (enterprise_installed()) { + $subtitle_header = $config['custom_subtitle_header']; + $class_header = ''; + } else { + $subtitle_header = __('the Flexible Monitoring System (OpenSource version)'); + echo ''; + $class_header = 'underline-hover modal_module_list'; + } + if (is_reporting_console_node() === true) { - echo '
'; + echo '
'; echo ''; echo $config['custom_title_header']; echo ''; echo ''; - echo $config['custom_subtitle_header']; + echo $subtitle_header; echo ''; echo '
'; echo '
'; echo '
'.$modal_help, $header_user, $header_logout.'
'; } else { - echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
+ echo '
'.$config['custom_title_header'].''.$subtitle_header.'
'.$header_searchbar.'
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $modal_help, $header_setup, $header_user, $header_logout.'
'; } @@ -916,6 +925,46 @@ echo sprintf('
', $menuTypeClass); $(document).ready (function () { + + $('.header_left').on('click', function(){ + // Hidden tips modal. + $(".window").css("display", "none"); + jQuery.post( + "ajax.php", + { + page: "include/functions_menu", + 'why_enterprise': "true" + }, + function(data) { + if (data) { + $("#dialog_why_enterprise").html(data); + // Open dialog + $("#dialog_why_enterprise").dialog({ + resizable: false, + draggable: false, + modal: true, + show: { + effect: "fade", + duration: 200 + }, + hide: { + effect: "fade", + duration: 200 + }, + closeOnEscape: true, + width: 700, + height: 450, + close: function(){ + $('#dialog_why_enterprise').html(''); + } + }); + } + }, + "html" + ); + }); + + // Check new notifications on a periodic way setInterval(check_new_notifications, 60000); diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index e18d278ac8..bbc499661f 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -418,7 +418,7 @@ switch ($login_screen) { } if ($config['enterprise_installed']) { - if ($config['reset_pass_option']) { + if ($config['reset_pass_option'] && $config['auth'] === 'mysql') { $reset_pass_link = 'reset_pass.php'; // Reset password link. echo '
'; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 9fd0d8c7ef..51893ca8a6 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -600,43 +600,176 @@ html_print_div( 'content' => html_print_table($tableAgent, true).$CodeQRTable, ] ); -/* - TODO REVIEW - $table_satellite = ''; - if ($remote_agent === true) { - // Satellite server selector. - $satellite_servers = db_get_all_rows_filter( - 'tserver', - ['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE], - [ - 'id_server', - 'name', - ] - ); - $satellite_names = []; - if (empty($satellite_servers) === false) { - foreach ($satellite_servers as $s_server) { - $satellite_names[$s_server['id_server']] = $s_server['name']; +// Basic Options. +$tableBasicAgent = new stdClass(); +$tableBasicAgent->class = 'filter-table-adv'; +$tableBasicAgent->data = []; +$disabledBasic = false; +$tableClassDisabled = ''; +if ($new_agent === true || $remote_agent === false || $has_remote_conf === false) { + $disabledBasic = true; + $tableClassDisabled = ' basic-options-disabled'; +} + +if (enterprise_installed()) { + // Get all plugins (BASIC OPTIONS). + $agent_plugin = new PandoraFMS\Agent($id_agente); + $plugins = $agent_plugin->getPlugins(); + // Check if some plugin was enabled/disabled in conf. + foreach ($plugins as $key => $row) { + if (preg_match('/pandora_hardening/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $security_hardening = 0; + } else { + $security_hardening = 1; + } } - $table_satellite = '

'.__('Satellite').'

'; - $table_satellite .= '
'; + if ($id_os === '1' || $id_os === '8') { + if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_log_collector = 0; + } else { + $enable_log_collector = 1; + } + } - $table_satellite .= html_print_input( + if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_inventory = 0; + } else { + $enable_inventory = 1; + } + } + } else { + if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) { + if ($row['disabled'] === 1) { + $enable_inventory = 0; + } else { + $enable_inventory = 1; + } + } + } + } + + if ($id_os === '9') { + $modules = $agent_plugin->getModules(); + foreach ($modules as $key => $row) { + if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_log_collector = 0; + } else { + $enable_log_collector = 1; + } + } + } + } + + unset($agent_plugin, $plugins); + if (($new_agent === true && $config['current_package'] >= 774) || ($agent_version >= 774 && $new_agent === false)) { + if ($disabledBasic === true || $has_remote_conf === false) { + $message = __('Remote config disabled, please activate to enable agent basic options'); + $tableBasicAgent->data[] = ''.$message.''; + } + + $tableBasicAgent->data[] = html_print_label_input_block( + __('Enable security hardening monitoring'), + html_print_input( [ - 'type' => 'select', - 'fields' => $satellite_names, - 'name' => 'satellite_server', - 'selected' => $satellite_server, - 'nothing' => __('None'), - 'nothinf_value' => 0, - 'return' => true, + 'type' => 'switch', + 'id' => 'security_hardening', + 'name' => 'security_hardening', + 'value' => $security_hardening, + 'disabled' => $disabledBasic, ] - ).'
'; + ).html_print_input_hidden('options_package', '1', true) + ); + + $tableBasicAgent->data[] = html_print_label_input_block( + __('Enable log collection'), + html_print_input( + [ + 'type' => 'switch', + 'id' => 'enable_log_collector', + 'name' => 'enable_log_collector', + 'value' => $enable_log_collector, + 'disabled' => $disabledBasic, + ] + ) + ); } + + $tableBasicAgent->data[] = html_print_label_input_block( + __('Enable inventory'), + html_print_input( + [ + 'type' => 'switch', + 'id' => 'enable_inventory', + 'name' => 'enable_inventory', + 'value' => $enable_inventory, + 'disabled' => $disabledBasic, + ] + ).html_print_input_hidden('enable_basic_options', '1', true) + ); + + if ($config['ehorus_enabled'] === '1') { + $pandoraRC_Id = html_print_image( + 'images/alert_recovered@svg.svg', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'title' => __('Pandora RC connected with id ').$config['ehorus_custom_field'], + ] + ); + } else { + $pandoraRC_Id = html_print_image( + 'images/alerts.svg', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'title' => __('This agent do not have a Pandora RC agent installed, install one.'), + ] + ); } -*/ + + $tableBasicAgent->data[] = html_print_label_input_block( + __('Enable remote control'), + $pandoraRC_Id + ); + + $WarningPackage = ''; + if (($new_agent === true && $config['current_package'] < 774) || ($agent_version < 774 && $new_agent === false)) { + $WarningPackage = html_print_image( + 'images/alert-yellow@svg.svg', + true, + [ + 'title' => __('Only available for agents 774 or higher'), + 'alt' => __('Only available for agents 774 or higher'), + 'class' => 'main_menu_icon mrgn_lft_5px', + ] + ); + } +} else { + $tableBasicAgent->data[] = ''.__('Remote config is enabled only in the Enteprise version').''; + $tableBasicAgent->data[] .= html_print_input_hidden( + 'enable_basic_options', + '0', + true + ); +} + +ui_toggle( + html_print_table($tableBasicAgent, true), + ''.__('Basic options').$WarningPackage.'', + '', + 'basic_options', + true, + false, + 'white_box_content', + 'no-border white_table_graph'.$tableClassDisabled, + 'box-flat white_table_graph invisible' +); // Advanced options. $tableAdvancedAgent = new stdClass(); @@ -922,22 +1055,25 @@ $tableAdvancedAgent->data['safe_operation'][] = html_print_label_input_block( ) ); -$tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block( - __('Vulnerability scanning'), - html_print_select( - [ - 0 => __('Disabled'), - 1 => __('Enabled'), - 2 => __('Use global settings'), - ], - 'vul_scan_enabled', - $vul_scan_enabled, - '', - '', - 0, - true - ) -); +if (enterprise_installed() === true) { + $tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block( + __('Vulnerability scanning'), + html_print_select( + [ + 0 => __('Disabled'), + 1 => __('Enabled'), + 2 => __('Use global settings'), + ], + 'vul_scan_enabled', + $vul_scan_enabled, + '', + '', + 0, + true + ) + ); +} + ui_toggle( html_print_table($tableAdvancedAgent, true), @@ -1101,11 +1237,24 @@ if ($new_agent === false) { $actionButtons .= html_print_input_hidden('id_agente', $id_agente); if (is_management_allowed() === true) { + $clusters = agents_get_agent_belongs_cluster($id_agente); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); + } + $actionButtons .= html_print_button( __('Delete agent'), 'deleteAgent', false, - 'deleteAgentDialog('.$id_agente.')', + 'deleteAgentDialog('.$id_agente.', "'.$cluster_belongs.'")', [ 'icon' => 'delete', 'mode' => 'secondary dialog_opener', @@ -1153,10 +1302,18 @@ ui_require_jquery_file('bgiframe'); } } - function deleteAgentDialog($idAgente) { + function deleteAgentDialog($idAgente, cluster) { + var msg_cluster = ''; + if(cluster) { + msg_cluster = ""; + msg_cluster += ': '; + msg_cluster += cluster; + msg_cluster += '. '; + } + confirmDialog({ title: "", - message: "", + message: msg_cluster + "", onAccept: function() { window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente); } @@ -1253,7 +1410,8 @@ ui_require_jquery_file('bgiframe'); }); $("#checkbox-cascade_protection").change(function () { - var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) { + var checked = $("#checkbox-cascade_protection").is(":checked"); + if (checked) { $("#cascade_protection_module").removeAttr("disabled"); $("#text-id_parent").attr("required", "required"); } @@ -1263,7 +1421,7 @@ ui_require_jquery_file('bgiframe'); $("#text-id_parent").removeAttr("required"); } }); - + var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); if (safe_mode_checked) { $("#safe_mode_module").removeAttr("disabled"); @@ -1271,10 +1429,10 @@ ui_require_jquery_file('bgiframe'); else { $("#safe_mode_module").attr("disabled", 'disabled'); } - + $("#checkbox-safe_mode").change(function () { var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); - + if (safe_mode_checked) { $("#safe_mode_module").removeAttr("disabled"); } @@ -1308,5 +1466,17 @@ ui_require_jquery_file('bgiframe'); } }); + check_basic_options(); + $('#id_os').on('change', function(){ + check_basic_options(); + }) }); + + function check_basic_options(){ + if ($('#id_os').val() == 1 || $('#id_os').val() == 8 || $('#id_os').val() == 9) { + $('#basic_options').removeClass('invisible'); + } else { + $('#basic_options').addClass('invisible'); + } + } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 09ca22062e..cad6faad62 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -232,7 +232,7 @@ if ($create_agent) { $cps = (int) get_parameter_switch('cps', -1); $fixed_ip = (int) get_parameter_switch('fixed_ip', 0); $vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2); - + $agent_version = $config['current_package']; $secondary_groups = (array) get_parameter('secondary_groups_selected', ''); $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -300,6 +300,7 @@ if ($create_agent) { 'cps' => $cps, 'fixed_ip' => $fixed_ip, 'vul_scan_enabled' => $vul_scan_enabled, + 'agent_version' => $agent_version, ] ); } else { @@ -1015,6 +1016,13 @@ if ($update_agent) { $satellite_server = (int) get_parameter('satellite_server', 0); $fixed_ip = (int) get_parameter_switch('fixed_ip', 0); $vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2); + $security_vunerability = (int) get_parameter_switch('security_vunerability', 0); + $security_hardening = (int) get_parameter_switch('security_hardening', 0); + $security_monitoring = (int) get_parameter_switch('security_monitoring', 0); + $enable_log_collector = (int) get_parameter_switch('enable_log_collector', 0); + $enable_inventory = (int) get_parameter_switch('enable_inventory', 0); + $enable_basic_options = get_parameter('enable_basic_options'); + $options_package = get_parameter('options_package', '0'); if ($fields === false) { $fields = []; @@ -1243,6 +1251,81 @@ if ($update_agent) { ); } } + + if ($enable_basic_options === '1') { + // Get all plugins (BASIC OPTIONS). + $agent = new PandoraFMS\Agent($id_agente); + $plugins = $agent->getPlugins(); + foreach ($plugins as $key => $row) { + // Only check plugins when agent package is bigger than 774. + if ($options_package === '1') { + if (preg_match('/pandora_hardening/', $row['raw']) === 1) { + if ($security_hardening === 1) { + if ($row['disabled'] === 1) { + $agent->enablePlugins($row['raw']); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disablePlugins($row['raw']); + } + } + } + + if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) { + if ($enable_log_collector === 1) { + if ($row['disabled'] === 1) { + $agent->enablePlugins($row['raw']); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disablePlugins($row['raw']); + } + } + } + } + + // Inventory switch enable when basic options are enabled. + if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) { + if ($enable_inventory === 1) { + if ($row['disabled'] === 1) { + $agent->enablePlugins($row['raw']); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disablePlugins($row['raw']); + } + } + } + + // Inventory switch enable when basic options are enabled. + if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) { + if ($enable_inventory === 1) { + if ($row['disabled'] === 1) { + $agent->enablePlugins($row['raw']); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disablePlugins($row['raw']); + } + } + } + } + + $modules = $agent->getModules(); + foreach ($modules as $key => $row) { + if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) { + if ($enable_log_collector === 1) { + if ($row['disabled'] === 1) { + $agent->enableModule($row['module_name'], $row); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disableModule($row['module_name'], $row); + } + } + } + } + } } // Read agent data @@ -1300,6 +1383,19 @@ if ($id_agente) { $satellite_server = (int) $agent['satellite_server']; $fixed_ip = (int) $agent['fixed_ip']; $vul_scan_enabled = (int) $agent['vul_scan_enabled']; + if (strpos($agent['agent_version'], '(')) { + $agent_version = (int) explode('.', explode('(', $agent['agent_version'])[0])[2]; + } else { + if (strpos($agent['agent_version'], 'build') || strpos($agent['agent_version'], 'Build')) { + $agent_version = (int) explode('.', explode('build', $agent['agent_version'])[0])[2]; + } else { + if (strpos($agent['agent_version'], '.')) { + $agent_version = (int) explode('.', $agent['agent_version'])[2]; + } else { + $agent_version = $agent['agent_version']; + } + } + } } $update_module = (bool) get_parameter('update_module'); @@ -2162,6 +2258,28 @@ if ($update_module || $create_module || ($module_in_policy && !$module_linked) ) { if ($success_action > 0) { + if (empty($old_configuration_data) === true + && empty($configuration_data) === true && $disabled === '0' + && ($enable_module || $disable_module) + ) { + $modulo_nombre = io_safe_output( + db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + (empty($disable_module) === false) ? $disable_module : $enable_module + ) + ); + + $old_configuration_data = config_agents_get_module_from_conf( + $id_agente, + $modulo_nombre + ); + $configuration_data = $old_configuration_data; + + $disabled = (empty($disable_module) === false) ? true : false; + } + enterprise_hook( 'config_agents_write_module_in_conf', [ @@ -2310,7 +2428,6 @@ if ($disable_module) { $modulo_nombre = io_safe_output($modulo_nombre['nombre']); if ($result === NOERR) { - enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias'] diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 25b06e2f5a..53b4995d20 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,6 +217,7 @@ foreach ($fields as $field) { array_push($table->data, $data); } +$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -231,6 +232,9 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - ['type' => 'form_action'] + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], ); echo ''; diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 487fe54e07..a7ee6bf4c0 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -566,10 +566,10 @@ if ($search != '') { if ($id != '') { $aux = $id[0]['id_agent']; $search_sql = sprintf( - ' AND ( nombre LIKE "%%%s%%" - OR alias LIKE "%%%s%%" - OR comentarios LIKE "%%%s%%" - OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%") + ' AND ( REPLACE(nombre, " ", " ") LIKE "%%%s%%" + OR REPLACE(alias, " ", " ") LIKE "%%%s%%" + OR REPLACE(comentarios, " ", " ") LIKE "%%%s%%" + OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, " ", " ") LIKE "%%%s%%") OR tagente.id_agente = %d', $search, $search, @@ -591,10 +591,10 @@ if ($search != '') { $search_sql .= ')'; } else { $search_sql = sprintf( - ' AND ( nombre - LIKE "%%%s%%" OR alias - LIKE "%%%s%%" OR comentarios LIKE "%%%s%%" - OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))', + ' AND ( REPLACE(nombre, " ", " ") + LIKE "%%%s%%" OR REPLACE(alias, " ", " ") + LIKE "%%%s%%" OR REPLACE(comentarios, " ", " ") LIKE "%%%s%%" + OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, " ", " ") LIKE "%%%s%%"))', $search, $search, $search, @@ -958,12 +958,33 @@ if ($agents !== false) { ); if ($check_aw === true && is_management_allowed() === true) { - if ($agent['id_os'] != CLUSTER_OS_ID) { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;'; - } else { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;'; + $clusters = agents_get_agent_belongs_cluster($agent['id_agente']); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); } + $msg = ''; + if ($agent['id_os'] == CLUSTER_OS_ID) { + $msg .= __('You are going to delete a cluster agent'); + $msg .= '. '; + } else if (empty($cluster_belongs) === false) { + $msg .= __('This agent belongs to the clusters'); + $msg .= ': '; + $msg .= $cluster_belongs; + $msg .= '. '; + } + + $msg .= __('Are you sure?'); + $onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;'; + $agentActionButtons[] = html_print_menu_button( [ 'href' => ui_get_full_url( diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 5c21fa71a0..b4cd0e2351 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -38,6 +38,7 @@ $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_servers.php'; +require_once $config['homedir'].'/include/functions_macros.php'; $search_string = get_parameter('search_string'); @@ -574,7 +575,7 @@ $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente); $search_string_entities = io_safe_input($search_string); $basic_where = sprintf( - "(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND", + "(REPLACE(nombre, ' ', ' ') LIKE '%%%s%%' OR REPLACE(nombre, ' ', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, ' ', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, ' ', ' ') LIKE '%%%s%%') AND", $search_string, $search_string_entities, $search_string, @@ -949,7 +950,23 @@ if ($modules !== false) { ); if (strlen($module['ip_target']) !== 0) { - $title .= '
IP: '.$module['ip_target']; + // Check if value is custom field. + if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') { + $custom_field_name = substr($module['ip_target'], 1, -1); + $custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name); + if (isset($custom_value) && $custom_value !== false) { + $title .= '
IP: '.$custom_value; + } else { + $array_macros = return_agent_macros($id_agente); + if (isset($array_macros[$module['ip_target']])) { + $title .= '
IP: '.$array_macros[$module['ip_target']]; + } else { + $title .= '
IP: '.$module['ip_target']; + } + } + } else { + $title .= '
IP: '.$module['ip_target']; + } } // This module is initialized ? (has real data). diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index de08a299de..c396634f67 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1391,7 +1391,6 @@ $table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( false, '', false, - false, 'wp100 static' ); @@ -2000,23 +1999,18 @@ ui_require_jquery_file('json'); $('#' + thisLabel).prop('checked', true); $('#' + thisLabel).siblings().prop('checked', false); - if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { + var type_selected = $("#id_module_type").val(); + var type_names = jQuery.parseJSON(Base64.decode($('#hidden-type_names').val())); + var type_name_selected = type_names[type_selected]; + + if (($('#radius-percentage_warning').prop('checked') === true && $('#radius-percentage_critical').prop('checked') === true) || type_name_selected == 'generic_data_string') { + paint_graph_values(); $("#svg_dinamic").hide(); } else { paint_graph_values(); $("#svg_dinamic").show(); } - if ($('#radius-percentage_warning').prop('checked') === true) { - $('#radius-warning_inverse').hide(); - $('#label-radius-warning_inverse').hide(); - } - - if ($('#radius-warning_inverse').prop('checked') === true) { - $('#radius-percentage_warning').hide(); - $('#label-radius-percentage_warning').hide(); - } - if ($('#radius-normal_warning').prop('checked') === true) { $('#radius-warning_inverse').show(); $('#label-radius-warning_inverse').show(); @@ -2024,17 +2018,6 @@ ui_require_jquery_file('json'); $('#label-radius-percentage_warning').show(); } - - if ($('#radius-percentage_critical').prop('checked') === true) { - $('#radius-critical_inverse').hide(); - $('#label-radius-critical_inverse').hide(); - } - - if ($('#radius-critical_inverse').prop('checked') === true) { - $('#radius-percentage_critical').hide(); - $('#label-radius-percentage_critical').hide(); - } - if ($('#radius-normal_critical').prop('checked') === true) { $('#radius-critical_inverse').show(); $('#label-radius-critical_inverse').show(); @@ -2351,30 +2334,48 @@ ui_require_jquery_file('json'); var message_error_percentage = ''; //if haven't error - if (max_w == 0 || max_w > min_w) { - if (max_c == 0 || max_c > min_c) { - paint_graph_status( - min_w, max_w, min_c, max_c, inverse_w, - inverse_c, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + if (max_w == 0 || max_w > min_w || $('#radius-percentage_warning').is(':checked') === true) { + if (max_c == 0 || max_c > min_c || $('#radius-percentage_critical').is(':checked') === true) { + error_c = 0; + error_w = 0; } else { error_c = 1; - paint_graph_status( - 0, 0, 0, 0, 0, 0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + min_w = 0; + max_w = 0; + min_c = 0; + max_c = 0; + inverse_w = 0; + inverse_c = 0; } } else { + if (max_c !== 0 && max_c < min_c && $('#radius-percentage_critical').is(':checked') === false) { + error_c = 2; + } error_w = 1; - paint_graph_status( - 0, 0, 0, 0, 0, 0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + min_w = 0; + max_w = 0; + min_c = 0; + max_c = 0; + inverse_w = 0; + inverse_c = 0; } + + if ($('#radius-percentage_warning').is(':checked') === true){ + min_w = 0; + max_w = 0; + } + + if ($('#radius-percentage_critical').is(':checked') === true){ + min_c = 0; + max_c = 0; + } + + paint_graph_status( + min_w, max_w, min_c, max_c, inverse_w, + inverse_c, error_w, error_c, + legend_normal, legend_warning, legend_critical, + message_error_warning, message_error_critical + ); } /* ]]> */ diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 970a2c4d9f..9b5d98c27d 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -171,7 +171,7 @@ foreach ($password_fields as $k => $p) { } $(document).ready(function () { - if ($("#id_plugin").val() === 0) { + if ($("#id_plugin").val() !== 0) { changePluginSelect(); } }); diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index eb85a05618..095708d2b1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -131,9 +131,10 @@ if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { } $data = []; -$data[0] = __('Agent'); -$data[1] = __('Module'); -$data[2] = __('Period'); + +$data[0] = __('Module'); +$data[1] = __('Period'); + $table_simple->cellclass['caption_prediction_module'][0] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][1] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][2] = 'w33p'; @@ -163,34 +164,68 @@ $params['none_module_text'] = __('Select Module'); $params['use_hidden_input_idagent'] = true; $params['input_style'] = 'width: 100%;'; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; -$data[0] = ui_print_agent_autocomplete_input($params); -if ($id_agente > 0) { - $predictionModuleInput = html_print_select_from_sql( - 'SELECT id_agente_modulo, nombre - FROM tagente_modulo - WHERE delete_pending = 0 - AND history_data = 1 - AND id_agente = '.$id_agente_clean.' - AND id_agente_modulo <> '.$id_agente_modulo, +if (strstr($page, 'policy_modules') === false) { + $modules = agents_get_modules($id_agente); + + $predictionModuleInput = html_print_select( + $modules, 'prediction_module', $prediction_module, '', - __('Select Module'), + '', 0, true, false, true, + '', false, - 'width: 100%;' + false, + false, + false, + false, + '', + false, + false, + false, + false, + true, + false, + false, + '', + false, + 'pm' ); } else { - $predictionModuleInput = ''; + $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); + + $predictionModuleInput = html_print_select( + $modules, + 'id_module_policy', + $module['custom_integer_1'], + '', + '', + 0, + true, + false, + true, + '', + false, + false, + false, + false, + false, + '', + false, + false, + true + ); } -$data[1] = $predictionModuleInput; -$data[2] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); -$data[2] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); +$data[0] = $predictionModuleInput; +$data[1] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); +$data[1] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); + $table_simple->cellclass['prediction_module'][0] = 'w33p'; $table_simple->cellclass['prediction_module'][1] = 'w33p'; $table_simple->cellclass['prediction_module'][2] = 'w33p'; @@ -264,7 +299,7 @@ if ($selector_form !== ENTERPRISE_NOT_HOOK) { } // Synthetic modules are an Enterprise feature. -$synthetic_module_form = enterprise_hook('get_synthetic_module_form'); +$synthetic_module_form = enterprise_hook('get_synthetic_module_form', [$policy_id]); if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; $data[0] = $synthetic_module_form; diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 003ec45d03..8236d1e69c 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -31,13 +31,14 @@ if (is_ajax()) { return; } - echo '

'.$template['name'].'

'; + echo '

'.$template['name'].'

'; + echo html_print_image('images/info.svg', true, ['class' => 'invert_filter']); + echo ui_print_alert_template_example($template['id'], true, true, false); + echo '
'; + echo '
'; echo ''.__('Type').': '; echo alerts_get_alert_templates_type_name($template['type']); - echo '
'; - echo ui_print_alert_template_example($template['id'], true); - echo '
'; if ($template['description'] != '') { diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 8d4d07e578..7809742221 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -256,7 +256,7 @@ $schedule = io_safe_output( $data[0] = ''; $data[0] .= html_print_input_hidden('schedule', $schedule, true); -$data[0] .= '
'; +$data[0] .= '
'; $data[1] = ''; $table_conditions->data[] = $data; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 4718689da5..6d33077bf8 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -520,7 +520,7 @@ $(document).ready (function () { name: "id_action", value: "" }); - + jQuery.post (, values, function (data, status) { @@ -552,6 +552,9 @@ $(document).ready (function () { // If the row is empty, hide it if (field_row == '') { + // Clear hidden fields. + $("[name=field" + i + "_value]").val(''); + $("[name=field" + i + "_recovery_value]").val('') $table_macros_field.hide(); continue; } diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index bbd758d9a9..7365339191 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -1240,7 +1240,7 @@ if ($step == 2) { 'priority', $priority, '', - 0, + '', 0, true, false, diff --git a/pandora_console/godmode/db/db_main.php b/pandora_console/godmode/db/db_main.php index 9979b2c224..3bd4052ba2 100644 --- a/pandora_console/godmode/db/db_main.php +++ b/pandora_console/godmode/db/db_main.php @@ -27,7 +27,6 @@ if (! check_acl($config['id_user'], 0, 'DM')) { // Get some general DB stats (not very heavy) // NOTE: this is not realtime monitoring stats, are more focused on DB sanity -$stat_access = db_get_sql('SELECT COUNT(*) FROM tagent_access WHERE id_agent != 0'); $stat_data = db_get_sql('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo != 0'); $stat_data_log4x = db_get_sql('SELECT COUNT(*) FROM tagente_datos_log4x WHERE id_agente_modulo != 0'); $stat_data_string = db_get_sql('SELECT COUNT(*) FROM tagente_datos_string WHERE id_agente_modulo != 0'); @@ -149,18 +148,6 @@ echo $stat_modules; echo ''; - -echo ''; -echo __('Total agent access records'); -echo ''; -if ($stat_access > $max_access) { - echo "$stat_access"; -} else { - echo $stat_access; -} - -echo ''; - // Sanity echo ''; echo __('Database sanity'); diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index c91a2df8fe..4ab84fa76b 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -115,6 +115,7 @@ $fields_available['module_status'] = __('Module Status'); $fields_available['mini_severity'] = __('Severity mini'); $fields_available['module_custom_id'] = __('Module custom ID'); $fields_available['custom_data'] = __('Custom data'); +$fields_available['event_custom_id'] = __('Event Custom ID'); // Remove fields already selected. diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index a6f282d2cf..cc9ed5d5f0 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -68,7 +68,7 @@ foreach ($layer_ids as $layer_id) { $layer_list[] = [ 'id' => (strpos($layer_id, 'new_') === false) ? (int) $layer_id : null, 'layer_name' => $trimmed_name, - 'layer_visible' => ((int) $layers[$layer_id]['visible'] === 1), + 'layer_visible' => ($layers[$layer_id]['visible'] === 'true'), 'layer_group' => (int) $layers[$layer_id]['agents_from_group'], 'layer_agent_list' => $layers[$layer_id]['agents'], 'layer_group_list' => $layers[$layer_id]['groups'], @@ -243,10 +243,15 @@ switch ($action) { $map_default_altitude = get_parameter('map_default_altitude'); $map_group_id = get_parameter('map_group_id'); $map_levels_zoom = get_parameter('map_levels_zoom', 16); - $map_connection_list_temp = explode(',', get_parameter('map_connection_list')); + $map_connection_list_temp_string = implode(',', $map_connection_list_temp); + if (strlen($map_connection_list_temp_string) > 0) { + $where_map_connection = ' WHERE id_tmap_connection IN('.$map_connection_list_temp_string.')'; + } else { + $where_map_connection = ''; + } - $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); + $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'.$where_map_connection); foreach ($map_connection_list_temp as $index => $value) { $cleanValue = trim($value); @@ -256,7 +261,6 @@ switch ($action) { } $map_connection_default = get_parameter('map_connection_default'); - $map_connection_list = []; foreach ($listConnectionTemp as $idMapConnection) { $default = 0; @@ -345,7 +349,7 @@ function deleteConnectionMap(idConnectionMap) { checked = $("#radiobtn0001", $("#map_connection_" + idConnectionMap)).attr('checked'); $("#map_connection_" + idConnectionMap).remove(); - + if (checked) { //Checked first, but not is index = 0 maybe. @@ -485,7 +489,7 @@ foreach ($listConnectionTemp as $connectionTemp) { $table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][1] = " -
".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)." + ".html_print_select($listConnection, 'select-map_connection_list', '', '', '', '0', true)." ".html_print_image( @@ -560,21 +564,23 @@ html_print_table($table); $user_groups = users_get_groups($config['user'], 'AR', false); -echo '

'.__('Layers').'

'; +echo '
'.__('Layers').''; $table->width = '100%'; $table->class = 'databox filters'; $table->valign = []; -$table->valign[0] = 'top'; -$table->valign[1] = 'top'; +$table->valign[0] = 'top; width: 50%'; +$table->valign[1] = 'top; width: 50%'; $table->data = []; $table->data[0][0] = '

'.__('List of layers').'

'; $table->data[0][1] = '
'.html_print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub add "', true).'
'; -$table->data[1][0] = '
'; -$table->data[1][1] = '
'; switch ($action) { case 'save_new': @@ -1229,6 +1237,8 @@ function getLayerRow (layerId, layerData) { .append($editCol) .append($deleteCol); + $("#list_layers").removeClass('invisible'); + return $row; } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 00bbdddb39..66717bc35b 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -84,6 +84,9 @@ if (is_ajax() === true) { } $group = db_get_row('tgrupo', 'id_grupo', $id_group); + if (str_contains($group['icon'], '.png') === true) { + $group['folder'] = 'groups_small/'; + } echo json_encode($group); return; @@ -757,6 +760,125 @@ if ($tab == 'tree') { /* * Group tree view. */ + + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters filter-table-adv'; + if (is_metaconsole() === true) { + $table->cellspacing = 0; + $table->cellpadding = 0; + } + + $search_group_string = get_parameter('search_group_string', ''); + $search_agent_string = get_parameter('search_agent_string', ''); + $agent_status = get_parameter('agent_status', ''); + $show_not_init_agents = get_parameter('show_not_init_agents', 1); + $show_not_init_modules = get_parameter('show_not_init_modules', 1); + $show_full_hirearchy = get_parameter('show_full_hirearchy', 1); + + + $table->data = []; + $table->head = []; + $table->style = []; + + $table->style[0] = 'width: 50%;'; + $table->style[1] = 'width: 50%;'; + + $table->data[0][0] = html_print_label_input_block( + __('Search group'), + html_print_input_text( + 'search_group_string', + $search_group_string, + '', + 25, + 255, + true, + false, + false, + '', + ) + ); + + $agents_status_list = agents_status_list(); + + $table->data[0][1] = html_print_label_input_block( + __('Search by agent status').ui_print_help_tip(__('Shows the groups that contain an agent with the status that has been searched'), true), + html_print_select( + $agents_status_list, + 'agent_status', + $agent_status, + '', + __('All'), + '', + true, + false, + false, + 'w200p', + false, + 'width: 100%;' + ) + ); + + $table->data[1][0] = html_print_label_input_block( + __('Search by agent').ui_print_help_tip(__('Shows groups that contain an agent matching the search'), true), + html_print_input_text( + 'search_agent_string', + $search_agent_string, + '', + 25, + 255, + true, + false, + false, + '', + ) + ); + + $table->data[1][1] = html_print_label_input_block( + __('Show full hierarchy'), + html_print_checkbox_switch_extended( + 'show_full_hirearchy', + 1, + $show_full_hirearchy, + false, + '', + '', + true + ) + ); + + $table->data[3][0] = ' '; + + $table->data[3][1] = html_print_submit_button( + __('Filter'), + 'filter', + false, + [ + 'class' => 'float-right', + 'icon' => 'search', + ], + true + ); + + $form = "
"; + $form .= html_print_table($table, true); + $form .= '
'; + + + + ui_toggle( + $form, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); + + echo "
"; } else { /* @@ -826,6 +948,8 @@ if ($tab == 'tree') { ); $form .= ''; + + ui_toggle( $form, ''.__('Filters').'', @@ -1058,87 +1182,119 @@ $tab = 'group_edition'; diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 560de898e9..a8f7930b26 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -154,7 +154,7 @@ if ($is_management_allowed === true && $update_group === true) { $subcheck = db_get_value('name', 'tmodule_group', 'id_mg', $id_group); if ($name) { - if (!$check || $subcheck == $name) { + if ($check === false || strcasecmp($subcheck, $name) === 0) { $result = db_process_sql_update( 'tmodule_group', ['name' => $name], diff --git a/pandora_console/godmode/massive/massive_add_alerts.php b/pandora_console/godmode/massive/massive_add_alerts.php index 57261a357b..ad5cc00e27 100755 --- a/pandora_console/godmode/massive/massive_add_alerts.php +++ b/pandora_console/godmode/massive/massive_add_alerts.php @@ -255,7 +255,18 @@ $table->data[1][1] = html_print_select( true, '', false, - 'width:180px;' + 'width:180px;', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, + true ); $table->data[1][2] = __('When select agents'); $table->data[1][2] .= '
'; @@ -271,7 +282,31 @@ $table->data[1][2] .= html_print_select( '', true ); -$table->data[1][3] = html_print_select([], 'module[]', '', false, '', '', true, true, false, '', false, 'width:180px;'); +$table->data[1][3] = html_print_select( + [], + 'module[]', + '', + false, + '', + '', + true, + true, + false, + '', + false, + 'width:180px;', + false, + false, + false, + '', + true, + false, + false, + false, + true, + true, + false +); $usr_groups = users_get_groups($config['id_user'], 'LW', true); $filter_groups = ''; diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index cad37a3a29..0cd712e124 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -111,7 +111,8 @@ if ($delete) { $alerts_agent_modules = []; foreach ($agent_alerts['simple'] as $agent_alert) { if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) { - $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + // $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + $alerts_agent_modules[] = $agent_alert['id']; } } @@ -126,7 +127,7 @@ if ($delete) { $agent_module_actions = []; foreach ($alerts_agent_modules as $alert_agent_module) { - $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']); + $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']); foreach ($agent_module_actions as $agent_module_action) { foreach ($actions as $action) { diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 94509ab820..ace5659ce7 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -367,6 +367,8 @@ if ($access_console_node === true) { $sub['godmode/alerts/alert_list']['text'] = __('List of Alerts'); $sub['godmode/alerts/alert_list']['id'] = 'List_of_Alerts'; $sub['godmode/alerts/alert_list']['pages'] = ['godmode/alerts/alert_view']; + $sub['godmode/agentes/planned_downtime.list']['text'] = __('Scheduled downtime'); + $sub['godmode/agentes/planned_downtime.list']['id'] = 'scheduled_downtime'; if ((bool) check_acl($config['id_user'], 0, 'LM') === true) { $sub['godmode/alerts/alert_templates']['text'] = __('Templates'); @@ -476,8 +478,8 @@ if ($access_console_node === true) { } } - $sub2['godmode/setup/setup§ion=ehorus']['text'] = __('Pandora RC'); - $sub2['godmode/setup/setup§ion=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup§ion=pandorarc']['text'] = __('Pandora RC'); + $sub2['godmode/setup/setup§ion=pandorarc']['refr'] = 0; $sub2['godmode/setup/setup§ion=ITSM']['text'] = __('ITSM'); $sub2['godmode/setup/setup§ion=ITSM']['refr'] = 0; @@ -573,12 +575,13 @@ if ($access_console_node === true) { continue; } + $extmenu = []; if ($extension['godmode_menu']['name'] !== __('DB Schema check') && $extension['godmode_menu']['name'] !== __('DB interface')) { $extmenu = $extension['godmode_menu']; } // Check the ACL for this user. - if ((bool) check_acl($config['id_user'], 0, $extmenu['acl']) === false) { + if ((bool) check_acl($config['id_user'], 0, ($extmenu['acl'] ?? '')) === false) { continue; } @@ -708,6 +711,17 @@ if ($access_console_node === true) { } if ($access_console_node === true) { + // Tools + $menu_godmode['tools']['text'] = __('Tools'); + $menu_godmode['tools']['sec2'] = 'operation/extensions'; + $menu_godmode['tools']['id'] = 'oper-extensions'; + $sub = []; + $sub['operation/agentes/exportdata']['text'] = __('Export data'); + $sub['operation/agentes/exportdata']['id'] = 'export_data'; + $sub['extensions/files_repo']['text'] = __('File repository'); + $sub['extensions/files_repo']['id'] = 'file_repository'; + $menu_godmode['tools']['sub'] = $sub; + // About. $menu_godmode['about']['text'] = __('About'); $menu_godmode['about']['id'] = 'about'; @@ -719,7 +733,7 @@ if ((bool) $config['pure'] === false) { echo '
'; // Need to be here because the translate string. -if (check_acl($config['id_user'], $group, 'AW')) { +if (check_acl($config['id_user'], 0, 'AW')) { ?> diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index d3fd439181..e92e038dfe 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -777,7 +777,7 @@ $table->data[0][0] = html_print_label_input_block( ) ); $table->data[0][1] = html_print_label_input_block( - __('Poisition'), + __('Position'), html_print_input_text_extended( 'position_to_delete', 1, diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php index c0381acca2..d4914d2b58 100755 --- a/pandora_console/godmode/reporting/reporting_builder.main.php +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -180,8 +180,8 @@ if ($report_id_user == $config['id_user'] $options['div_class'] = ''; } - $table->data[2][1] = html_print_label_input_block( - __('Group'), + $table->data[3][0] = html_print_label_input_block( + __('Write Access Group'), html_print_select_groups( false, 'RW', @@ -216,7 +216,7 @@ if ($enterpriseEnable) { if (enterprise_installed() === true) { - $table->data[3][0] = html_print_label_input_block( + $table->data[4][0] = html_print_label_input_block( __('Generate cover page in PDF render'), html_print_checkbox_switch( 'cover_page_render', @@ -226,7 +226,7 @@ if (enterprise_installed() === true) { ) ); - $table->data[3][1] = html_print_label_input_block( + $table->data[4][1] = html_print_label_input_block( __('Generate index in PDF render'), html_print_checkbox_switch( 'index_render', diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 095f79b14a..7d75b5bd27 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1643,7 +1643,7 @@ switch ($action) { $es['log_number'] = $log_number; $values['external_source'] = json_encode($es); - $values['period'] = get_parameter('period'); + $values['period'] = get_parameter('period3'); $good_format = true; break; @@ -1661,7 +1661,7 @@ switch ($action) { $es['log_number'] = $log_number; $values['external_source'] = json_encode($es); - $values['period'] = get_parameter('period'); + $values['period'] = get_parameter('period3'); $values['period_range'] = get_parameter('period_range'); $values['show_graph'] = get_parameter('combo_graph_options'); $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); @@ -1730,10 +1730,20 @@ switch ($action) { $good_format = true; break; + case 'service_level': + $es['period_time_service_level'] = get_parameter('period_time_service_level', '28800'); + $es['show_agents'] = get_parameter('show_agents', false); case 'agent_module': case 'agent_module_status': $agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); + if ($agents_to_report_text === '' || $agents_to_report_text === 'null') { + $agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', ''))); + } + $modules_to_report_text = get_parameter('module-multiple-text', ''); + if ($modules_to_report_text === '' || $modules_to_report_text === 'null') { + $modules_to_report_text = io_safe_input(json_encode(get_parameter('module', ''))); + } // Decode json check modules. $agents_to_report = json_decode( @@ -1745,11 +1755,16 @@ switch ($action) { true ); + $es['module'] = get_same_modules_all( $agents_to_report, $modules_to_report ); + if ((bool) is_metaconsole() === true) { + $es['module'] = $modules_to_report; + } + // Encode json modules and agents. $es['module'] = base64_encode(json_encode($es['module'])); $es['id_agents'] = base64_encode(json_encode($agents_to_report)); @@ -1928,6 +1943,7 @@ switch ($action) { $values['graph_render'] = (int) get_parameter( 'graph_render' ); + $values['check_unknowns_graph'] = get_parameter_switch('unknowns_graph', 0); case 'simple_baseline_graph': // HACK it is saved in show_graph field. $values['show_graph'] = (int) get_parameter( @@ -2045,6 +2061,70 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'vuls_severity_graph': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_attack_complexity': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_by_packages': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_by_agent': + $values['id_group'] = get_parameter('combo_group'); + $es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter'); + $es['secmon_status'] = get_parameter('secmon_status'); + $es['security_hardening_score'] = get_parameter('security_hardening_score'); + $es['vulnerabilities_status'] = get_parameter('vulnerabilities_status'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + + case 'vuls_info_agent': + $values['id_agent'] = get_parameter('id_agent'); + $es['server_id'] = get_parameter('server_id'); + $es['vul_package'] = get_parameter('vul_package'); + $es['vul_severity'] = get_parameter('vul_severity'); + $es['vul_ac'] = get_parameter('vul_ac'); + $es['vul_pr'] = get_parameter('vul_pr'); + $es['vul_ui'] = get_parameter('vul_ui'); + $es['vul_av'] = get_parameter('vul_av'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + + case 'top_n_agents_vuls': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_vuls_count': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2065,7 +2145,10 @@ switch ($action) { break; } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); $values['id_agent_module'] = ''; @@ -2181,7 +2264,10 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ($values['server_name'] == '') { $values['server_name'] = get_parameter( @@ -2704,7 +2790,7 @@ switch ($action) { $es['log_number'] = $log_number; $values['external_source'] = json_encode($es); - $values['period'] = get_parameter('period'); + $values['period'] = get_parameter('period3'); $good_format = true; break; @@ -2722,17 +2808,27 @@ switch ($action) { $es['log_number'] = $log_number; $values['external_source'] = json_encode($es); - $values['period'] = get_parameter('period'); + $values['period'] = get_parameter('period3'); $values['period_range'] = get_parameter('period_range'); $values['show_graph'] = get_parameter('combo_graph_options'); $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); $good_format = true; break; + case 'service_level': + $es['period_time_service_level'] = get_parameter('period_time_service_level', '28800'); + $es['show_agents'] = get_parameter('show_agents', false); case 'agent_module': case 'agent_module_status': - $agents_to_report_text = get_parameter('id_agents2-multiple-text'); + $agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); + if ($agents_to_report_text === '' || $agents_to_report_text === 'null') { + $agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', ''))); + } + $modules_to_report_text = get_parameter('module-multiple-text', ''); + if ($modules_to_report_text === '' || $modules_to_report_text === 'null') { + $modules_to_report_text = io_safe_input(json_encode(get_parameter('module', ''))); + } // Decode json check modules. $agents_to_report = json_decode( @@ -2749,11 +2845,14 @@ switch ($action) { $modules_to_report ); + if ((bool) is_metaconsole() === true) { + $es['module'] = $modules_to_report; + } + // Encode json modules and agents. $es['module'] = base64_encode(json_encode($es['module'])); $es['id_agents'] = base64_encode(json_encode($agents_to_report)); $es['show_type'] = get_parameter('show_type', 0); - $values['external_source'] = json_encode($es); $good_format = true; break; @@ -2867,6 +2966,7 @@ switch ($action) { $values['graph_render'] = (int) get_parameter( 'graph_render' ); + $values['check_unknowns_graph'] = get_parameter_switch('unknowns_graph', 0); case 'simple_baseline_graph': // HACK it is saved in show_graph field. $values['show_graph'] = (int) get_parameter( @@ -2977,6 +3077,71 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'vuls_severity_graph': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_attack_complexity': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_by_packages': + $values['id_group'] = get_parameter('combo_group'); + $good_format = true; + break; + + case 'vuls_by_agent': + $values['id_group'] = get_parameter('combo_group'); + $es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter'); + $es['secmon_status'] = get_parameter('secmon_status'); + $es['security_hardening_score'] = get_parameter('security_hardening_score'); + $es['vulnerabilities_status'] = get_parameter('vulnerabilities_status'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + + case 'vuls_info_agent': + $values['id_agent'] = get_parameter('id_agent'); + $es['server_id'] = get_parameter('server_id'); + $es['vul_package'] = get_parameter('vul_package'); + $es['vul_severity'] = get_parameter('vul_severity'); + $es['vul_ac'] = get_parameter('vul_ac'); + $es['vul_pr'] = get_parameter('vul_pr'); + $es['vul_ui'] = get_parameter('vul_ui'); + $es['vul_av'] = get_parameter('vul_av'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + + case 'top_n_agents_vuls': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_vuls_count': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -3003,7 +3168,10 @@ switch ($action) { ); } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); if (($values['type'] == 'alert_report_agent') || ($values['type'] == 'event_report_agent') @@ -3117,7 +3285,9 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ((($values['type'] == 'custom_graph') diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php index 5ce3c3f679..f5cc8d059c 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.data.php +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -151,7 +151,7 @@ $table->data[0][] = html_print_label_input_block( __('Name'), html_print_input_text( 'name', - $visualConsoleName, + io_safe_output($visualConsoleName), '', 80, 100, diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index 300ea33f40..c4f83e2d02 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) { $table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true); $table->data[($i + 1)][5] .= '
'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; $table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true); + $table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true); // Second row $table->data[($i + 2)]['icon'] = ''; @@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) { $pure = get_parameter('pure', 0); -if (is_metaconsole() === false) { - echo '
'; - html_print_input_hidden('action', 'update'); -} else { - echo ""; - html_print_input_hidden('action2', 'update'); -} - html_print_table($table); // Form for multiple delete. @@ -806,15 +799,14 @@ if (is_metaconsole() === false) { $url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id']; } -echo '
'; - $buttons = html_print_submit_button( __('Update'), 'go', false, [ - 'icon' => 'next', - 'form' => 'vc_elem_form', + 'icon' => 'next', + 'form' => 'vc_elem_form', + 'onclick' => 'submit_update_json()', ], true ); @@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/'); return false; } + + function submit_update_json() { + var array_update = []; + $('input[id^=hidden-updated_]').each(function(){ + var id = $(this).attr('id').split('_')[1]; + + var label = $('#hidden-label_'+id).val(); + var image = $('#image_'+id).val(); + var width = $('#text-width_'+id).val(); + var height = $('#text-height_'+id).val(); + var pos_x = $('#text-left_'+id).val(); + var pos_y = $('#text-top_'+id).val(); + var parent = $('#parent_'+id).val(); + var agent = $('#hidden-agent_'+id).val(); + var module = $('#module_'+id).val(); + var period = $('#hidden-period_'+id).val(); + var map_linked = $('#map_linked_'+id).val(); + var id_server = $('#id_server_id_'+id).val(); + var rowtype = $('rowtype_'+id).val(); + var custom_graph = $('#custom_graph_'+id).val(); + + array_update.push({ + 'id': id, + 'label': label, + 'image': image, + 'width': width, + 'height': height, + 'pos_x': pos_x, + 'pos_y': pos_y, + 'parent': parent, + 'agent': agent, + 'module': module, + 'period': period, + 'map_linked': map_linked, + 'rowtype': rowtype, + 'custom_graph': custom_graph, + 'id_server': id_server, + }); + }); + + var background_width = $('#text-width').val(); + var background_height = $('#text-height').val(); + + if (background_height > 0 && background_width > 0){ + $.ajax({ + type: "POST", + url: "ajax.php", + data: { + page: "godmode/reporting/visual_console_builder", + action: "update_json", + tab: "list_elements", + array_update: JSON.stringify(array_update), + id_visual_console: "", + background: $('#background').val(), + background_width: $('#text-width').val(), + background_height: $('#text-height').val(), + }, + dataType: "json", + complete: function (data) { + location.reload(); + } + }); + } else { + confirmDialog({ + title: "", + message: "", + strOKButton: "", + hideCancelButton: true, + size: 300, + }); + } + } diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 986dcb423b..7c04892524 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues( 'update', 'delete', 'multiple_delete', + 'update_json', ], 'new' ); @@ -164,6 +165,9 @@ switch ($activeTab) { $width = (int) get_parameter('width'); $height = (int) get_parameter('height'); $visualConsoleName = (string) get_parameter('name'); + $visualConsoleName = str_replace('<', '', $visualConsoleName); + $visualConsoleName = str_replace('>', '', $visualConsoleName); + $visualConsoleName = (string) io_safe_input($visualConsoleName); $is_favourite = (int) get_parameter('is_favourite_sent'); $auto_adjust = (int) get_parameter('auto_adjust_sent'); @@ -239,7 +243,7 @@ switch ($activeTab) { if ($uploadOK == 1) { if (move_uploaded_file($_FILES['background_image']['tmp_name'], $target_file)) { $background = $nameImage; - $values['background'] = $background; + $values['background'] = io_safe_input($background); $error2 = chmod($target_file, 0644); $uploadOK = $error2; } else { @@ -523,6 +527,110 @@ switch ($activeTab) { } break; + case 'update_json': + // Update background. + $background = get_parameter('background'); + $width = get_parameter('background_width'); + $height = get_parameter('background_height'); + + if ($width == 0 && $height == 0) { + $sizeBackground = getimagesize( + $config['homedir'].'/images/console/background/'.$background + ); + $width = $sizeBackground[0]; + $height = $sizeBackground[1]; + } + + db_process_sql_update( + 'tlayout', + [ + 'background' => $background, + 'width' => $width, + 'height' => $height, + ], + ['id' => $idVisualConsole] + ); + + // Return the updated visual console. + $visualConsole = db_get_row_filter( + 'tlayout', + ['id' => $idVisualConsole] + ); + + // Update elements in visual map. + $idsElements = db_get_all_rows_filter( + 'tlayout_data', + ['id_layout' => $idVisualConsole], + [ + 'id', + 'type', + ] + ); + + $array_update = json_decode(io_safe_output(get_parameter('array_update')), true); + + if (count($array_update)) { + foreach ($array_update as $row) { + $id = $row['id']; + $values = []; + $values['label'] = $row['label']; + $values['image'] = $row['image']; + $values['width'] = $row['width']; + $values['height'] = $row['height']; + $values['pos_x'] = $row['pos_x']; + $values['pos_y'] = $row['pos_y']; + + switch ($row['rowtype']) { + case NETWORK_LINK: + case LINE_ITEM: + continue 2; + + break; + + case SIMPLE_VALUE_MAX: + case SIMPLE_VALUE_MIN: + case SIMPLE_VALUE_AVG: + $values['period'] = $row['period']; + break; + + case MODULE_GRAPH: + $values['period'] = $row['period']; + unset($values['image']); + break; + + case GROUP_ITEM: + $values['id_group'] = $row['group']; + break; + + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: + case PERCENTILE_BUBBLE: + case PERCENTILE_BAR: + unset($values['height']); + break; + } + + if (defined('METACONSOLE')) { + $values['id_metaconsole'] = $row['id_server']; + } + + $values['id_agent'] = $row['agent']; + $values['id_agente_modulo'] = $row['module']; + $values['id_custom_graph'] = $row['custom_graph']; + $values['parent_item'] = $row['parent']; + $values['id_layout_linked'] = $row['map_linked']; + + if (enterprise_installed()) { + enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id); + } + + db_process_sql_update('tlayout_data', $values, ['id' => $id]); + } + + return true; + } + break; + case 'delete': $id_element = get_parameter('id_element'); $result = db_process_sql_delete('tlayout_data', ['id' => $id_element]); @@ -872,7 +980,7 @@ $buttons[$activeTab]['active'] = true; $tab_builder = ($activeTab === 'editor') ? 'visual_console_editor_editor_tab' : ''; ui_print_standard_header( - ($visualConsoleName ?? ''), + (io_safe_output($visualConsoleName) ?? ''), 'images/visual_console.png', false, $tab_builder, diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 315702528e..39acc45c21 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -860,8 +860,10 @@ if (empty($create) === false || empty($view) === false) { if ($management_allowed === false) { ui_print_warning_message( __( - 'This console is not manager of this environment, - please manage this feature from centralized manager console (Metaconsole).' + 'This console is not manager of this environment, please manage this feature from feature from %s.', + ''.__('metaconsole').'' ) ); } diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 101a99d955..516a62ea82 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -64,32 +64,33 @@ $table->style = []; // $table->style[0] = 'font-weight: bold'; $table->align = []; $table->align[1] = 'center'; -$table->align[3] = 'center'; -$table->align[8] = 'right'; +$table->align[4] = 'center'; +$table->align[9] = 'right'; $table->headstyle[1] = 'text-align:center'; -$table->headstyle[3] = 'text-align:center'; -$table->headstyle[8] = 'text-align:right;width: 120px;'; +$table->headstyle[4] = 'text-align:center'; +$table->headstyle[9] = 'text-align:right;width: 120px;'; $table->titleclass = 'tabletitle'; $table->titlestyle = 'text-transform:uppercase;'; -$table->style[6] = 'display: flex;align-items: center;'; +$table->style[7] = 'display: flex;align-items: center;'; $table->head = []; $table->head[0] = __('Name'); $table->head[1] = __('Status'); $table->head[2] = __('Type'); -$table->head[3] = __('Version'); -$table->head[4] = __('Modules'); -$table->head[5] = __('Lag').ui_print_help_tip(__('Avg. Delay(sec)/Modules delayed'), true); -$table->head[6] = __('T/Q').ui_print_help_tip(__('Threads / Queued modules currently'), true); +$table->head[3] = __('Master'); +$table->head[4] = __('Version'); +$table->head[5] = __('Modules'); +$table->head[6] = __('Lag').ui_print_help_tip(__('Avg. Delay(sec)/Modules delayed'), true); +$table->head[7] = __('T/Q').ui_print_help_tip(__('Threads / Queued modules currently'), true); // This will have a column of data such as "6 hours". -$table->head[7] = __('Updated'); +$table->head[8] = __('Updated'); // Only Pandora Administrator can delete servers. if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $table->head[8] = ''.__('Op.').''; + $table->head[9] = ''.__('Op.').''; } $table->data = []; @@ -143,9 +144,11 @@ foreach ($servers as $server) { } // Type. - $data[2] = ''.$server['img']; + $data[2] = ''.$server['img'].'    '.$server['name']; if ($server['master'] == $master) { - $data[2] .= ui_print_help_tip(__('This is a master server'), true); + $data[3] .= __('Yes', true); + } else { + $data[3] .= __('-'); } if ((int) $server['exec_proxy'] === 1) { @@ -157,27 +160,27 @@ foreach ($servers as $server) { case 'event': case 'autoprovision': case 'migration': - $data[3] = $server['version']; - $data[4] = __('N/A'); + $data[4] = $server['version']; $data[5] = __('N/A'); + $data[6] = __('N/A'); break; case 'export': - $data[3] = $server['version']; - $data[4] = $server['modules'].' '.__('of').' '.$server['modules_total']; - $data[5] = __('N/A'); + $data[4] = $server['version']; + $data[5] = $server['modules'].' '.__('of').' '.$server['modules_total']; + $data[6] = __('N/A'); break; default: - $data[3] = $server['version']; - $data[4] = $server['modules'].' '.__('of').' '.$server['modules_total']; - $data[5] = ''.$server['lag_txt'].''; + $data[4] = $server['version']; + $data[5] = $server['modules'].' '.__('of').' '.$server['modules_total']; + $data[6] = ''.$server['lag_txt'].''; break; } - $data[6] = ''; - if ($server['queued_modules'] > 500) { - $data[6] .= '
'.html_print_image( + $data[7] = ''; + if ($server['queued_modules'] >= $config['number_modules_queue']) { + $data[7] .= '  '; } - $data[6] .= $server['threads'].' : '.$server['queued_modules']; + $data[7] .= $server['threads'].' : '.$server['queued_modules']; - $data[7] = ui_print_timestamp($server['keepalive'], true); + $data[8] = ui_print_timestamp($server['keepalive'], true); if ($server['type'] === 'data') { $ext = '_server'; @@ -208,11 +211,11 @@ foreach ($servers as $server) { // Only Pandora Administrator can delete servers. if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $data[8] = ''; + $data[9] = ''; if ($server['type'] === 'recon') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/snmp-trap@svg.svg', true, [ @@ -221,12 +224,12 @@ foreach ($servers as $server) { ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($server['type'] === 'data') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/force@svg.svg', true, [ @@ -234,10 +237,10 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } else if ($server['type'] === 'enterprise snmp') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/force@svg.svg', true, [ @@ -245,12 +248,12 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($server['type'] === 'event' && (bool) check_acl($config['id_user'], 0, 'LM') === true) { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/alert@svg.svg', true, [ @@ -258,11 +261,11 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/edit.svg', true, [ @@ -270,11 +273,11 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/agents@svg.svg', true, [ @@ -282,10 +285,10 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/remote-configuration@svg.svg', true, [ @@ -293,12 +296,12 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; $names_servers[$safe_server_name] = false; } - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/delete.svg', true, [ @@ -307,14 +310,14 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($tiny) { - unset($data[4]); - unset($data[6]); + unset($data[5]); unset($data[7]); unset($data[8]); + unset($data[9]); } $ext = ''; @@ -323,10 +326,10 @@ foreach ($servers as $server) { } if ($tiny) { - unset($table->head[4]); - unset($table->head[6]); + unset($table->head[5]); unset($table->head[7]); unset($table->head[8]); + unset($table->head[9]); } if ($tiny) { diff --git a/pandora_console/godmode/setup/file_manager.php b/pandora_console/godmode/setup/file_manager.php index cfcf3c0827..211af66cb7 100644 --- a/pandora_console/godmode/setup/file_manager.php +++ b/pandora_console/godmode/setup/file_manager.php @@ -71,6 +71,8 @@ if (isset($config['filemanager']['message']) === true) { $fallback_directory = 'images'; // Get directory. $directory = (string) get_parameter('directory'); +$directory = str_replace('<', '', $text); +$directory = str_replace('>', '', $text); if (empty($directory) === true) { $directory = $fallback_directory; } else { diff --git a/pandora_console/godmode/setup/links.php b/pandora_console/godmode/setup/links.php index fc27454b48..20e61e95b0 100644 --- a/pandora_console/godmode/setup/links.php +++ b/pandora_console/godmode/setup/links.php @@ -54,8 +54,12 @@ if (isset($_POST['create'])) { if (! $result) { ui_print_error_message(__('There was a problem creating link')); } else { - ui_print_success_message(__('Successfully created')); $id_link = $result; + ui_print_result_message( + $id_link, + __('Successfully created'), + __('Could not be created') + ); } } @@ -111,8 +115,8 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { $link = ''; } - echo ''; echo ''; + echo '
'; if ($creation_mode == 1) { echo ""; } else { @@ -179,10 +183,10 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { ) ); - echo '
'; + echo '
'; } else { - // Main list view for Links editor - $rows = db_get_all_rows_in_table('tlink', 'name'); + // Main list view for Links editor. + $rows = db_get_all_fields_in_table('tlink', '', '', 'name'); if ($rows === false) { $rows = []; } diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index 2d0e54a681..6313aa3edd 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -46,7 +46,7 @@ if ($idOS > 0) { $description = $os['description']; $icon = $os['icon_name']; } else { - $name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); + $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $icon = get_parameter('icon', 0); } @@ -87,9 +87,16 @@ if ($is_management_allowed === true) { if (in_array($file_ext, $allowed_extensions) === false) { $message = 9; + } else if (exif_imagetype($file_tmp) === false && $file_ext !== 'svg') { + $message = 10; } else { $message = 8; - move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + $file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + if ($file_uploaded !== true) { + $message = 10; + } } } } else { @@ -108,7 +115,7 @@ if ($is_management_allowed === true) { if ($resultOrId === false) { $message = 2; - $tab = 'builder'; + $tab = 'manage_os'; $actionHidden = 'save'; $textButton = __('Create'); $classButton = ['icon' => 'wand']; @@ -144,13 +151,19 @@ if ($is_management_allowed === true) { if (in_array($file_ext, $allowed_extensions) === false) { $message = 9; + } else if (exif_imagetype($file_tmp) === false) { + $message = 10; } else { $message = 8; - move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + $file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + if ($file_uploaded !== true) { + $message = 10; + } } } } else { - $name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); + $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $icon = get_parameter('icon', 0); @@ -254,7 +267,7 @@ $table->class = 'databox filter-table-adv'; $table->data[0][] = html_print_label_input_block( __('Name'), - html_print_input_text('name', $name, __('Name'), 20, 30, true, false, false, '', 'w250px') + html_print_input_text('name', $name, __('Name'), 20, 30, true, false, true, '', 'w250px') ); $table->data[0][] = html_print_label_input_block( @@ -290,6 +303,28 @@ html_print_action_buttons( echo ''; +$id_message = get_parameter('id_message', 0); + +if ($id_message !== 0) { + switch ($id_message) { + case 8: + echo ui_print_success_message(__('Icon successfuly uploaded'), '', true); + break; + + case 9: + echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); + break; + + case 10: + echo ui_print_error_message(__('An error ocurrered to upload icon'), '', true); + break; + + default: + // Nothing to do. + break; + } +} + function get_list_os_icons_dir() { diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index 99402ff30a..dcfe95ecdb 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -162,11 +162,15 @@ if (empty($id_message) === false) { break; case 8: - echo ui_print_success_message(__('Icon successfuly uploaded'), '', true); + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=8'); break; case 9: - echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=9'); + break; + + case 10: + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=10'); break; default: diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 51cd554a66..870c4c283a 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -154,8 +154,7 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) { $performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control'])); $total_agents = db_get_value('count(*)', 'tagente'); -$disable_agentaccess = ($total_agents >= 200 && $config['agentaccess'] == 0) ? true : false; - +// $disable_agentaccess = ($total_agents >= 200 && $config['agentaccess'] == 0) ? true : false; $table_status = new StdClass(); $table_status->width = '100%'; $table_status->class = 'databox filters'; @@ -666,8 +665,8 @@ $table_other->data[2][1] = html_print_label_input_block( true ) ); - -$table_other->data[3][0] = html_print_label_input_block( +/* + $table_other->data[3][0] = html_print_label_input_block( __('Use agent access graph'), html_print_checkbox_switch( 'agentaccess', @@ -676,9 +675,9 @@ $table_other->data[3][0] = html_print_label_input_block( true, $disable_agentaccess ) -); - -$table_other->data[3][1] = html_print_label_input_block( + ); +*/ +$table_other->data[3][0] = html_print_label_input_block( __('Max. recommended number of files in attachment directory'), html_print_input_text( 'num_files_attachment', diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..1de74e1123 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -93,7 +93,7 @@ $buttons['general'] = [ 'images/setup.png', true, [ - 'title' => __('General'), + 'title' => __('General setup'), 'class' => 'invert_filter', ] @@ -184,7 +184,7 @@ $buttons['ITSM'] = [ $buttons['ehorus'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/RC.png', true, [ @@ -265,7 +265,7 @@ if (enterprise_installed()) { switch ($section) { case 'general': $buttons['general']['active'] = true; - $subpage = __('General'); + $subpage = __('General setup'); $help_header = 'setup_general_tab'; break; @@ -297,7 +297,7 @@ switch ($section) { $help_header = 'setup_flow_tab'; break; - case 'ehorus': + case 'pandorarc': $buttons['ehorus']['active'] = true; $subpage = __('Pandora RC'); $help_header = 'setup_ehorus_tab'; @@ -370,14 +370,14 @@ switch ($section) { break; default: - $subpage = 'seccion: '.$section; + $subpage = 'seccion: '; // Default. break; } // Header. ui_print_standard_header( - $subpage, + __('Setup').' » '.$subpage, '', false, $help_header, @@ -388,6 +388,10 @@ ui_print_standard_header( 'link' => '', 'label' => __('Setup'), ], + [ + 'link' => '', + 'label' => $subpage, + ], ] ); @@ -438,7 +442,7 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; break; - case 'ehorus': + case 'pandorarc': include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index 3196ef677c..012d80f849 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -187,7 +187,8 @@ $button_test .= ' '; $row['control'] = html_print_label_input_block( __('Test connection pandora to ITSM'), - $button_test + $button_test, + ['div_class' => 'ITSM-remote-setup-ITSM_token'] ); $table_remote->data['ITSM_test'] = $row; diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 40a816a6fa..f9f2afcd14 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -535,16 +535,47 @@ html_print_action_buttons( __('Update'), 'update_button', false, - [ 'icon' => 'update' ], + [ + 'icon' => 'update', + 'onclick' => 'onFormSubmit()', + ], true ) ); echo ''; +echo ui_print_warning_message( + [ + 'message' => __('Session timeout must be a number'), + 'force_class' => 'invisible js_warning_msg', + ], + '', + true +); ?> diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index b939a01825..9e6f6ee180 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -83,6 +83,19 @@ $table->data[3][] = html_print_label_input_block( html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); +$table->data[4][] = html_print_label_input_block( + __('Enable Sflow'), + html_print_checkbox_switch_extended( + 'activate_sflow', + 1, + $config['activate_sflow'], + $rbt_disabled, + '', + '', + true + ), +); + echo '
'; html_print_table($table); html_print_input_hidden('update_config', 1); diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 99895b3464..5f76fd1f9c 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -1952,6 +1952,7 @@ if ($create_alert || $update_alert) { [ 'border' => '0', 'alt' => __('Delete'), + 'class' => 'invert_filter main_menu_icon', ] ).' '; $data[1] .= ''; diff --git a/pandora_console/godmode/um_client/index.php b/pandora_console/godmode/um_client/index.php index c79502626a..1a78e39b5f 100644 --- a/pandora_console/godmode/um_client/index.php +++ b/pandora_console/godmode/um_client/index.php @@ -61,7 +61,7 @@ $license = db_get_value( ); if (isset($config['lts_updates']) === false) { - $config['lts_updates'] = false; + $config['lts_updates'] = true; } if (empty($license) === true) { diff --git a/pandora_console/godmode/update_manager/modal_lts_update.php b/pandora_console/godmode/update_manager/modal_lts_update.php new file mode 100644 index 0000000000..fc744b3b57 --- /dev/null +++ b/pandora_console/godmode/update_manager/modal_lts_update.php @@ -0,0 +1,111 @@ + + + + + + \ No newline at end of file diff --git a/pandora_console/godmode/update_manager/update_manager.php b/pandora_console/godmode/update_manager/update_manager.php index e201bc14dd..3cb774c4d5 100644 --- a/pandora_console/godmode/update_manager/update_manager.php +++ b/pandora_console/godmode/update_manager/update_manager.php @@ -119,11 +119,13 @@ switch ($tab) { case 'setup': include $config['homedir'].'/godmode/update_manager/update_manager.setup.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; case 'offline': $mode = \UpdateManager\UI\Manager::MODE_OFFLINE; include $config['homedir'].'/godmode/um_client/index.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; case 'online': @@ -163,5 +165,6 @@ switch ($tab) { $mode = \UpdateManager\UI\Manager::MODE_ONLINE; include $config['homedir'].'/godmode/um_client/index.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; } diff --git a/pandora_console/godmode/update_manager/update_manager.setup.php b/pandora_console/godmode/update_manager/update_manager.setup.php index ac5471f96a..6fb56aed15 100644 --- a/pandora_console/godmode/update_manager/update_manager.setup.php +++ b/pandora_console/godmode/update_manager/update_manager.setup.php @@ -63,6 +63,10 @@ if (users_is_admin()) { } } +if (isset($config['lts_updates']) === false) { + config_update_value('lts_updates', 1); +} + if (!$action_update_url_update_manager) { $url_update_manager = get_parameter( 'url_update_manager', diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index c2089ab298..83e54f24c5 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -155,14 +155,92 @@ if (is_ajax() === true) { return; } + + if ($delete_profile === true) { + // Get parameters. + $result = false; + $id_user = (string) get_parameter('id_user'); + $id_up = (int) get_parameter('id_user_profile'); + $delete_user = (bool) get_parameter('delete_user', false); + $user_is_global_admin = users_is_admin($id_user); + + $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); + $id_perfil = $perfilUser['id_perfil']; + + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + 'Deleted profile for user '.io_safe_output($id_user), + false, + false, + 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] + ); + // Delete profile. + $profile_deleted = profile_delete_user_profile($id_user, $id_up); + // Check if exists more profiles. + $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id_user); + if ($profile_deleted === true) { + if ($has_profile === false && $user_is_global_admin === false && $delete_user === true) { + if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + // Connect to the remote console. + metaconsole_connect($server); + + // Delete the user. + $result = delete_user($id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s from metaconsole', io_safe_output($id_user)) + ); + } + + // Restore the db connection. + metaconsole_restore_db(); + + // Log to the metaconsole too. + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __( + 'Deleted user %s from %s', + io_safe_input($id_user), + io_safe_input($server['server_name']) + ) + ); + } + } + + $result = delete_user((string) $id_user); + + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s', io_safe_output($id_user)) + ); + } + } else { + $result = delete_user((string) $id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s', io_safe_output($id_user)) + ); + } + } + } else { + $result = $profile_deleted; + } + } + + return $result; + } } $tab = get_parameter('tab', 'user'); - // Save autorefresh list. $autorefresh_list = (array) get_parameter_post('autorefresh_list'); $autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list); - // Header. if (is_metaconsole() === true) { user_meta_print_header(); @@ -195,11 +273,11 @@ if (is_metaconsole() === true) { ).'', ], ]; - $buttons[$tab]['active'] = true; } $edit_user = get_parameter('edit_user'); + ui_print_standard_header( ($edit_user) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), 'images/gm_users.png', @@ -222,11 +300,9 @@ if (is_metaconsole() === true) { ], ] ); - $sec = 'gusuarios'; } - if ((bool) $config['user_can_update_info'] === true) { $view_mode = false; } else { @@ -348,8 +424,10 @@ if ($create_user === true) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -596,8 +674,11 @@ if ($update_user) { $values['email'] = (string) get_parameter('email'); $values['phone'] = (string) get_parameter('phone'); $values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments')))); - $values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0); - $values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list')))); + if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) { + $values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0); + $values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list')))); + } + $values['is_admin'] = (get_parameter('is_admin', 0) === 0) ? 0 : 1; $values['language'] = (string) get_parameter('language'); $values['timezone'] = (string) get_parameter('timezone'); @@ -643,8 +724,10 @@ if ($update_user) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -686,23 +769,55 @@ if ($update_user) { $id_user = (string) get_parameter('id_user', ''); if ($password_new != '') { - $correct_password = false; + if ($config['auth'] !== 'mysql') { + ui_print_error_message(__('It is not possible to change the password because external authentication is being used')); + } else { + $correct_password = false; - $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); + $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); - if ($user_credentials_check !== false) { - $correct_password = true; - } + if ($user_credentials_check !== false) { + $correct_password = true; + } - if ((string) $password_confirm === (string) $password_new) { - if ($correct_password === true || is_user_admin($config['id_user'])) { - if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { - $pass_ok = login_validate_pass($password_new, $id, true); - if ($pass_ok != 1) { - ui_print_error_message($pass_ok); + if ((string) $password_confirm === (string) $password_new) { + if ($correct_password === true || is_user_admin($config['id_user'])) { + if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { + $pass_ok = login_validate_pass($password_new, $id, true); + if ($pass_ok != 1) { + ui_print_error_message($pass_ok); + } else { + $res2 = update_user_password($id, $password_new); + if ($res2) { + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password updated', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + $res3 = save_pass_history($id, $password_new); + + // Generate new API token. + $newToken = api_token_generate(); + $res4 = update_user($id, ['api_token' => $newToken]); + } + + ui_print_result_message( + $res1 || $res2, + __('User info successfully updated'), + __('Error updating user info (no change?)') + ); + } } else { $res2 = update_user_password($id, $password_new); if ($res2) { + $res3 = save_pass_history($id, $password_new); db_process_sql_insert( 'tsesion', [ @@ -715,7 +830,6 @@ if ($update_user) { 'utimestamp' => time(), ] ); - $res3 = save_pass_history($id, $password_new); // Generate new API token. $newToken = api_token_generate(); @@ -729,54 +843,27 @@ if ($update_user) { ); } } else { - $res2 = update_user_password($id, $password_new); - if ($res2) { - $res3 = save_pass_history($id, $password_new); - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password updated', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - - // Generate new API token. - $newToken = api_token_generate(); - $res4 = update_user($id, ['api_token' => $newToken]); + if ($own_password_confirm === '') { + ui_print_error_message(__('Password of the active user is required to perform password change')); + } else { + ui_print_error_message(__('Password of active user is not correct')); } - - ui_print_result_message( - $res1 || $res2, - __('User info successfully updated'), - __('Error updating user info (no change?)') - ); } } else { - if ($own_password_confirm === '') { - ui_print_error_message(__('Password of the active user is required to perform password change')); - } else { - ui_print_error_message(__('Password of active user is not correct')); - } + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password update failed', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + ui_print_error_message(__('Passwords does not match')); } - } else { - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password update failed', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - ui_print_error_message(__('Passwords does not match')); } } else { $has_skin = false; @@ -862,89 +949,6 @@ if ($update_user) { $user_info = $values; } -if ($delete_profile) { - $id2 = (string) get_parameter('id_user'); - $id_up = (int) get_parameter('id_user_profile'); - $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); - $id_perfil = $perfilUser['id_perfil']; - $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); - - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - 'Deleted profile for user '.io_safe_output($id2), - false, - false, - 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] - ); - - $return = profile_delete_user_profile($id2, $id_up); - ui_print_result_message( - $return, - __('Successfully deleted'), - __('Could not be deleted') - ); - - - $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2); - $user_is_global_admin = users_is_admin($id2); - - if ($has_profile === false && $user_is_global_admin === false) { - $result = delete_user($id2); - - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s', io_safe_output($id_user)) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted'), - __('There was a problem deleting the user') - ); - - // Delete the user in all the consoles. - if (is_metaconsole() === true) { - $servers = metaconsole_get_servers(); - foreach ($servers as $server) { - // Connect to the remote console. - metaconsole_connect($server); - - // Delete the user. - $result = delete_user($id_user); - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s from metaconsole', io_safe_output($id_user)) - ); - } - - // Restore the db connection. - metaconsole_restore_db(); - - // Log to the metaconsole too. - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __( - 'Deleted user %s from %s', - io_safe_input($id_user), - io_safe_input($server['server_name']) - ) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted from %s', io_safe_input($server['server_name'])), - __('There was a problem deleting the user from %s', io_safe_input($server['server_name'])) - ); - } - } - } -} - if ((int) $status !== -1) { ui_print_result_message( $status, @@ -1155,6 +1159,13 @@ if (is_user_admin($id) === true) { ); } +html_print_div( + [ + 'id' => 'delete_profile_modal', + 'content' => '', + ] +); + $full_name = '
'.html_print_input_text_extended( 'fullname', $user_info['fullname'], @@ -1927,24 +1938,87 @@ if (is_metaconsole() === false) { } }); }); - + $('input:image[name="del"]').click(function(e) { - if ($(json_profile).length > 0) return; - if (!confirm('Are you sure?')) return; - e.preventDefault(); - var rows = $("#table_profiles tr").length; - if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { - if (!confirm('' + '. ' + '')) { - return; - } - } + + var rows = $("#table_profiles tr").length; + let deleteuser = 0; + e.preventDefault(); var id_user_profile = $(this).siblings(); id_user_profile = id_user_profile[1].value; var row = $(this).closest('tr'); + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') { + $("#delete_profile_modal") + .empty() + .html(""); + // Set the title. + $("#delete_profile_modal").prop("title", ""); + // Build the dialog for show the mesage. + $("#delete_profile_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 500, + buttons: [ + { + text: "Cancel", + click: function() { + $(this).dialog("close"); + return false; + } + }, + { + text: "Delete", + click: function() { + $(this).dialog("close"); + deleteuser = 1; + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + }, + { + text: "Preserve", + click: function() { + $(this).dialog("close"); + deleteuser = 0; + delete_user_profile(id_user_profile, row, id_user, deleteuser) + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); + } else { + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { + if (!confirm('' + '. ' + '')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } else { + if (!confirm('Are you sure?')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } + } + + if ($(json_profile).length > 0) return; + }); + + function delete_user_profile(id_user_profile, row, id_user, deleteuser){ var params = []; params.push("delete_profile=1"); + params.push("edit_user=1"); + params.push("delete_user=" + deleteuser); params.push("id_user=" + id_user); params.push("id_user_profile=" + id_user_profile); params.push("page=godmode/users/configure_user"); @@ -1955,15 +2029,14 @@ if (is_metaconsole() === false) { success: function(data) { row.remove(); var rows = $("#table_profiles tr").length; - - if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1') { + if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); - } else if (is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1') { + } else if (is_metaconsole === '1' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); } } }); - }); + } function checkProfiles(e) { e.preventDefault(); diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 8d9efea97b..b1212c11ec 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -81,6 +81,11 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select( false, 'width: 100%' ); +// Home screen. Visual consoles. +$customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); +// Home screen. External link and Other. +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true); $layouts = visual_map_get_user_layouts($config['id_user'], true); $layouts_aux = []; @@ -327,7 +332,7 @@ $passwordManageTable->data = []; $passwordManageTable->data['captions_newpassword'][0] = __('New password'); $passwordManageTable->rowclass['fields_newpassword'] = 'w540px'; -$passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_newpassword'][0] = '
'.html_print_input_text_extended( 'password_new', '', 'password_new', @@ -337,16 +342,17 @@ $passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_exte $view_mode, '', [ - 'class' => 'input w100p', + 'class' => 'input', 'placeholder' => __('Password'), + 'style' => 'width: 540px', ], true, true -); +).'
'; $passwordManageTable->data['captions_repeatpassword'][0] = __('Repeat new password'); $passwordManageTable->rowclass['fields_repeatpassword'] = 'w540px'; -$passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_repeatpassword'][0] = '
'.html_print_input_text_extended( 'password_confirm', '', 'password_conf', @@ -358,10 +364,11 @@ $passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_e [ 'class' => 'input w100p', 'placeholder' => __('Password confirmation'), + 'style' => 'width: 540px', ], true, true -); +).'
'; if ($new_user === false && users_is_admin() === false) { $passwordManageTable->data['captions_currentpassword'][0] = __('Current password'); @@ -857,50 +864,56 @@ $userManagementTable->data['fields_addSettings'][0] = html_print_textarea( '' ); -$userManagementTable->data['captions_addSettings'][1] = __('Login allowed IP list'); -$userManagementTable->data['fields_addSettings'][1] = html_print_div( - [ - 'class' => 'edit_user_allowed_ip', - 'content' => html_print_textarea( - 'allowed_ip_list', - 5, - 65, - ($user_info['allowed_ip_list'] ?? ''), - (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), - true - ), - ], - true -); +if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) { + $allowAllIpsContent = []; + $allowAllIpsContent[] = ''.__('Enable IP allowlist').''; + $allowAllIpsContent[] = html_print_div( + [ + 'content' => html_print_checkbox_switch( + 'allowed_ip_active', + 0, + ($user_info['allowed_ip_active'] ?? 0), + true, + false, + 'handleIpAllowlist(this)' + ), + ], + true + ); -$userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder( - __('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), - true -); + $userManagementTable->data['captions_addSettings'][1] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $allowAllIpsContent), + ], + true + ); -$allowAllIpsContent = []; -$allowAllIpsContent[] = ''.__('Allow all IPs').''; -$allowAllIpsContent[] = html_print_div( - [ - 'content' => html_print_checkbox_switch( - 'allowed_ip_active', - 0, - ($user_info['allowed_ip_active'] ?? 0), - true - ), - ], - true -); - -$userManagementTable->data['fields_addSettings'][1] .= html_print_div( - [ - 'class' => 'margin-top-10', - 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', - 'content' => implode('', $allowAllIpsContent), - ], - true -); + $userManagementTable->data['fields_addSettings'][1] .= html_print_div( + [ + 'class' => 'edit_user_allowed_ip '.(((int) $user_info['allowed_ip_active'] === 1) ? '' : 'invisible'), + 'content' => html_print_textarea( + 'allowed_ip_list', + 5, + 65, + ($user_info['allowed_ip_list'] ?? ''), + (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), + true + ), + ], + true + ); + $userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder( + __('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), + true, + [ + 'id' => 'info_allowed_ip', + 'class' => ((int) $user_info['allowed_ip_active'] === 1) ? 'input_sub_placeholder' : 'input_sub_placeholder invisible', + ] + ); +} if ($config['ITSM_enabled'] && $config['ITSM_user_level_conf']) { // Pandora ITSM user remote login. @@ -1038,4 +1051,14 @@ $(document).ready(function () { } }) }); + +function handleIpAllowlist(e){ + if(e.checked === true) { + $('.edit_user_allowed_ip').show(); + $('#info_allowed_ip').show(); + } else { + $('.edit_user_allowed_ip').hide(); + $('#info_allowed_ip').hide(); + } +} \ No newline at end of file diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e831022c23..d088e8c84f 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -1422,6 +1422,14 @@ class DiscoveryTaskList extends HTML $table->rowid = []; $table->data = []; + $countErrors = 1; + $tableErrors = new StdClasS(); + $tableErrors->class = 'databox data'; + $tableErrors->width = '75%'; + $tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;'; + $tableErrors->rowid = []; + $tableErrors->data = []; + if ($task['review_mode'] == DISCOVERY_RESULTS) { $agents_review = db_get_all_rows_filter( 'tdiscovery_tmp_agents', @@ -1476,11 +1484,11 @@ class DiscoveryTaskList extends HTML $countSummary = 1; if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) { foreach ($task['stats'] as $key => $summary) { - $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; - $table->data[$i][1] = ''; - $countSummary++; - $i++; if (is_array($summary) === true) { + $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; + $table->data[$i][1] = ''; + $countSummary++; + $i++; if (empty($summary['summary']) === true && empty($summary['info']) === true) { $table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT); $table->data[$i][1] = ''; @@ -1517,8 +1525,12 @@ class DiscoveryTaskList extends HTML $i++; } } else { - $table->data[$i][0] = $summary; - $table->data[$i][1] = ''; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $summary; + $tableErrors->data[$i][1] = ''; + $countErrors++; $i++; } } @@ -1560,12 +1572,26 @@ class DiscoveryTaskList extends HTML $table->data[$i++][1] .= ''; } } else { - $table->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][1] = ''; + $countErrors++; + $i++; } } $output = '
'.__('Summary').'
'; - $output .= html_print_table($table, true).'
'; + if (is_array($table->data) === true && count($table->data) > 0) { + $output .= html_print_table($table, true); + } + + if (is_array($tableErrors->data) === true && count($tableErrors->data) > 0) { + $output .= html_print_table($tableErrors, true); + } + + $output .= '
'; } return $output; diff --git a/pandora_console/images/desacoplar-ventana.svg b/pandora_console/images/desacoplar-ventana.svg new file mode 100644 index 0000000000..0b3cbca31d --- /dev/null +++ b/pandora_console/images/desacoplar-ventana.svg @@ -0,0 +1,14 @@ + + + Icons/Dark/20/desacoplar-ventana + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/donut.svg b/pandora_console/images/donut.svg new file mode 100644 index 0000000000..67c8733d33 --- /dev/null +++ b/pandora_console/images/donut.svg @@ -0,0 +1,7 @@ + + + donut + + + + \ No newline at end of file diff --git a/pandora_console/images/minimizar.svg b/pandora_console/images/minimizar.svg new file mode 100644 index 0000000000..957268b4ea --- /dev/null +++ b/pandora_console/images/minimizar.svg @@ -0,0 +1,7 @@ + + + Icons/Dark/20/minimizar + + + + \ No newline at end of file diff --git a/pandora_console/images/widgets/service_level.png b/pandora_console/images/widgets/service_level.png new file mode 100644 index 0000000000..685744641f Binary files /dev/null and b/pandora_console/images/widgets/service_level.png differ diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index d742f952e8..6ed1d582cb 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) { } $idGroup = $filter_alert['ag_group']; + $search_sg = $filter_alert['search_sg']; $tag_filter = $filter_alert['tag']; $action_filter = $filter_alert['action']; @@ -651,31 +652,30 @@ if ($get_agent_alerts_datatable === true) { if (is_metaconsole() === true) { include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php'; if ($idAgent !== 0) { - $alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); + $alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter); - $countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); + $countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter); } else { $id_groups = array_keys( users_get_groups($config['id_user'], 'AR', false) ); + $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, $search_sg); - $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); - - $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); + $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, $search_sg); } } else { if ($idAgent !== 0) { - $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); + $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter); - $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); + $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter); } else { $id_groups = array_keys( users_get_groups($config['id_user'], $access, false) ); - $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false); + $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, false, $search_sg); - $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false); + $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, false, $search_sg); } } diff --git a/pandora_console/include/ajax/dashboard.ajax.php b/pandora_console/include/ajax/dashboard.ajax.php index f07d1aee57..50a0e0b7a1 100644 --- a/pandora_console/include/ajax/dashboard.ajax.php +++ b/pandora_console/include/ajax/dashboard.ajax.php @@ -99,10 +99,26 @@ if ($method === 'draw') { $table->data = []; + $where_name = ''; if (strlen($filter['free_search']) > 0) { - $where = 'WHERE name LIKE "%'.$filter['free_search'].'%"'; - } else { - $where = ''; + $where_name = 'name LIKE "%'.$filter['free_search'].'%"'; + } + + $where_group = ''; + if (empty($filter['group']) === false && $filter['group'] !== '0') { + $where_group = sprintf('id_group = %s', $filter['group']); + if (empty($where_name) === false) { + $where_group = 'AND '.$where_group; + } + } + + $where = ''; + if (empty($where_name) === false || empty($where_group) === false) { + $where = sprintf( + 'WHERE %s %s', + $where_name, + $where_group + ); } $sql = 'SELECT * FROM tdashboard '.$where.' ORDER BY id '.$pagination; diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 7e8341c4a1..0aea4cf37f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -92,6 +92,9 @@ $get_id_source_event = get_parameter('get_id_source_event'); $node_id = (int) get_parameter('node_id', 0); $settings_modal = get_parameter('settings', 0); $parameters_modal = get_parameter('parameters', 0); +$update_event_custom_id = get_parameter('update_event_custom_id', 0); +$draw_events_graph = get_parameter('drawEventsGraph', false); + // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); @@ -311,6 +314,7 @@ if ($save_event_filter) { $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); + $values['regex'] = get_parameter('regex'); $values['not_search'] = get_parameter('not_search'); $values['text_agent'] = get_parameter('text_agent'); $values['id_agent'] = get_parameter('id_agent'); @@ -379,6 +383,7 @@ if ($update_event_filter) { $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); + $values['regex'] = get_parameter('regex'); $values['not_search'] = get_parameter('not_search'); $values['text_agent'] = get_parameter('text_agent'); $values['id_agent'] = get_parameter('id_agent'); @@ -638,6 +643,8 @@ function load_form_filter() { $("#status").val(val); if (i == 'search') $('#text-search').val(val); + if (i == 'regex') + $('#text-regex').val(val); if (i == 'not_search') $('#checkbox-not_search').val(val); if (i == 'text_agent') @@ -968,6 +975,7 @@ function save_new_filter() { "severity" : $("#severity").val(), "status" : $("#status").val(), "search" : $("#text-search").val(), + "regex" : $('#text-regex').val(), "not_search" : $("#checkbox-not_search").val(), "text_agent" : $("#text_id_agent").val(), "id_agent" : $('input:hidden[name=id_agent]').val(), @@ -1048,6 +1056,7 @@ function save_update_filter() { "severity" : $("#severity").val(), "status" : $("#status").val(), "search" : $("#text-search").val(), + "regex" : $('#text-regex').val(), "not_search" : $("#checkbox-not_search").val(), "text_agent" : $("#text_id_agent").val(), "id_agent" : $('input:hidden[name=id_agent]').val(), @@ -2642,6 +2651,8 @@ if ($get_events_fired) { $filter['date_to'] = date('Y-m-d', $end); $filter['time_from'] = date('H:i:s', $start); $filter['time_to'] = date('H:i:s', $end); + $filter['severity'] = explode(',', $filter['severity']); + $data = events_get_all( ['te.*'], $filter @@ -2751,3 +2762,56 @@ if ($draw_row_response_info === true) { echo $output; return; } + +if ($update_event_custom_id) { + $event_custom_id = get_parameter('event_custom_id'); + $event_id = get_parameter('event_id'); + $server_id = 0; + if (is_metaconsole() === true) { + $server_id = (int) get_parameter('server_id'); + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($event_custom_id))) { + $return = false; + } else { + try { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node = new Node($server_id); + $node->connect(); + } + + $return = events_event_custom_id( + $event_id, + $event_custom_id + ); + } catch (\Exception $e) { + // Unexistent agent. + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + + $return = false; + } finally { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + } + } + + echo ($return === true) ? 'update_ok' : 'update_error'; + return; +} + +if ((bool) $draw_events_graph === true) { + $filter = get_parameter('filter'); + $output = event_print_graph($filter); + echo $output; + return; +} \ No newline at end of file diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 3d77c7ba30..67e9ad648f 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -35,6 +35,7 @@ if (check_login()) { include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_ui.php'; + include_once $config['homedir'].'/include/functions_macros.php'; enterprise_include_once('include/functions_metaconsole.php'); $get_plugin_macros = get_parameter('get_plugin_macros'); @@ -755,6 +756,7 @@ if (check_login()) { $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $id_agent = (int) get_parameter('id_agente'); $id_agente = $id_agent; + $id_grupo = agents_get_agent_group($id_agent); $show_notinit = (bool) get_parameter('show_notinit'); $cluster_list = (int) get_parameter('cluster_list'); $sortField = (string) get_parameter('sort_field'); @@ -1168,7 +1170,9 @@ if (check_login()) { ); } + $data[2] .= ''; $data[2] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '…', 'font-size: 9pt;'); + $data[2] .= ''; if (empty($module['extended_info']) === false) { $data[2] .= ui_print_help_tip($module['extended_info'], true, '/images/default_list.png'); } @@ -1204,7 +1208,23 @@ if (check_login()) { ); if (strlen($module['ip_target']) !== 0) { - $title .= '
IP: '.$module['ip_target']; + // Check if value is custom field. + if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') { + $custom_field_name = substr($module['ip_target'], 1, -1); + $custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name); + if (isset($custom_value) && $custom_value !== false) { + $title .= '
IP: '.$custom_value; + } else { + $array_macros = return_agent_macros($id_agente); + if (isset($array_macros[$module['ip_target']])) { + $title .= '
IP: '.$array_macros[$module['ip_target']]; + } else { + $title .= '
IP: '.$module['ip_target']; + } + } + } else { + $title .= '
IP: '.$module['ip_target']; + } } $last_status_change_text = __('Time elapsed since last status change: '); @@ -1361,10 +1381,12 @@ if (check_login()) { $additionalLinkAction = '&flag=1'; $linkCaption = __('Force checks'); $imgaction = 'images/force@svg.svg'; + $visibility = ''; } else { $additionalLinkAction = ''; $linkCaption = __('Refresh'); $imgaction = 'images/go-back@svg.svg'; + $visibility = 'visibility: initial;'; } $moduleActionButtons[] = html_print_anchor( @@ -1376,6 +1398,7 @@ if (check_login()) { [ 'title' => __('Force remote check'), 'class' => 'main_menu_icon forced_title', + 'style' => $visibility, ] ), ], diff --git a/pandora_console/include/ajax/notifications.ajax.php b/pandora_console/include/ajax/notifications.ajax.php index 36ea95900d..a69ad1b56e 100644 --- a/pandora_console/include/ajax/notifications.ajax.php +++ b/pandora_console/include/ajax/notifications.ajax.php @@ -38,6 +38,10 @@ if ($change_label === '1') { $source = get_parameter('source', 0); $user = get_parameter('user', ''); $value = get_parameter('value', 0) ? 1 : 0; + $user_info = get_user_info($config['id_user']); + if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { + return false; + } // Update the label value. ob_clean(); diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index 59469a16e3..5f83d79b88 100755 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -251,7 +251,7 @@ if ($change_custom_fields_macros_report === true) { } if ($get_agents === true) { - $agents_id = str_replace('"', '', $agents_id); + $agents_id = str_replace('"', '"', $agents_id); try { $agents_id = json_decode($agents_id, true); diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 319b98e168..7b47fa8b42 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -59,6 +59,7 @@ if (is_ajax() === true) { $metaID = (int) get_parameter('metaID', 0); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $default_filters = [ 'searchAgent' => '', 'statusAgent' => AGENT_STATUS_ALL, @@ -69,6 +70,7 @@ if (is_ajax() === true) { ]; $filter = get_parameter('filter', $default_filters); + $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); @@ -187,7 +189,8 @@ if (is_ajax() === true) { $serverID, $childrenMethod, $access, - $metaID + $metaID, + $filter['groupID'] ); break; diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 0d105d5994..b29dd06bd3 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -70,8 +70,7 @@ $otherSerialize = get_parameter('other'); $otherMode = get_parameter('other_mode', 'url_encode'); $returnType = get_parameter('return_type', 'string'); $info = get_parameter('info', ''); -$raw_decode = (bool) get_parameter('raw_decode', false); - +$raw_decode = (bool) get_parameter('raw_decode', true); $other = parseOtherParameter($otherSerialize, $otherMode, $raw_decode); $apiPassword = io_output_password( db_get_value_filter( diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php deleted file mode 100644 index 529684569d..0000000000 --- a/pandora_console/include/chart_generator.php +++ /dev/null @@ -1,324 +0,0 @@ - 'api_password'] - ) - ); - - - if ($apiPassword === $data_decoded['apipass']) { - $bypassLogin = true; - } -} - -if (!isset($config[$slicebar])) { - $config[$slicebar] = $slicebar_value; -} - -// Try to initialize session using existing php session id. -$user = new PandoraFMS\User(['phpsessionid' => $session_id]); - -if (check_login(false) === false && $bypassLogin !== true) { - // Error handler. - ?> - - - - - Access denied - - - - - - - - - -

Access is not granted

- @@ -1136,7 +1135,7 @@ class WelcomeWindow extends Wizard } function configureEmail() { - window.location = ''; + window.location = ''; } function serversUp() { @@ -1263,14 +1262,18 @@ class WelcomeWindow extends Wizard }); }); - $('#button-create_conectivity').click(function(){ + $('#button-create_conectivity').click(function(e){ + if($("#text-ip_target")[0].checkValidity() == false) { + $("#text-ip_target")[0].reportValidity(); + return false; + } $.ajax({ async: false, type: "POST", url: "include/ajax/task_to_perform.php", data: { check_connectivity: 1, - id_group: $('#id_group :selected').val(), + id_group: $('#id_group1 option:selected').val(), ip_target: $('#text-ip_target').val(), agent_name: $('#text-agent_name').val(), }, diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 13b679aa04..9ad1aa52da 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC231124'; +$build_version = 'PC231214'; $pandora_version = 'v7.0NG.774'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 4f020e61de..5207298b03 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -45,6 +45,7 @@ define('EVENT_NEW', 0); define('EVENT_VALIDATE', 1); define('EVENT_PROCESS', 2); define('EVENT_NO_VALIDATED', 3); +define('EVENT_NO_PROCESS', 4); // Events group by constants. define('EVENT_GROUP_REP_ALL', 0); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d03b8d7412..0bb6612376 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -306,32 +306,48 @@ function format_for_graph( } -function human_milliseconds_to_string($seconds) +function human_milliseconds_to_string($seconds, $size_text='large') { $ret = ''; // get the days $days = intval(intval($seconds) / (360000 * 24)); if ($days > 0) { - $ret .= "$days days "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$days d").' '; + } else { + $ret .= "$days days "; + } } // get the hours $hours = ((intval($seconds) / 360000) % 24); if ($hours > 0) { - $ret .= "$hours hours "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$hours h").' '; + } else { + $ret .= "$hours hours "; + } } // get the minutes $minutes = ((intval($seconds) / 6000) % 60); if ($minutes > 0) { - $ret .= "$minutes minutes "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$minutes m").' '; + } else { + $ret .= "$minutes minutes "; + } } // get the seconds $seconds = ((intval($seconds) / 100) % 60); if ($seconds > 0) { - $ret .= "$seconds seconds"; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$seconds s").' '; + } else { + $ret .= "$seconds seconds "; + } } return $ret; @@ -990,6 +1006,70 @@ function get_parameter($name, $default='') } +function get_parameter_date($name, $default='', $date_format='Y/m/d') +{ + $date_end = get_parameter('date_end', 0); + $time_end = get_parameter('time_end'); + $datetime_end = strtotime($date_end.' '.$time_end); + + $custom_date = get_parameter('custom_date', 0); + $range = get_parameter('range', SECONDS_1DAY); + $date_text = get_parameter('range_text', SECONDS_1DAY); + $date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY); + $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less)); + $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less)); + $datetime_init = strtotime($date_init.' '.$time_init); + if ($custom_date === '1') { + if ($datetime_init >= $datetime_end) { + $datetime_init = $date_init_less; + } + + $date_init = date('Y/m/d H:i:s', $datetime_init); + $date_end = date('Y/m/d H:i:s', $datetime_end); + $period = ($datetime_end - $datetime_init); + } else if ($custom_date === '2') { + $date_units = get_parameter('range_units'); + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units))); + $period = (strtotime($date_end) - strtotime($date_init)); + } else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) { + if ($range === 'this_week') { + $monday = date('Y/m/d', strtotime('last monday')); + + $sunday = date('Y/m/d', strtotime($monday.' +6 days')); + $period = (strtotime($sunday) - strtotime($monday)); + $date_init = $monday; + $date_end = $sunday; + } else if ($range === 'this_month') { + $date_end = date('Y/m/d', strtotime('last day of this month')); + $first_of_month = date('Y/m/d', strtotime('first day of this month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_month') { + $date_end = date('Y/m/d', strtotime('last day of previous month')); + $first_of_month = date('Y/m/d', strtotime('first day of previous month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_week') { + $date_end = date('Y/m/d', strtotime('sunday', strtotime('last week'))); + $first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week'))); + $date_init = $first_of_week; + $period = (strtotime($date_end) - strtotime($first_of_week)); + } + } else { + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range)); + $period = (strtotime($date_end) - strtotime($date_init)); + } + + return [ + 'date_init' => date($date_format, strtotime($date_init)), + 'date_end' => date($date_format, strtotime($date_end)), + 'period' => $period, + ]; +} + + /** * Get a parameter from a get request. * @@ -4310,48 +4390,22 @@ function generator_chart_to_pdf( $module_list=false ) { global $config; - - if (is_metaconsole()) { + $hack_metaconsole = ''; + if (is_metaconsole() === true) { $hack_metaconsole = '../..'; - } else { - $hack_metaconsole = ''; } - $url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php'; - if (!$params['return_img_base_64']) { $img_file = 'img_'.uniqid().'.png'; $img_path = $config['homedir'].'/attachment/'.$img_file; $img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file; } - $session_id = session_id(); - if ($type_graph_pdf === 'combined') { - $data = [ - 'data' => $params, - 'session_id' => $session_id, - 'type_graph_pdf' => $type_graph_pdf, - 'data_module_list' => $module_list, - 'data_combined' => $params_combined, - 'id_user' => $config['id_user'], - 'slicebar' => $_SESSION['slicebar'], - 'slicebar_value' => $config[$_SESSION['slicebar']], - 'apipass' => get_parameter('apipass', null), - - ]; - } else { - $data = [ - 'data' => $params, - 'session_id' => $session_id, - 'type_graph_pdf' => $type_graph_pdf, - 'id_user' => $config['id_user'], - 'slicebar' => $_SESSION['slicebar'], - 'slicebar_value' => $config[$_SESSION['slicebar']], - 'apipass' => get_parameter('apipass', null), - ]; + if ($type_graph_pdf !== 'combined') { + $params_combined = []; + $module_list = []; } - unset($data['data']['graph_data']); // If not install chromium avoid 500 convert tu images no data to show. $chromium_dir = io_safe_output($config['chromium_path']); $result_ejecution = exec($chromium_dir.' --version'); @@ -4371,22 +4425,16 @@ function generator_chart_to_pdf( // Creates a new page. $page = $browser->createPage(); - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, ['data' => json_encode($data)]); + // Generate Html. + $html = chart_generator( + $type_graph_pdf, + $params, + $params_combined, + $module_list + ); - $response = curl_exec($curl); - - curl_close($curl); - - $page->setHtml($response); - /* - //For debug url with parameters. - $navigation = $page->navigate($url.'?data='.urlencode(json_encode($data))); - $navigation->waitForNavigation(Page::DOM_CONTENT_LOADED); - */ + $page->setHtml($html); // Dynamic. $dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue(); @@ -4433,6 +4481,211 @@ function generator_chart_to_pdf( } +/** + * Html print chart for chromium + * + * @param string $type_graph_pdf Chart mode. + * @param array $params Params. + * @param array $params_combined Params Combined charts. + * @param array $module_list Module list Combined charts. + * + * @return string Output Html. + */ +function chart_generator( + string $type_graph_pdf, + array $params, + array $params_combined=[], + array $module_list=[] +) : string { + global $config; + + include_once $config['homedir'].'/include/graphs/functions_d3.php'; + + if (isset($params['backgroundColor']) === false) { + $params['backgroundColor'] = 'inherit'; + } + + $hack_metaconsole = (is_metaconsole() === true) ? '../../' : ''; + + $output = ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= 'Pandora FMS Graph'; + $output .= ''; + + $css_files = [ + 'pandora' => 'include/styles/', + 'pandora_minimal' => 'include/styles/', + 'jquery-ui.min' => 'include/styles/js/', + 'jquery-ui_custom' => 'include/styles/js/', + ]; + + foreach ($css_files as $name => $path) { + $output .= ui_require_css_file($name, $path, true, true); + } + + $js_files = [ + 'pandora_ui' => 'include/javascript/', + 'jquery.current' => 'include/javascript/', + 'jquery.pandora' => 'include/javascript/', + 'jquery-ui.min' => 'include/javascript/', + 'date' => 'include/javascript/timezone/src/', + 'pandora' => 'include/javascript/', + 'jquery.flot' => 'include/graphs/flot/', + 'jquery.flot.min' => 'include/graphs/flot/', + 'jquery.flot.time' => 'include/graphs/flot/', + 'jquery.flot.pie' => 'include/graphs/flot/', + 'jquery.flot.crosshair.min' => 'include/graphs/flot/', + 'jquery.flot.stack.min' => 'include/graphs/flot/', + 'jquery.flot.selection.min' => 'include/graphs/flot/', + 'jquery.flot.resize.min' => 'include/graphs/flot/', + 'jquery.flot.threshold' => 'include/graphs/flot/', + 'jquery.flot.threshold.multiple' => 'include/graphs/flot/', + 'jquery.flot.symbol.min' => 'include/graphs/flot/', + 'jquery.flot.exportdata.pandora' => 'include/graphs/flot/', + 'jquery.flot.axislabels' => 'include/graphs/flot/', + 'pandora.flot' => 'include/graphs/flot/', + 'chart' => 'include/graphs/chartjs/', + 'chartjs-plugin-datalabels.min' => 'include/graphs/chartjs/', + ]; + + foreach ($js_files as $name => $path) { + $output .= ui_require_javascript_file($name, $path, true, true); + } + + $output .= include_javascript_d3(true, true); + + $output .= ''; + $output .= ''; + $params['only_image'] = false; + $params['menu'] = false; + $params['disable_black'] = true; + + $viewport = [ + 'width' => 0, + 'height' => 0, + ]; + + $style = 'width:100%;'; + if (isset($params['options']['viewport']) === true) { + $viewport = $params['options']['viewport']; + if (empty($viewport['width']) === false) { + $style .= 'width:'.$viewport['width'].'px;'; + } + + if (empty($viewport['height']) === false) { + $style .= 'height:'.$viewport['height'].'px;'; + } + } + + $output .= '
'; + switch ($type_graph_pdf) { + case 'combined': + $params['pdf'] = true; + $result = graphic_combined_module( + $module_list, + $params, + $params_combined + ); + + $output .= $result; + break; + + case 'sparse': + $params['pdf'] = true; + $output .= grafico_modulo_sparse($params); + break; + + case 'pie_graph': + $params['pdf'] = true; + $chart = get_build_setup_charts( + 'PIE', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'vbar_graph': + $params['pdf'] = true; + $chart = get_build_setup_charts( + 'BAR', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'ring_graph': + $params['pdf'] = true; + $params['options']['width'] = 500; + $params['options']['height'] = 500; + + $chart = get_build_setup_charts( + 'DOUGHNUT', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'line_graph': + $params['pdf'] = true; + $params['options']['width'] = '100%'; + $params['options']['height'] = 200; + $chart = get_build_setup_charts( + 'LINE', + $params['options'], + $params['chart_data'] + ); + $output .= $chart->render(true); + break; + + case 'slicebar': + $output .= flot_slicesbar_graph( + $params['graph_data'], + $params['period'], + $params['width'], + $params['height'], + $params['legend'], + $params['colors'], + $params['fontpath'], + $params['round_corner'], + $params['homeurl'], + $params['watermark'], + $params['adapt_key'], + $params['stat_winalse'], + $params['id_agent'], + $params['full_legend_daterray'], + $params['not_interactive'], + $params['ttl'], + $params['sizeForTicks'], + $params['show'], + $params['date_to'], + $params['server_id'] + ); + break; + + default: + // Code... + break; + } + + $output .= '
'; + $output .= ''; + $output .= ''; + + return $output; +} + + /** * Get the product name. * diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..7dc206711d 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3643,7 +3643,7 @@ function select_modules_for_agent_group( if (!$selection && $agents != null) { $number_agents = count($id_agents); - $selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents"; + $selection_filter = "GROUP BY nombre HAVING COUNT(id_agente_modulo) = $number_agents"; } if (tags_has_user_acl_tags(false)) { @@ -3664,7 +3664,7 @@ function select_modules_for_agent_group( $sql = "SELECT * FROM ( - SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre + SELECT (tagente_modulo.id_agente_modulo), tagente_modulo.nombre, tagente.alias FROM tagente_modulo $sql_tags_inner INNER JOIN tagente @@ -3679,7 +3679,7 @@ function select_modules_for_agent_group( $filter_not_string_modules $sql_conditions_tags ) x - GROUP BY nombre + $selection_filter"; $modules = db_get_all_rows_sql($sql); @@ -4752,7 +4752,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $secondaryLinks = []; if (empty($secondary_groups['for_select']) === true) { - $secondaryLinks[] = ''.__('N/A').''; + $secondaryLinks = []; } else { foreach ($secondary_groups['for_select'] as $id => $name) { $secondaryLinks[] = html_print_anchor( @@ -4811,22 +4811,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) 'content' => groups_get_name($agent['id_grupo']), ], true - ); + ).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true); $table_contact->data[] = $data; // Secondary groups. $data = []; - $data[0] = ''.__('Secondary groups').''; - $data[1] = implode(', ', $secondaryLinks); - $table_contact->data[] = $data; + if (!empty($secondaryLinks) === true) { + $data[0] = ''.__('Secondary groups').''; + $data[1] = implode(', ', $secondaryLinks); + $table_contact->data[] = $data; + } // Parent agent line. if (enterprise_installed() === true) { - $data = []; - $data[0] = ''.__('Parent').''; - if ((int) $agent['id_parent'] === 0) { - $data[1] = ''.__('N/A').''; - } else { + if ((int) $agent['id_parent'] !== 0) { + $data = []; + $data[0] = ''.__('Parent').''; $data[1] = html_print_anchor( [ 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_parent'], @@ -4834,9 +4834,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) ], true ); - } - $table_contact->data[] = $data; + $table_contact->data[] = $data; + } } // Last status change line. @@ -4845,6 +4845,123 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; + $has_remote_conf = enterprise_hook( + 'config_agents_has_remote_configuration', + [$agent['id_agente']] + ); + + if ((bool) $has_remote_conf) { + $data = []; + $data[0] = __('Remote configuration'); + $data[1] = ''.__('Enabled').''; + $data[1] .= html_print_menu_button( + [ + 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'), + 'image' => 'images/remote-configuration@svg.svg', + 'title' => __('Edit remote config'), + ], + true + ); + + $satellite_server = (int) db_get_value_filter( + 'satellite_server', + 'tagente', + ['id_agente' => $id_agente] + ); + + if (empty($satellite_server) === false) { + $satellite_name = db_get_value_filter( + 'name', + 'tserver', + ['id_server' => $satellite_server] + ); + + $data[0] = __('Satellite server'); + $data[1] = $satellite_name; + } + + $table_contact->data[] = $data; + } + + if (enterprise_installed() === true) { + // SecurityMon line. + $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); + $modules = db_get_all_rows_filter( + 'tagente_modulo', + [ + 'id_agente' => $agent['id_agente'], + 'id_module_group' => $id_module_group, + ] + ); + + if (is_array($modules) === true && count($modules) > 0) { + $secmon_status = secmon_status($agent['id_agente']); + $data = []; + $data[0] = ''.__('SecurityMon').''; + $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); + $table_contact->data[] = $data; + } + + // Hardening line. + $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); + $hardening = ''; + if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { + $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); + $hardening = format_numeric($raw_data_score[0]['datos'], 2); + $data = []; + $data[0] = ''.__('Hardening').''; + $data[1] = $hardening.' %'; + $table_contact->data[] = $data; + } + + // Vulnerabilities line. + $vuls = get_vulnerabilities($agent['id_agente']); + if (is_array($vuls) === true && count($vuls) > 0) { + $score = get_score($vuls); + $data = []; + $data[0] = ''.__('Vulnerability').''; + $data[1] = ui_print_status_vulnerability_div($score); + $table_contact->data[] = $data; + } + } + + // Optional data + // Position Information. + if ((bool) $config['activate_gis'] === true) { + $data = []; + + $dataPositionAgent = gis_get_data_last_position_agent( + $agent['id_agente'] + ); + if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') { + $data[0] = __('Position (Long, Lat)'); + + $dataOptionalOutput = html_print_anchor( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente='.$id_agente, + 'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'], + ], + true + ); + + if (empty($dataPositionAgent['description']) === false) { + $dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')'; + } + + $data[1] = $dataOptionalOutput; + } + + $table_contact->data[] = $data; + } + + // Timezone Offset. + if ((int) $agent['timezone_offset'] !== 0) { + $data = []; + $data[0] = __('Timezone Offset'); + $data[1] = $agent['timezone_offset']; + $table_contact->data[] = $data; + } + $agent_contact = html_print_div( [ 'class' => 'agent_details_header', @@ -4856,4 +4973,50 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $agent_contact .= html_print_table($table_contact, true); return $agent_contact; +} + + +/** + * agent belongs to the clusters. + * + * @param integer $idAgent + * + * @return array Names clusters. + */ +function agents_get_agent_belongs_cluster(int $idAgent): array +{ + $sql = sprintf( + 'SELECT tcluster.name + FROM tcluster + INNER JOIN tcluster_agent + ON tcluster.id = tcluster_agent.id_cluster + WHERE tcluster_agent.id_agent = %d', + $idAgent + ); + + $result = db_get_all_rows_sql($sql); + if ($result === false) { + $result = []; + } + + return $result; +} + + +/** + * Return an array with a list of status agents + * + * @return array. + */ +function agents_status_list() +{ + $status_list = []; + $status_list[AGENT_STATUS_NORMAL] = __('Normal'); + $status_list[AGENT_STATUS_WARNING] = __('Warning'); + $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); + $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); + $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); + $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); + + return $status_list; } \ No newline at end of file diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 94dcb97f6c..c461eb1402 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2169,13 +2169,16 @@ function get_group_alerts( $strict_user=false, $tag=false, $action_filter=false, - $alert_action=true + $alert_action=true, + $search_sg=false ) { global $config; - $group_query = ''; if (!empty($idGroup)) { $group_query = ' AND id_grupo = '.$idGroup; + if ((bool) $search_sg === true) { + $group_query .= ' OR tasg.id_group = '.$idGroup; + } } if (is_array($filter)) { diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f6d1674022..bf1c1b3004 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode) case 'url_encode': $returnVar = [ 'type' => 'string', - 'data' => urldecode($other), + 'data' => $rawDecode ? rawurldecode($other) : urldecode($other), ]; break; @@ -10301,8 +10301,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) modules_get_type_name($agentModule['id_tipo_modulo']), $data ); - - if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) { + if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$idAgentModule.'.'.$time.'.data', $xml)) { returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config'])); } else { echo __('XML file was generated successfully in path: ').$config['remote_config']; @@ -12952,7 +12951,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values = []; if ($other['data'][0] != '') { - $values['event'] = $other['data'][0]; + $values['event'] = io_safe_input(io_safe_output($other['data'][0])); } else { returnError('Event text required.'); return; @@ -13132,7 +13131,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario + $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id FROM tevento WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";'; @@ -13147,6 +13146,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['status'] = 2; $ack_utimestamp = $val['ack_utimestamp']; $values['id_usuario'] = $val['id_usuario']; + $values['event_custom_id'] = $val['event_custom_id']; } api_set_validate_event_by_id($val['id_evento']); @@ -13177,7 +13177,8 @@ function api_set_create_event($id, $trash1, $other, $returnType) $custom_data, $values['server_id'], $values['id_extra'], - $ack_utimestamp + $ack_utimestamp, + $values['event_custom_id'] ?? null ); if ($other['data'][12] != '') { @@ -17787,6 +17788,48 @@ function api_token_check(string $token) } +/** + * Set custom field value in tevento + * + * @param mixed $id_event Event id. + * @param mixed $custom_field Custom field to set. + * @return void + */ +function api_set_event_custom_id($id, $value) +{ + // Get the event + $event = events_get_event($id, false, is_metaconsole()); + // If event not exists, end the execution. + if ($event === false) { + returnError( + 'event_not_exists', + 'Event not exists' + ); + $result = false; + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($value))) { + $result = false; + } + + $result = events_event_custom_id( + $id, + $value + ); + + // If update results failed + if (empty($result) === true || $result === false) { + returnError( + 'The event could not be updated' + ); + return false; + } else { + returnData('string', ['data' => 'Event updated.']); + } +} + + /** * Extract info Agents for inventories ITSM. * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 0c7d6039cd..9eb19be28d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -249,10 +249,6 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { - $error_update[] = __('Enable Sflow'); - } - if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) { $error_update[] = __('Enable Feedback'); } @@ -375,6 +371,10 @@ function config_update_config() $error_update[] = __('eastern_eggs_disabled'); } + if (config_update_value('number_modules_queue', get_parameter('number_modules_queue'), true) === false) { + $error_update[] = __('number_modules_queue'); + } + if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) { $error_update[] = __('Console log enabled'); } @@ -435,6 +435,10 @@ function config_update_config() if (config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist), true) === false) { $error_update[] = __('Inventory changes blacklist'); } + + if (config_update_value('tftp_server_ip', (string) get_parameter('tftp_server_ip'), true) === false) { + $error_update[] = __('Ftp server ip'); + } break; case 'enterprise': @@ -921,10 +925,6 @@ function config_update_config() $error_update[] = __('Batch statistics period (secs)'); } - if (config_update_value('agentaccess', (int) get_parameter('agentaccess'), true) === false) { - $error_update[] = __('Use agent access graph'); - } - if (config_update_value('num_files_attachment', (int) get_parameter('num_files_attachment'), true) === false) { $error_update[] = __('Max. recommended number of files in attachment directory'); } @@ -1627,6 +1627,10 @@ function config_update_config() if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) { $error_update[] = __('Name resolution for IP address'); } + + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { + $error_update[] = __('Enable Sflow'); + } break; case 'sflow': @@ -2241,10 +2245,6 @@ function config_process_config() config_update_value('show_qr_code_header', false); } - if (!isset($config['agentaccess'])) { - config_update_value('agentaccess', true); - } - if (!isset($config['timezone'])) { config_update_value('timezone', 'Europe/Berlin'); } @@ -2453,6 +2453,10 @@ function config_process_config() config_update_value('show_experimental_features', 0); } + if (!isset($config['number_modules_queue'])) { + config_update_value('number_modules_queue', 500); + } + if (!isset($config['eastern_eggs_disabled'])) { config_update_value('eastern_eggs_disabled', 1); } diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 9de0520ccd..40a6e159cc 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true) // Check prev process running and kill it (only if port changed in setup params). if (empty($config['restart_gotty_next_cron_port']) === false) { - config_update_value('restart_gotty_next_cron_port', ''); - - $prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + $prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'"); if (empty($prevProcessRunning) === false) { shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); } + + config_update_value('restart_gotty_next_cron_port', ''); } // Check if gotty is running on the configured port. - $processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + $processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'"); $start_proc = true; diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 500b668a24..f76dc7c0f7 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -194,11 +194,11 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t function custom_graphs_search($id_group, $search) { if ($id_group != '' && $search != '') { - $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (name LIKE "%'.$search.'%" OR description LIKE "'.$search.'")'); + $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (REPLACE(name, " ", " ") LIKE "%'.$search.'%" OR REPLACE(description, " ", " ") LIKE "'.$search.'")'); } else if ($id_group != '') { $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.''); } else { - $all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%" OR description LIKE "'.$search.'"'); + $all_graphs = db_get_all_rows_sql('select * from tgraph where REPLACE(name, " ", " ") LIKE "%'.$search.'%" OR REPLACE(description, " ", " ") LIKE "'.$search.'"'); } if ($all_graphs === false) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 5534897e84..f34a8f6239 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -127,6 +127,58 @@ function events_translate_event_type($event_type) } +/** + * Module status event_type into descriptive text. + * + * @param integer $event_type Event type. + * + * @return string Module status. + */ +function events_status_module_event_type($event_type) +{ + $module_status = ''; + switch ($event_type) { + case 'alert_fired': + case 'alert_recovered': + case 'alert_ceased': + case 'alert_manual_validation': + $module_status = AGENT_MODULE_STATUS_CRITICAL_ALERT; + break; + + case 'going_down_normal': + case 'going_up_normal': + $module_status = AGENT_MODULE_STATUS_NORMAL; + break; + + case 'going_unknown': + case 'unknown': + $module_status = AGENT_MODULE_STATUS_UNKNOWN; + break; + + case 'going_up_warning': + case 'going_down_warning': + $module_status = AGENT_MODULE_STATUS_WARNING; + break; + + case 'going_up_critical': + case 'going_down_critical': + $module_status = AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + + case 'recon_host_detected': + case 'system': + case 'error': + case 'new_agent': + case 'configuration_change': + default: + $module_status = AGENT_MODULE_STATUS_NOT_INIT; + break; + } + + return $module_status; +} + + /** * Translates a numeric value event_status into descriptive text. * @@ -219,6 +271,7 @@ function events_get_all_fields() $columns['module_status'] = __('Module status'); $columns['module_custom_id'] = __('Module custom id'); $columns['custom_data'] = __('Custom data'); + $columns['event_custom_id'] = __('Event Custom ID'); return $columns; } @@ -322,6 +375,9 @@ function events_get_column_name($field, $table_alias=false) case 'custom_data': return __('Custom data'); + case 'event_custom_id': + return __('Event Custom ID'); + default: return __($field); } @@ -982,6 +1038,9 @@ function events_get_all( case EVENT_NO_VALIDATED: $filter['status'][$key] = (EVENT_NEW.', '.EVENT_PROCESS); + + case EVENT_NO_PROCESS: + $filter['status'][$key] = (EVENT_NEW.', '.EVENT_VALIDATE); default: // Ignore. break; @@ -1027,6 +1086,24 @@ function events_get_all( $validatedState ); break; + + case EVENT_NO_PROCESS: + // Show comments in validated events. + $validatedState = ''; + if ($validatedEvents === true) { + $validatedState = sprintf( + 'OR estado = %d', + EVENT_VALIDATE + ); + } + + $sql_filters[] = sprintf( + ' AND (estado = %d OR estado = %d %s)', + EVENT_NEW, + EVENT_VALIDATE, + $validatedState + ); + break; } } } @@ -2335,7 +2412,8 @@ function events_create_event( $custom_data='', $server_id=0, $id_extra='', - $ack_utimestamp=0 + $ack_utimestamp=0, + $event_custom_id=null ) { if ($source === false) { $source = get_product_name(); @@ -2367,6 +2445,7 @@ function events_create_event( 'custom_data' => $custom_data, 'data' => '', 'module_status' => 0, + 'event_custom_id' => $event_custom_id, ]; return (int) db_process_sql_insert('tevento', $values); @@ -2590,7 +2669,6 @@ function events_print_type_img( $urlImage = ui_get_full_url(false); $icon = ''; $style = 'main_menu_icon'; - switch ($type) { case 'alert_recovered': $icon = 'images/alert_recovered@svg.svg'; @@ -2656,16 +2734,6 @@ function events_print_type_img( if ($only_url) { $output = $urlImage.'/'.$icon; } else { - /* - $output .= html_print_div( - [ - 'title' => events_print_type_description($type, true), - 'class' => $style, - 'style' => ((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''), - ], - true - ); - */ $output .= html_print_image( $icon, true, @@ -3204,12 +3272,14 @@ function events_get_all_status($report=false) $fields[1] = __('Only validated'); $fields[2] = __('Only in process'); $fields[3] = __('Only not validated'); + $fields[4] = __('Only not in process'); } else { $fields[-1] = __('All event'); $fields[0] = __('New'); $fields[1] = __('Validated'); $fields[2] = __('In process'); $fields[3] = __('Not Validated'); + $fields[4] = __('Not in process'); } return $fields; @@ -4039,7 +4109,13 @@ function events_get_response_target( if (empty($event['custom_data']) === false) { $custom_data = json_decode($event['custom_data']); foreach ($custom_data as $key => $value) { - $target = str_replace('_customdata_'.$key.'_', $value, $target); + if (is_array($value) === true) { + foreach ($value as $k => $v) { + $target = str_replace('_customdata_'.$k.'_', $v, $target); + } + } else { + $target = str_replace('_customdata_'.$key.'_', $value, $target); + } } if (strpos($target, '_customdata_json_') !== false) { @@ -4629,6 +4705,30 @@ function events_page_details($event, $server_id=0) $data[1] = ''.__('N/A').''; } + $table_details->data[] = $data; + $readonly = true; + if (check_acl($config['id_user'], 0, 'EW')) { + $readonly = false; + } + + $data = []; + $data[0] = __('Event Custom ID'); + $data[1] = '
'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, $readonly, false, '', 'w60p'); + if ($readonly === false) { + $data[1] .= html_print_button( + __('Update'), + 'update_event_custom_id', + false, + 'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');', + [ + 'icon' => 'next', + 'mode' => 'link', + ], + true + ); + } + + $data[1] .= '
'; $table_details->data[] = $data; $details = '
'.html_print_table($table_details, true).'
'; @@ -4939,7 +5039,11 @@ function events_page_general($event) $data[1] = $user_owner; } - $table_general->cellclass[3][1] = 'general_owner'; + if (is_metaconsole() === true && $event['server_name'] !== '') { + $table_general->cellclass[4][1] = 'general_owner'; + } else { + $table_general->cellclass[3][1] = 'general_owner'; + } $table_general->data[] = $data; @@ -4999,38 +5103,21 @@ function events_page_general($event) $table_general->cellclass[count($table_general->data)][1] = 'general_acknowleded'; $data = []; + + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect = new Node($event['server_id']); + $node_connect->connect(); + } + $data[0] = __('Acknowledged by'); + $data[1] = events_page_general_acknowledged($event['id_evento']); - if ($event['estado'] == 1 || $event['estado'] == 2) { - if (empty($event['id_usuario']) === true) { - $user_ack = __('Autovalidated'); - } else { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $event['id_usuario'] - ); - - if (empty($user_ack) === true) { - $user_ack = $event['id_usuario']; - } - } - - $data[1] = $user_ack.' ( '; - if ($event['ack_utimestamp_raw'] !== false - && $event['ack_utimestamp_raw'] !== 'false' - && empty($event['ack_utimestamp_raw']) === false - ) { - $data[1] .= date( - $config['date_format'], - $event['ack_utimestamp_raw'] - ); - } - - $data[1] .= ' ) '; - } else { - $data[1] = ''.__('N/A').''; + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect->disconnect(); } $table_general->cellclass[7][1] = 'general_status'; @@ -5137,15 +5224,19 @@ function events_page_general_acknowledged($event_id) $Acknowledged = ''; $event = db_get_row('tevento', 'id_evento', $event_id); if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $config['id_user'] - ); + if (empty($event['id_usuario']) === true) { + $user_ack = __('Autovalidated'); + } else { + $user_ack = db_get_value( + 'fullname', + 'tusuario', + 'id_user', + $config['id_user'] + ); - if (empty($user_ack) === true) { - $user_ack = $config['id_user']; + if (empty($user_ack) === true) { + $user_ack = $config['id_user']; + } } $Acknowledged = $user_ack.' ( '; @@ -5160,7 +5251,7 @@ function events_page_general_acknowledged($event_id) $Acknowledged .= ' ) '; } else { - $Acknowledged = 'N/A'; + $Acknowledged = ''.__('N/A').''; } return $Acknowledged; @@ -5746,7 +5837,7 @@ function events_get_field_value_by_event_id( } -function events_get_instructions($event) +function events_get_instructions($event, $max_text_length=300) { if (is_array($event) === false) { return ''; @@ -5794,17 +5885,17 @@ function events_get_instructions($event) return ''; } - $max_text_length = 300; $over_text = io_safe_output($value); if (strlen($over_text) > ($max_text_length + 3)) { $over_text = substr($over_text, 0, $max_text_length).'...'; + } else { + return $value; } $output = '
'; $output .= ''; $output .= ''; @@ -5813,7 +5904,6 @@ function events_get_instructions($event) true, ['title' => $over_text] ).''; - $output .= ''; return $output; } @@ -5993,17 +6083,47 @@ function get_count_event_criticity( $type = 'AND event_type = "'.$eventType.'"'; } - $groups = ' '; + $groups = ' '; if ((int) $groupId !== 0) { $groups = 'AND id_grupo IN ('.$groupId.')'; } - $status = ' '; - if ((int) $eventStatus !== -1) { - $status = 'AND estado = '.$eventStatus; + $status = ' '; + if (empty($eventStatus) === false) { + switch ($eventStatus) { + case EVENT_ALL: + default: + // Do not filter. + break; + + case EVENT_NEW: + case EVENT_VALIDATE: + case EVENT_PROCESS: + $status = sprintf( + ' AND estado = %d', + $eventStatus + ); + break; + + case EVENT_NO_VALIDATED: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_PROCESS + ); + break; + + case EVENT_NO_PROCESS: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_VALIDATE + ); + break; + } } - $criticity = ' '; + $criticity = ' '; if (empty($criticityId) === false) { $criticity = 'AND criticity IN ('.$criticityId.')'; } @@ -6199,3 +6319,206 @@ function event_get_counter_extraId(array $event, ?array $filters) return $counters; } + + +/** + * Update event detail custom field + * + * @param mixed $id_event Event ID or array of events. + * @param string $event_custom_id Event custom ID to be update. + * + * @return boolean Whether or not it was successful + */ +function events_event_custom_id( + $id_event, + $event_custom_id, +) { + global $config; + // Cleans up the selection for all unwanted values also casts any single + // values as an array. + if (![$id_event]) { + $id_event = (array) safe_int($id_event, 1); + } + + // Check ACL. + foreach ($id_event as $k => $id) { + $event_group = events_get_group($id); + if (check_acl($config['id_user'], $event_group, 'EW') == 0) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Attempted updating event #'.$id + ); + + unset($id_event[$k]); + } + } + + if (empty($id_event) === true) { + return false; + } + + // Get the current event comments. + $first_event = $id_event; + if (is_array($id_event) === true) { + $first_event = reset($id_event); + } + + // Update comment. + $ret = db_process_sql_update( + 'tevento', + ['event_custom_id' => $event_custom_id], + ['id_evento' => $first_event] + ); + + if (($ret === false) || ($ret === 0)) { + return false; + } + + return true; +} + + +function event_print_graph( + $filter, + $graph_height=100, +) { + global $config; + $show_all_data = false; + $events = events_get_all(['te.id_evento', 'te.timestamp', 'te.utimestamp'], $filter, null, null, 'te.utimestamp', true); + + if (empty($filter['date_from']) === false + && empty($filter['time_from']) === false + && empty($filter['date_to']) === false + && empty($filter['time_to']) === false + ) { + $start_utimestamp = strtotime($filter['date_from'].' '.$filter['time_from']); + $end_utimestamp = strtotime($filter['date_to'].' '.$filter['time_to']); + } else if ($filter['event_view_hr'] !== '') { + $start_utimestamp = strtotime('-'.$filter['event_view_hr'].' hours'); + $end_utimestamp = strtotime('now'); + } else { + $show_all_data = true; + $start_utimestamp = $events[0]['utimestamp']; + $end_utimestamp = $events[array_key_last($events)]['utimestamp']; + } + + $data_events = []; + $control_timestamp = $start_utimestamp; + $count = 0; + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $num_data = count($data_events); + + $num_intervals = $num_data; + + $period = ($end_utimestamp - $start_utimestamp); + + if ($period <= SECONDS_6HOURS) { + $chart_time_format = 'H:i:s'; + } else if ($period < SECONDS_1DAY) { + $chart_time_format = 'H:i'; + } else if ($period < SECONDS_15DAYS) { + $chart_time_format = 'M d H:i'; + } else if ($period < SECONDS_1MONTH) { + $chart_time_format = 'M d H\h'; + } else { + $chart_time_format = 'M d H\h'; + } + + $chart = []; + $labels = []; + $color = []; + $count = 0; + + if ($show_all_data === true) { + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $data_events = array_reverse($data_events, true); + + foreach ($data_events as $utimestamp => $count) { + $labels[] = date($chart_time_format, $utimestamp); + $chart[] = [ + 'y' => $count, + 'x' => date($chart_time_format, $utimestamp), + ]; + $color[] = '#82b92f'; + } + } else { + if ($num_intervals > 0) { + $interval_length = (int) ($period / $num_intervals); + } else { + $interval_length = 0; + } + + $intervals = []; + $intervals[0] = $start_utimestamp; + for ($i = 0; $i < $num_intervals; $i++) { + $intervals[($i + 1)] = ($intervals[$i] + $interval_length); + } + + $control_data = []; + + foreach ($data_events as $utimestamp => $count_event) { + for ($i = 0; $i < $num_intervals; $i++) { + if ((int) $utimestamp > (int) $intervals[$i] && (int) $utimestamp < (int) $intervals[($i + 1)]) { + $control_data[(string) $intervals[$i]] += $count_event; + } + } + } + + for ($i = 0; $i < $num_intervals; $i++) { + $labels[] = date($chart_time_format, $intervals[$i]); + $chart[] = [ + 'y' => $control_data[$intervals[$i]], + 'x' => date($chart_time_format, $intervals[$i]), + ]; + $color[] = '#82b92f'; + } + } + + $water_mark = [ + 'file' => $config['homedir'].'/images/logo_vertical_water.png', + 'url' => ui_get_full_url('/images/logo_vertical_water.png'), + ]; + + $options = [ + 'height' => $graph_height, + 'waterMark' => $water_mark, + 'legend' => ['display' => false], + 'colors' => $color, + 'border' => false, + 'scales' => [ + 'x' => [ + 'grid' => ['display' => false], + ], + 'y' => [ + 'grid' => ['display' => false], + ], + ], + 'labels' => $labels, + ]; + + $graph = '
'; + $graph .= vbar_graph($chart, $options); + $graph .= '
'; + + return $graph; +} diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index aee3d88730..a390ee2c1a 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -128,19 +128,18 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_ $extension = pathinfo($filename, PATHINFO_EXTENSION); $umask = io_safe_output((string) get_parameter('umask')); - $parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)); - $parse_sec2_query = explode('=', $parse_all_queries[1]); - $check_extension = true; - if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') { - if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) { - $check_extension = false; - } else { - $check_extension = true; - } - } - + // $parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)); + // $parse_sec2_query = explode('=', $parse_all_queries[1]); + // $check_extension = true; + // if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') { + // if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) { + // $check_extension = false; + // } else { + // $check_extension = true; + // } + // } // (strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip') - if (strpos($real_directory, $default_real_directory) !== 0 || $check_extension === false) { + if (strpos($real_directory, $default_real_directory) !== 0) { // Perform security check to determine whether received upload // directory is part of the default path for caller uploader and // user is not trying to access an external path (avoid @@ -152,12 +151,12 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_ // Copy file to directory and change name. $nombre_archivo = sprintf('%s/%s', $real_directory, $filename); try { - $mimeContentType = mime_content_type($_FILES['file']['tmp_name']); - - if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) { + $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)); + if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) { $result = copy($_FILES['file']['tmp_name'], $nombre_archivo); } else { - $error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.'; + $types_allowed = implode(', ', $filterFilesType); + $error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.'; throw new Exception(__($error_message)); } } catch (Exception $ex) { @@ -199,19 +198,29 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_ $filepath = $_FILES['file']['tmp_name']; $real_directory = filemanager_safe_directory($destination_directory); $secure = true; - if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') { - // Security control structure. - $zip = new \ZipArchive; - if ($zip->open($filepath) === true) { - for ($i = 0; $i < $zip->numFiles; $i++) { - $unzip_filename = $zip->getNameIndex($i); - $extension = pathinfo($unzip_filename, PATHINFO_EXTENSION); - if (strtolower($extension) !== 'mib') { - $secure = false; - break; + try { + $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)); + if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) { + // Security control structure. + $zip = new \ZipArchive; + if ($zip->open($filepath) === true) { + for ($i = 0; $i < $zip->numFiles; $i++) { + $unzip_filename = $zip->getNameIndex($i); + $extension = pathinfo($unzip_filename, PATHINFO_EXTENSION); + if (in_array(strtolower($extension), $filterFilesType) === false) { + $error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.'; + $secure = false; + throw new Exception(__($error_message)); + } } } } + } catch (Exception $ex) { + db_pandora_audit( + AUDIT_LOG_FILE_MANAGER, + 'Error Uploading files: '.$ex->getMessage() + ); + $config['filemanager']['message'] = ui_print_error_message(__('Upload error').': '.$ex->getMessage()); } if (strpos($real_directory, $default_real_directory) !== 0 || $secure === false) { diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index ba9116759b..b57ec9e9ff 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list) '.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).' '.$radioButton.' - '.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).' + '.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter main_menu_icon']).' '; - $table->data[1] = $content; - $table->colspan[1][0] = 2; + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; + $table->data['data']['cell'] = html_print_table( + $table_ncm, + true + ); } else { - $content = '
'; - $content .= str_replace("\n", '
', $item['data']); - $content .= '
'; - return $content; + $table_ncm->titleclass = 'title_table_pdf'; + $table_ncm->titlestyle = 'text-align:left;'; + + return html_print_table( + $table_ncm, + true + ); } } + + +/** + * HTML content for ncm backup report. + * + * @param array $item Content generated by reporting_ncm_backups. + * + * @return string HTML code. + */ +function reporting_html_ncm_backups($table, $item, $pdf=0) +{ + ui_require_css_file('diff2html.min'); + ui_require_css_file('highlight.min'); + ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('diff2html-ui.min'); + ui_require_javascript_file('highlight.min'); + ui_require_javascript_file('highlightjs-line-numbers.min'); + ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('jquery', ENTERPRISE_DIR.'/include/javascript/'); + ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); + + // Create table diff. + foreach ($item['data'] as $ncm_agent_key => $ncm_agent) { + $table_ncm = new stdClass(); + if ($pdf === 1) { + $table_ncm->width = '100%'; + } + + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->headstyle[0] = 'width: 250px'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + $table_ncm->id = 'ncm_backups'; + $table_ncm->name = 'ncm_backups'; + $table_ncm->title = $ncm_agent['caption']; + $row = []; + foreach ($ncm_agent['data'] as $ncm_agent_data) { + if ($pdf === 1) { + $row[] = [ + $ncm_agent_data['updated_at'], + ($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '
', $ncm_agent_data['diffstr']), + ]; + } else { + $row[] = [ + $ncm_agent_data['updated_at'], + $ncm_agent_data['diff'], + ]; + } + + $table_ncm->data = $row; + } + + $table->colspan[$ncm_agent_key]['cell'] = 3; + $table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;'; + $table->data[$ncm_agent_key]['cell'] = html_print_table( + $table_ncm, + true + ); + } + + if ($pdf === 1) { + $table->width = '100%'; + return html_print_table( + $table, + true + ); + } + +} diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3da9993933..bb9f57f5c3 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -777,6 +777,10 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Modules'), 'name' => __('Last value'), ]; + $types['service_level'] = [ + 'optgroup' => __('Modules'), + 'name' => __('Service Level Detailed'), + ]; $types['general'] = [ 'optgroup' => __('Grouped'), @@ -963,9 +967,14 @@ function reports_get_report_types($template=false, $not_editor=false) ]; } + $types['ncm_backups'] = [ + 'optgroup' => __('NCM'), + 'name' => __('NCM configuration changes'), + ]; + $types['ncm'] = [ 'optgroup' => __('NCM'), - 'name' => __('Network configuration changes'), + 'name' => __('NCM devices list'), ]; if (enterprise_installed() === true) { @@ -1003,6 +1012,41 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Security hardening'), 'name' => __('Evolution'), ]; + + $types['vuls_severity_graph'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Severity graph bar'), + ]; + + $types['vuls_attack_complexity'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Attack complexity doughnut chart'), + ]; + + $types['vuls_by_packages'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('By packages in pie chart'), + ]; + + $types['vuls_by_agent'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Detailed security report'), + ]; + + $types['vuls_info_agent'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Vulnerabilities of agent'), + ]; + + $types['top_n_agents_vuls'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N agents with more risk'), + ]; + + $types['top_n_vuls_count'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N common vulnerabilities'), + ]; } return $types; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 75e034ce3c..ff6fab73c6 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -665,6 +665,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'data'; $id_modulo = 1; + $server['name'] = __('Data server'); break; case SERVER_TYPE_NETWORK: @@ -678,6 +679,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'network'; $id_modulo = 2; + $server['name'] = __('Network server'); break; case SERVER_TYPE_SNMP: @@ -691,6 +693,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'snmp'; $id_modulo = 0; + $server['name'] = __('SNMP Trap server'); break; case SERVER_TYPE_DISCOVERY: @@ -704,6 +707,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'recon'; $id_modulo = 0; + $server['name'] = __('Discovery server'); break; case SERVER_TYPE_PLUGIN: @@ -717,6 +721,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'plugin'; $id_modulo = 4; + $server['name'] = __('Plugin server'); break; case SERVER_TYPE_PREDICTION: @@ -730,6 +735,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'prediction'; $id_modulo = 5; + $server['name'] = __('Prediction server'); break; case SERVER_TYPE_WMI: @@ -743,6 +749,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'wmi'; $id_modulo = 6; + $server['name'] = __('WMI server'); break; case SERVER_TYPE_EXPORT: @@ -756,6 +763,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'export'; $id_modulo = 0; + $server['name'] = __('Export server'); break; case SERVER_TYPE_INVENTORY: @@ -769,6 +777,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'inventory'; $id_modulo = 0; + $server['name'] = __('Inventory server'); break; case SERVER_TYPE_WEB: @@ -782,6 +791,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'web'; $id_modulo = 0; + $server['name'] = __('Web server'); break; case SERVER_TYPE_EVENT: @@ -795,6 +805,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'event'; $id_modulo = 2; + $server['name'] = __('Event server'); break; case SERVER_TYPE_CORRELATION: @@ -808,6 +819,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'correlation'; $id_modulo = 0; + $server['name'] = __('Correlation server'); break; case SERVER_TYPE_ENTERPRISE_ICMP: @@ -821,6 +833,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise icmp'; $id_modulo = 2; + $server['name'] = __('Enterprise ICMP server'); break; case SERVER_TYPE_ENTERPRISE_SNMP: @@ -834,6 +847,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise snmp'; $id_modulo = 2; + $server['name'] = __('Enterprise SNMP server'); break; case SERVER_TYPE_ENTERPRISE_SATELLITE: @@ -847,6 +861,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise satellite'; $id_modulo = 0; + $server['name'] = __('Enterprise Satellite server'); break; case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: @@ -860,6 +875,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise transactional'; $id_modulo = 0; + $server['name'] = __('Enterprise Transactional server'); break; case SERVER_TYPE_MAINFRAME: @@ -873,6 +889,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'mainframe'; $id_modulo = 0; + $server['name'] = __('Mainframe server'); break; case SERVER_TYPE_SYNC: @@ -886,6 +903,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'sync'; $id_modulo = 0; + $server['name'] = __('Sync server'); break; case SERVER_TYPE_WUX: @@ -899,6 +917,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'wux'; $id_modulo = 0; + $server['name'] = __('Wux server'); break; case SERVER_TYPE_SYSLOG: @@ -912,6 +931,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'syslog'; $id_modulo = 0; + $server['name'] = __('Syslog server'); break; case SERVER_TYPE_NCM: @@ -925,6 +945,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'ncm'; $id_modulo = 0; + $server['name'] = __('NCM server'); break; case SERVER_TYPE_AUTOPROVISION: @@ -938,6 +959,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'autoprovision'; $id_modulo = 0; + $server['name'] = __('Autoprovision server'); break; case SERVER_TYPE_MIGRATION: @@ -951,6 +973,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'migration'; $id_modulo = 0; + $server['name'] = __('Migration server'); break; case SERVER_TYPE_ALERT: @@ -964,6 +987,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'alert'; $id_modulo = 0; + $server['name'] = __('Alert server'); break; case SERVER_TYPE_NETFLOW: @@ -977,6 +1001,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'netflow'; $id_modulo = 0; + $server['name'] = __('Netflow server'); break; case SERVER_TYPE_LOG: @@ -990,6 +1015,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'log'; $id_modulo = 0; + $server['name'] = __('Log server'); break; case SERVER_TYPE_MADE: @@ -1003,6 +1029,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'made'; $id_modulo = 0; + $server['name'] = __('MADE server'); break; default: diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 480d0d865e..99a0b07612 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -644,14 +644,16 @@ function snmp_browser_print_oid( if (isset($_POST['print_create_agent_module'])) { // Hidden by default. - $output .= html_print_button( - __('Create agent module'), - 'create_module_agent_single', - false, - 'show_add_module()', - 'class="sub add invisible"', - true - ); + if (is_metaconsole() === false) { + $output .= html_print_button( + __('Create agent module'), + 'create_module_agent_single', + false, + 'show_add_module()', + 'class="sub add invisible"', + true + ); + } } if (isset($_POST['print_copy_oid'])) { @@ -1238,13 +1240,15 @@ function snmp_browser_print_container( if ($show_massive_buttons) { $output .= '