From e4ed319bcc37cf2d55aa4cba793d104e20882d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Sun, 4 Jun 2023 09:04:50 -0600 Subject: [PATCH 001/104] Correct comments in Tentacle Server Conf. --- pandora_server/conf/tentacle_server.conf.new | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pandora_server/conf/tentacle_server.conf.new b/pandora_server/conf/tentacle_server.conf.new index 1acf082ca2..4fa307e0e8 100644 --- a/pandora_server/conf/tentacle_server.conf.new +++ b/pandora_server/conf/tentacle_server.conf.new @@ -5,10 +5,10 @@ # Tentacle have IANA assigned port tpc/41121 as official port. ########################################################################## -# [-a] IPv4 address to listen on. Several IPs cam be selected separating if by comma. +# [-a] IPv4 address to listen on. Several IP adresses can be selected separated by commas. addresses 0.0.0.0 -# [-p] Port to listen on +# [-p] Port number to listen on. port 41121 # [-c] Maximum number of simultaneous connections @@ -17,19 +17,19 @@ port 41121 # [-d] Run as daemon. 1 true, 0 false daemon 1 -# [-i] Enable insecure mode -# insecure 0 +# [-I] Enable insecure mode. 1 true, 0 false. +#insecure 0 -# Filters (regexp:dir;regexp:dir...) -filters .*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:commands +# [-i] Filters (regexp:dir;regexp:dir...). +filters ..conf:conf;..md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:commands # [-m] Maximum file size allowed by the server in bytes -#max_size 2000000 +# max_size 2000000 -# [-o] Accept files with a repeated name +# [-o] Accept files with a repeated name. 1 true, 0 false. # overwrite 0 -# [-q] Do not output error messages. +# [-q] No output error messages. 1 true, 0 false. # quiet 0 # [-r] Number of retries for socket read/write operations @@ -38,10 +38,10 @@ filters .*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:co # [-s] Storage directory directory /var/spool/pandora/data_in -# [-b] Address to proxy client requests to +# [-b] IP address proxy client requests to. # proxy_ip 127.0.0.1 -# [-g] Port to proxy client requests to +# [-g] Port number proxy client requests to. # proxy_port 41121 # [-t] Timeout for socket read/write operations in seconds @@ -71,5 +71,5 @@ log_file /dev/null # [-w] SSL password. Set to 1 to ask for password by command line # ssl_password 0 -# [-T] Use libwrap library (Authen::Libwrap perl module) +# [-T] Use libwrap library (Authen::Libwrap perl module). 1 true, 0 false. # use_libwrap 0 \ No newline at end of file From 936d9cac4c93b7af022bd4c829d0e74bc0ff5027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Mon, 5 Jun 2023 08:48:15 -0600 Subject: [PATCH 002/104] Set the filter as it was originally --- pandora_server/conf/tentacle_server.conf.new | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/conf/tentacle_server.conf.new b/pandora_server/conf/tentacle_server.conf.new index 4fa307e0e8..a7cec8fd2c 100644 --- a/pandora_server/conf/tentacle_server.conf.new +++ b/pandora_server/conf/tentacle_server.conf.new @@ -21,7 +21,7 @@ daemon 1 #insecure 0 # [-i] Filters (regexp:dir;regexp:dir...). -filters ..conf:conf;..md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:commands +filters .*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:commands # [-m] Maximum file size allowed by the server in bytes # max_size 2000000 From 3ecf171fdbbe9e1473c431f1feb8c400f71f8ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Tue, 1 Aug 2023 18:14:11 -0600 Subject: [PATCH 003/104] Ignore disabled nodes --- pandora_server/util/pandora_ha.pl | 45 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index 941b6dc854..be54f8d0ca 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -361,7 +361,7 @@ sub ha_load_databases($) { return unless defined($conf->{'ha_hosts'}); @HA_DB_Hosts = grep { !/^#/ } map { s/^\s+|\s+$//g; $_; } split(/,/, $conf->{'ha_hosts'}); - log_message($conf, 'DEBUG', "Loaded databases from disk (@HA_DB_Hosts)"); + log_message($conf, 'DEBUG', "Loaded databases from disk (@HA_DB_Hosts)"); } ############################################################################### @@ -388,9 +388,20 @@ sub ha_database_connect_pandora($) { # Load the list of HA databases. ha_load_databases($conf); - + # Select a new master database. my ($dbh, $utimestamp, $max_utimestamp) = (undef, undef, -1); + + my @disabled_nodes = get_disabled_nodes($conf); + + # If there are disabled nodes ignore them from the HA_DB_Hosts. + if(scalar @disabled_nodes ne 0){ + @HA_DB_Hosts = grep { my $item = $_; !grep { $_ eq $item } @disabled_nodes } @HA_DB_Hosts; + + my $data = join(",", @disabled_nodes); + log_message($conf, 'LOG', "Ignoring disabled hosts: " . $data); + } + foreach my $ha_dbhost (@HA_DB_Hosts) { # Retry each database ha_connect_retries times. @@ -481,6 +492,36 @@ sub ha_restart_pandora($) { `$config->{'pandora_service_cmd'} $control_command 2>/dev/null`; } +############################################################################### +# Get ip of the disabled nodes. +############################################################################### +sub get_disabled_nodes($) { + my ($conf) = @_; + + my $dbh = db_connect('mysql', + $conf->{'dbname'}, + $conf->{'dbhost'}, + $conf->{'dbport'}, + $conf->{'ha_dbuser'}, + $conf->{'ha_dbpass'}); + + my $disabled_nodes = get_db_value($dbh, "SELECT value FROM tconfig WHERE token = 'ha_disabled_nodes'"); + + if(!defined($disabled_nodes) || $disabled_nodes eq ""){ + $disabled_nodes = ','; + } + + my @disabled_nodes = split(',', $disabled_nodes); + + if(scalar @disabled_nodes ne 0){ + $disabled_nodes = join(",", @disabled_nodes); + @disabled_nodes = get_db_rows($dbh, "SELECT host FROM tdatabase WHERE id IN ($disabled_nodes)"); + @disabled_nodes = map { $_->{host} } @disabled_nodes; + } + + return @disabled_nodes; +} + ############################################################################### # Main (Pacemaker) ############################################################################### From 64d2d78137ef966d4f27d47c374a16e863bf6d1b Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 6 Sep 2023 13:59:12 +0200 Subject: [PATCH 004/104] #11014 fixed responsive user QR code --- pandora_console/include/styles/pandora.css | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d87d959ac5..a1821011d7 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12566,3 +12566,31 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { .ui-date-range-in > a { background-color: #81b92e3b !important; } + +@media screen and (min-width: 1190px) and (max-width: 1290px) { + #api_qrcode_display { + left: 580px; + } +} + +@media screen and (min-width: 1143px) and (max-width: 1189px) { + #api_qrcode_display { + left: 528px; + } +} + +@media screen and (min-width: 860px) and (max-width: 1142px) { + #api_qrcode_display { + left: 356px; + top: 120px; + } + + .font-title-font { + line-height: 0; + } + + #qr_code_agent_view > img { + width: 250px; + height: 250px; + } +} From 4ed724edccfbbca7216fdb6748fdac17b8fc0a3f Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 23 Nov 2023 12:15:55 -0600 Subject: [PATCH 005/104] Add SSL valitations for Cipher and Version --- tentacle/conf/tentacle_server.conf.new | 8 ++++- tentacle/tentacle_server | 47 ++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/tentacle/conf/tentacle_server.conf.new b/tentacle/conf/tentacle_server.conf.new index 1acf082ca2..390369995f 100644 --- a/tentacle/conf/tentacle_server.conf.new +++ b/tentacle/conf/tentacle_server.conf.new @@ -72,4 +72,10 @@ log_file /dev/null # ssl_password 0 # [-T] Use libwrap library (Authen::Libwrap perl module) -# use_libwrap 0 \ No newline at end of file +# use_libwrap 0 + +# [-z] Restrict to a specific ssl version +# ssl_version TLSv1_3 + +# [-u] Restrict to a specific ssl cipher +# ssl_cipher AES256-SHA diff --git a/tentacle/tentacle_server b/tentacle/tentacle_server index 6d503e0053..cf9b521cdd 100755 --- a/tentacle/tentacle_server +++ b/tentacle/tentacle_server @@ -187,6 +187,12 @@ my $t_proxy_ip = undef; # Port to proxy client requests to my $t_proxy_port = 41121; +# Allowed SSL Cipher +my $t_ssl_cipher= ''; + +# Allowed SSL Version +my $t_ssl_version= ''; + # Proxy socket my $t_proxy_socket; @@ -230,7 +236,7 @@ sub print_help { print ("\t-p port\t\tPort to listen on (default $t_port).\n"); print ("\t-q\t\tQuiet. Do now print error messages.\n"); print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n"); - print ("\t-S (install|uninstall|run) Manage the win32 service.\n"); + print ("\t-S \t\t(install|uninstall|run) Manage the win32 service.\n"); print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n"); print ("\t-v\t\tBe verbose (display errors).\n"); print ("\t-V\t\tBe verbose on hard way (display errors and other info).\n"); @@ -239,7 +245,9 @@ sub print_help { print ("\t-b ip_address\tProxy requests to the given address.\n"); print ("\t-g port\t\tProxy requests to the given port.\n"); print ("\t-T\t\tEnable tcpwrappers support.\n"); - print ("\t \t\t(To use this option, 'Authen::Libwrap' should be installed.)\n\n"); + print ("\t \t\t(To use this option, 'Authen::Libwrap' should be installed.)\n"); + print ("\t-z\t\tRestrict to a specific SSL Version.\n"); + print ("\t-u\t\tRestrict to a specific SSL Cipher.\n\n"); } ################################################################################ @@ -287,7 +295,7 @@ sub parse_options { my @t_addresses_tmp; # Get options - if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:zu:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -547,6 +555,18 @@ sub parse_options { } } + # Specific SSL Version + $token_value = get_config_value($opts{'z'}, $CONF->{'ssl_version'}); + if (defined ($token_value)) { + $t_ssl_version = $token_value; + } + + # Specific SSL Cipher + $token_value = get_config_value($opts{'u'}, $CONF->{'ssl_cipher'}); + if (defined ($token_value)) { + $t_ssl_cipher = $token_value; + } + # Win32 service management if (defined ($opts{'S'})) { my $service_action = $opts{'S'}; @@ -817,9 +837,30 @@ sub start_ssl { error ($err); } + validate_ssl(); + print_log ("SSL started for " . $t_client_socket->sockhost ()); } +################################################################################ +## SUB validate_ssl +## Validate that a socket has a defined ssl version and cipher. +################################################################################ +sub validate_ssl{ + my $ssl_version = $t_client_socket->get_ssl_version(); + my $ssl_cipher = $t_client_socket->get_cipher(); + + if($t_ssl_version && $ssl_version ne $t_ssl_version){ + $t_client_socket->close(); + error ("Invalid SSL Version " . $ssl_version . ", expected version is " . $t_ssl_version . "."); + } + + if($t_ssl_cipher && $ssl_cipher ne $t_ssl_cipher){ + $t_client_socket->close(); + error ("Invalid SSL Cipher " . $ssl_cipher . ", expected cipher is " . $t_ssl_cipher . "."); + } +} + ################################################################################ ## SUB accept_connections ## Manage incoming connections. From 245154ce21e8ae1cdba4daf1f436dd737d576a58 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Fri, 24 Nov 2023 09:37:20 -0600 Subject: [PATCH 006/104] Pass version and cipher as args instead of validating afterwards. --- tentacle/tentacle_server | 41 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/tentacle/tentacle_server b/tentacle/tentacle_server index cf9b521cdd..b6d6ae7b08 100755 --- a/tentacle/tentacle_server +++ b/tentacle/tentacle_server @@ -295,7 +295,7 @@ sub parse_options { my @t_addresses_tmp; # Get options - if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:zu:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:z:u:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -808,13 +808,19 @@ sub stop_server { sub start_ssl { my $err; + my %ssl_args = ( + SSL_cert_file => $t_ssl_cert, + SSL_key_file => $t_ssl_key, + SSL_passwd_cb => sub {return $t_ssl_pwd}, + SSL_server => 1, + SSL_cipher_list => $t_ssl_cipher // '', + SSL_version => $t_ssl_version // '', + ); + if ($t_ssl_ca eq '') { IO::Socket::SSL->start_SSL ( $t_client_socket, - SSL_cert_file => $t_ssl_cert, - SSL_key_file => $t_ssl_key, - SSL_passwd_cb => sub {return $t_ssl_pwd}, - SSL_server => 1, + %ssl_args, # Verify peer SSL_verify_mode => 0x01, ); @@ -822,11 +828,8 @@ sub start_ssl { else { IO::Socket::SSL->start_SSL ( $t_client_socket, + %ssl_args, SSL_ca_file => $t_ssl_ca, - SSL_cert_file => $t_ssl_cert, - SSL_key_file => $t_ssl_key, - SSL_passwd_cb => sub {return $t_ssl_pwd}, - SSL_server => 1, # Fail verification if no peer certificate exists SSL_verify_mode => 0x03, ); @@ -837,29 +840,9 @@ sub start_ssl { error ($err); } - validate_ssl(); - print_log ("SSL started for " . $t_client_socket->sockhost ()); } -################################################################################ -## SUB validate_ssl -## Validate that a socket has a defined ssl version and cipher. -################################################################################ -sub validate_ssl{ - my $ssl_version = $t_client_socket->get_ssl_version(); - my $ssl_cipher = $t_client_socket->get_cipher(); - - if($t_ssl_version && $ssl_version ne $t_ssl_version){ - $t_client_socket->close(); - error ("Invalid SSL Version " . $ssl_version . ", expected version is " . $t_ssl_version . "."); - } - - if($t_ssl_cipher && $ssl_cipher ne $t_ssl_cipher){ - $t_client_socket->close(); - error ("Invalid SSL Cipher " . $ssl_cipher . ", expected cipher is " . $t_ssl_cipher . "."); - } -} ################################################################################ ## SUB accept_connections From d5c24609d61f7cc38f2b5a8b28db8580a918e4c6 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Nov 2023 11:21:54 +0100 Subject: [PATCH 007/104] add tables merge process pandora_enterprise#12352 --- pandora_console/extras/mr/68.sql | 40 +++++++++++++++++++++++++++++ pandora_console/pandoradb.sql | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 pandora_console/extras/mr/68.sql diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..999d8e6c3c --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,40 @@ +START TRANSACTION; + +DROP TABLE IF EXISTS `tmerge_error`; +CREATE TABLE IF NOT EXISTS `tmerge_error` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `step` int(10) default 0, + `msg` LONGTEXT default "", + `action` text default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +DROP TABLE IF EXISTS `tmerge_steps`; +CREATE TABLE IF NOT EXISTS `tmerge_steps` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `total` int(10) default 0, + `step` int(10) default 0, + `debug` varchar(1024) default "", + `action` varchar(100) default "", + `affected` varchar(100) default "", + `query` mediumtext default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +DROP TABLE IF EXISTS `tmerge_queries`; +CREATE TABLE IF NOT EXISTS `tmerge_queries` ( + `steps` int(10) NOT NULL auto_increment, + `action` varchar(100) default "", + `affected` varchar(100) default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + `query` LONGTEXT NOT NULL default "", + PRIMARY KEY (`steps`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b98f706667..78a7833861 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4534,4 +4534,47 @@ CREATE TABLE IF NOT EXISTS `tpandora_cve` ( `cvss_score` DOUBLE DEFAULT NULL, `cvss_vector` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`cve_id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_error` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_error` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `step` int(10) default 0, + `msg` LONGTEXT default "", + `action` text default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_steps` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_steps` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `total` int(10) default 0, + `step` int(10) default 0, + `debug` varchar(1024) default "", + `action` varchar(100) default "", + `affected` varchar(100) default "", + `query` mediumtext default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_queries` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_queries` ( + `steps` int(10) NOT NULL auto_increment, + `action` varchar(100) default "", + `affected` varchar(100) default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + `query` LONGTEXT NOT NULL default "", + PRIMARY KEY (`steps`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; \ No newline at end of file From 9da2ad8682b69f929e97dfdb27ce2017d79ff25c Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 1 Dec 2023 09:26:48 +0100 Subject: [PATCH 008/104] add tables merge process pandora_enterprise#12352 --- pandora_console/extras/mr/68.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 999d8e6c3c..c0e5788091 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -1,6 +1,5 @@ START TRANSACTION; -DROP TABLE IF EXISTS `tmerge_error`; CREATE TABLE IF NOT EXISTS `tmerge_error` ( `id` int(10) NOT NULL auto_increment, `id_node` int(10) default 0, @@ -12,7 +11,8 @@ CREATE TABLE IF NOT EXISTS `tmerge_error` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -DROP TABLE IF EXISTS `tmerge_steps`; +ALTER TABLE `tmerge_error` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + CREATE TABLE IF NOT EXISTS `tmerge_steps` ( `id` int(10) NOT NULL auto_increment, `id_node` int(10) default 0, @@ -27,7 +27,8 @@ CREATE TABLE IF NOT EXISTS `tmerge_steps` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -DROP TABLE IF EXISTS `tmerge_queries`; +ALTER TABLE `tmerge_steps` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + CREATE TABLE IF NOT EXISTS `tmerge_queries` ( `steps` int(10) NOT NULL auto_increment, `action` varchar(100) default "", @@ -37,4 +38,6 @@ CREATE TABLE IF NOT EXISTS `tmerge_queries` ( PRIMARY KEY (`steps`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + COMMIT; From 8a92b39eee596013fc4b95eedd425e5fe599999e Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Dec 2023 11:59:31 +0100 Subject: [PATCH 009/104] add new filters widget modules status pandora_enterprise#12267 --- pandora_console/include/ajax/module.php | 33 +++ .../lib/Dashboard/Widgets/ModulesByStatus.php | 278 +++++++----------- 2 files changed, 145 insertions(+), 166 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index e4eba79858..c3e099f0cb 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1851,6 +1851,8 @@ if (check_login()) { $table_id = get_parameter('table_id', ''); $search = get_parameter('search', ''); + $search_agent = get_parameter('search_agent', ''); + $groupId = (int) get_parameter('groupId', 0); $module_name = get_parameter('module_name', ''); $status = get_parameter('status', ''); $start = get_parameter('start', 0); @@ -1862,13 +1864,36 @@ if (check_login()) { $nodes = get_parameter('nodes', 0); $disabled_modules = (bool) get_parameter('disabled_modules', false); + $groups_array = []; + if ($groupId === 0) { + if (users_can_manage_group_all('AR') === false) { + $groups_array = users_get_groups(false, 'AR', false); + } + } else { + $groups_array = [$groupId]; + } + $where = '1=1'; $recordsTotal = 0; + if (empty($groups_array) === false) { + $where .= sprintf( + ' AND (tagente.id_grupo IN (%s) + OR tagent_secondary_group.id_group IN(%s))', + implode(',', $groups_array), + implode(',', $groups_array) + ); + } + + if (empty($search) === false) { $where .= ' AND tagente_modulo.nombre LIKE "%%'.$search.'%%"'; } + if (empty($search_agent) === false) { + $where .= ' AND tagente.alias LIKE "%%'.$search_agent.'%%"'; + } + if (str_contains($status, '6') === true) { $expl = explode(',', $status); $exist = array_search('6', $expl); @@ -1943,6 +1968,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s ORDER BY %s LIMIT %d, %d', @@ -1960,6 +1987,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); @@ -1987,6 +2016,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); @@ -2019,6 +2050,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index e490135734..86a6cde7ed 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -200,6 +200,14 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $values = parent::decoders($decoder); + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['search_agent']) === true) { + $values['search_agent'] = $decoder['search_agent']; + } + if (isset($decoder['search']) === true) { $values['search'] = $decoder['search']; } @@ -240,9 +248,39 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); + $return_all_group = false; + if (users_can_manage_group_all('RM') || $values['groupId'] == 0) { + $return_all_group = true; + } + + // Groups. + $inputs[] = [ + 'label' => __('Group'), + 'arguments' => [ + 'type' => 'select_groups', + 'name' => 'groupId', + 'returnAllGroup' => $return_all_group, + 'privilege' => 'AR', + 'selected' => $values['groupId'], + 'return' => true, + ], + ]; + + // Search Agent. + $inputs[] = [ + 'label' => __('Search agent').ui_print_help_tip(__('Search filter by Agent name field content'), true), + 'arguments' => [ + 'name' => 'search_agent', + 'type' => 'text', + 'value' => $values['search_agent'], + 'return' => true, + 'size' => 0, + ], + ]; + // Search. $inputs[] = [ - 'label' => __('Free search').ui_print_help_tip(__('Search filter by Module name field content'), true), + 'label' => __('Search module').ui_print_help_tip(__('Search filter by Module name field content'), true), 'arguments' => [ 'name' => 'search', 'type' => 'text', @@ -373,7 +411,9 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $values = parent::getPost(); + $values['groupId'] = \get_parameter('groupId', 0); $values['search'] = \get_parameter('search', ''); + $values['search_agent'] = \get_parameter('search_agent', ''); $values['status'] = \get_parameter('status', ''); $values['limit'] = \get_parameter('limit', ''); $values['nodes'] = \get_parameter('nodes', ''); @@ -386,173 +426,73 @@ class ModulesByStatus extends Widget /** * Draw widget. * - * @return string; + * @return void Html output; */ public function load() { - $this->size = parent::getSize(); + // Datatables list. + try { + $info_columns = $this->columns(); + $column_names = $info_columns['column_names']; + $columns = $info_columns['columns']; + $hash = get_parameter('auth_hash', ''); + $id_user = get_parameter('id_user', ''); - global $config; - - $output = ''; - - if (is_metaconsole() === true) { - $modules = []; - - $servers_ids = array_column(metaconsole_get_servers(), 'id'); - - foreach ($servers_ids as $server_id) { - try { - $node = new Node((int) $server_id); - - $node->connect(); - $modules_tmp = $this->getInfoModules( - $this->values['search'], - $this->values['status'], - $this->values['nodes'] - ); - $modules[$node->id()] = $modules_tmp[0]; - $node->disconnect(); - } catch (\Exception $e) { - // Unexistent modules. - $node->disconnect(); - } - } - } else { - $modules = $this->getInfoModules( - $this->values['search'], - $this->values['status'] + $tableId = 'ModuleByStatus_'.$this->dashboardId.'_'.$this->cellId; + // Load datatables user interface. + ui_print_datatable( + [ + 'id' => $tableId, + 'class' => 'info_table align-left-important', + 'style' => 'width: 100%', + 'columns' => $columns, + 'column_names' => $column_names, + 'ajax_url' => 'include/ajax/module', + 'ajax_data' => [ + 'get_data_ModulesByStatus' => 1, + 'table_id' => $tableId, + 'search_agent' => $this->values['search_agent'], + 'search' => $this->values['search'], + 'groupId' => $this->values['groupId'], + 'status' => $this->values['status'], + 'nodes' => $this->values['nodes'], + 'disabled_modules' => $this->values['disabled_modules'], + 'auth_hash' => $hash, + 'auth_class' => 'PandoraFMS\Dashboard\Manager', + 'id_user' => $id_user, + ], + 'default_pagination' => $this->values['limit'], + 'order' => [ + 'field' => 'last_status_change', + 'direction' => 'desc', + ], + 'csv' => 0, + 'pagination_options' => [ + [ + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + [ + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + ], + 'dom_elements' => 'frtilp', + ] ); + } catch (\Exception $e) { + echo $e->getMessage(); } - - if ($modules !== false && empty($modules) === false) { - // Datatables list. - try { - $info_columns = $this->columns(); - $column_names = $info_columns['column_names']; - $columns = $info_columns['columns']; - $hash = get_parameter('auth_hash', ''); - $id_user = get_parameter('id_user', ''); - - $tableId = 'ModuleByStatus_'.$this->dashboardId.'_'.$this->cellId; - // Load datatables user interface. - ui_print_datatable( - [ - 'id' => $tableId, - 'class' => 'info_table align-left-important', - 'style' => 'width: 100%', - 'columns' => $columns, - 'column_names' => $column_names, - 'ajax_url' => 'include/ajax/module', - 'ajax_data' => [ - 'get_data_ModulesByStatus' => 1, - 'table_id' => $tableId, - 'search' => $this->values['search'], - 'status' => $this->values['status'], - 'nodes' => $this->values['nodes'], - 'disabled_modules' => $this->values['disabled_modules'], - 'auth_hash' => $hash, - 'auth_class' => 'PandoraFMS\Dashboard\Manager', - 'id_user' => $id_user, - ], - 'default_pagination' => $this->values['limit'], - 'order' => [ - 'field' => 'last_status_change', - 'direction' => 'desc', - ], - 'csv' => 0, - 'pagination_options' => [ - [ - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - ], - [ - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - ], - ], - 'dom_elements' => 'frtilp', - ] - ); - } catch (\Exception $e) { - echo $e->getMessage(); - } - } else { - $output = ''; - $output .= '
'; - $output .= \ui_print_info_message( - __('Not found modules'), - '', - true - ); - $output .= '
'; - - return $output; - } - } - - - /** - * Get info modules. - * - * @param string $search Free search. - * @param string $status Modules status. - * - * @return array Data. - */ - private function getInfoModules(string $search, string $status): array - { - if (empty($search) === false) { - $where = 'tagente_modulo.nombre LIKE "%%'.$search.'%%" AND '; - } - - if (str_contains($status, '6') === true) { - $expl = explode(',', $status); - $exist = array_search('6', $expl); - if (isset($exist) === true) { - unset($expl[$exist]); - } - - array_push($expl, '1', '2'); - - $status = implode(',', $expl); - } - - $where .= sprintf( - 'tagente_estado.estado IN (%s) - AND tagente_modulo.delete_pending = 0', - $status - ); - - $sql = sprintf( - 'SELECT - COUNT(*) AS "modules" - FROM tagente_modulo - INNER JOIN tagente - ON tagente_modulo.id_agente = tagente.id_agente - INNER JOIN tagente_estado - ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - WHERE %s', - $where - ); - - $modules = db_get_all_rows_sql($sql); - - if ($modules === false) { - $modules = []; - } - - return $modules; } @@ -579,7 +519,10 @@ class ModulesByStatus extends Widget 'nombre', 'alias', 'server_name', - 'last_status_change', + [ + 'text' => 'last_status_change', + 'class' => 'flex-column', + ], 'estado', ]; } else { @@ -593,7 +536,10 @@ class ModulesByStatus extends Widget $columns = [ 'nombre', 'alias', - 'last_status_change', + [ + 'text' => 'last_status_change', + 'class' => 'flex-column', + ], 'estado', ]; } @@ -642,12 +588,12 @@ class ModulesByStatus extends Widget $height_counter = (((int) count($nodes_fields)) * 20); $size = [ - 'width' => 450, + 'width' => 470, 'height' => (520 + $height_counter), ]; } else { $size = [ - 'width' => 450, + 'width' => 470, 'height' => 480, ]; } From 3d635449398886bf4392cdd6ead6422744211480 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:14:12 +0100 Subject: [PATCH 010/104] get data in file count from module --- .../include/class/ConsoleSupervisor.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 83208256fb..e34740711e 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -27,6 +27,7 @@ */ use PandoraFMS\Tools\Files; +use PandoraFMS\Agent; global $config; @@ -1162,11 +1163,20 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } - $filecount = $this->countFiles( - $config['attachment_store'], - '', - $config['num_files_attachment'] - ); + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); + if ($agentId !== false) { + $agent = new Agent($agentId); + + $moduleId = $agent->searchModules( + ['nombre' => 'Data_in_files'], + 1 + )->toArray()['id_agente_modulo']; + + if ($moduleId > 0) { + $filecount = (int) modules_get_last_value($moduleId); + } + } + if ($filecount > $config['num_files_attachment']) { $this->notify( [ From 2eae64407d4645cd8bc4eeb73a14005c4aac62fe Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:17:42 +0100 Subject: [PATCH 011/104] get data in file count from module --- pandora_console/include/class/ConsoleSupervisor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index e34740711e..a7676d4b40 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1163,6 +1163,8 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } + $filecount = 0; + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); if ($agentId !== false) { $agent = new Agent($agentId); From 7f4dc4fbe458b675a378b7e6813e908986eee0f1 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 11 Dec 2023 09:18:40 +0100 Subject: [PATCH 012/104] #12460 fixed log deprecated --- pandora_console/include/functions_api.php | 6 +++--- pandora_console/include/functions_ui.php | 4 ++++ .../include/lib/TacticalView/elements/NewsBoard.php | 2 ++ pandora_console/operation/events/events.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8f5fb66f54..07b512f55c 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -541,7 +541,7 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) } -function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType) +function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType='') { $idAgent = agents_get_agent_id($agentName); @@ -558,7 +558,7 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other='; } -function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType) +function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType='') { $sql = sprintf( 'SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo @@ -573,7 +573,7 @@ function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other= } -function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType) +function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType='') { global $config; if (defined('METACONSOLE')) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 5c9a7e90fc..4a0db88991 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -147,6 +147,10 @@ function ui_print_truncate_text( $text_html_decoded = io_safe_output($text); $text_has_entities = $text != $text_html_decoded; + if ($text_html_decoded === null) { + $text_html_decoded = ''; + } + if (mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) { // '/2' because [...] is in the middle of the word. $half_length = intval(($numChars - 3) / 2); diff --git a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php index 3be2dd685f..a2a2b7faba 100644 --- a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php +++ b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php @@ -117,6 +117,8 @@ class NewsBoard extends Element $output .= ''; return $output; + } else { + return ''; } } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..c924794d6d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -505,7 +505,7 @@ if (is_ajax() === true) { } } - if (strlen($tmp->server_name) >= 10) { + if (strlen(($tmp->server_name ?? '')) >= 10) { $tmp->server_name = ui_print_truncate_text( $tmp->server_name, 10, From 160514cfbe5acd41941de26f0ca5e31d2fa10a09 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 13 Dec 2023 10:08:13 +0100 Subject: [PATCH 013/104] fix filter bug --- pandora_console/include/functions_events.php | 7 ++++++- pandora_console/operation/events/events.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..852d00f270 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6472,7 +6472,12 @@ function event_print_graph( $color[] = '#82b92f'; } } else { - $interval_length = (int) ($period / $num_intervals); + $interval_length = 0; + + if ($num_intervals > 0) { + $interval_length = (int) ($period / $num_intervals); + } + $intervals = []; $intervals[0] = $start_utimestamp; for ($i = 0; $i < $num_intervals; $i++) { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..f47fc71f55 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1234,7 +1234,7 @@ if (is_ajax() === true) { $data = array_values( array_filter( - $data, + ($data ?? []), function ($item) { return (bool) (array) $item; } From 29260473fce207f10c842c99ce89c83fa9a5d8f2 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 13 Dec 2023 13:29:48 +0100 Subject: [PATCH 014/104] fix missing fields --- .../godmode/events/event_responses.editor.php | 20 +++++++++---------- pandora_console/include/styles/events.css | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/events/event_responses.editor.php b/pandora_console/godmode/events/event_responses.editor.php index ae31e10ad1..477aa70e85 100644 --- a/pandora_console/godmode/events/event_responses.editor.php +++ b/pandora_console/godmode/events/event_responses.editor.php @@ -285,7 +285,7 @@ if (enterprise_installed()) { $data = []; $data[0] = html_print_label_input_block( '', - '