From 895b7c74032bc4b04e3b05a424b629c59514cc5e Mon Sep 17 00:00:00 2001 From: alejandro Date: Mon, 23 Jan 2023 18:17:05 +0100 Subject: [PATCH 001/233] added exchange mail plugin --- .../Exchange_mail/exchange_mail.py | 451 ++++++++++++++++++ 1 file changed, 451 insertions(+) create mode 100644 pandora_plugins/Exchange_mail/exchange_mail.py diff --git a/pandora_plugins/Exchange_mail/exchange_mail.py b/pandora_plugins/Exchange_mail/exchange_mail.py new file mode 100644 index 0000000000..638c00d07e --- /dev/null +++ b/pandora_plugins/Exchange_mail/exchange_mail.py @@ -0,0 +1,451 @@ +# -*- coding: utf-8 -*- +from exchangelib import DELEGATE, Account, Credentials, Configuration,Message, Mailbox +from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter +from exchangelib import EWSTimeZone, EWSDateTime +BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter + +import urllib3 +urllib3.disable_warnings() + +import argparse,sys,re,json,os,traceback +from datetime import datetime,timedelta,timezone + + +__author__ = "Alejandro Sánchez Carrion" +__copyright__ = "Copyright 2022, PandoraFMS" +__maintainer__ = "Operations department" +__status__ = "Production" +__version__= '1.0' + +info = f""" +Pandora FMS Exchange Mail +Version = {__version__} +Description = This plugin can search for matches in your mail and find the number of matches, as well as list them. + +Manual execution + +./exchange_mail --server --username --password [ --subject ] [ --sender ] [ --date_start ] [ --date_end ] [ --agent_name ] [ --as_agent_plugin ] [ --tentacle_port ] [ --tentacle_address ] [ -g ] [ --data_dir ] + +there are four parameters with which to filter the mails + +subject +email +date + +You can use only one and filter from that or use the following combinations: + +subject +subject + sender +subject + sender + date +""" + +parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter) +parser.add_argument('--server', help="Server name") +parser.add_argument('--username', help="User name") +parser.add_argument('--password', help="Password") +parser.add_argument('--smtp_address', help="SMTP address") +parser.add_argument('--subject', help="Select match in subjects") +parser.add_argument('--sender', help="Select coincidences from email") +parser.add_argument('--date_start', help="Search for matches from a certain date,Each date must be separated by a hyphen and in quotation marks, with the following format: 'year-month-day-hour-minute'. example: '2021-1-12-0-0'") +parser.add_argument('--date_end', help="Search for matches from a certain date,Each date must be separated by a hyphen and in quotation marks, with the following format: 'year-month-day-hour-minute'. example: '2021-6-12-0-0'") +parser.add_argument('--mail_list', help='List mail coincidences',type=int,default=0) + +parser.add_argument('--agent_name', help='agent name', default= "Exchange") +parser.add_argument('--module_prefix', help='module prefix', default= "Exchange") +parser.add_argument('-g', '--group', help='PandoraFMS destination group (default exchange)', default='exchange') +parser.add_argument('--data_dir', help='PandoraFMS data dir (default: /var/spool/pandora/data_in/)', default='/var/spool/pandora/data_in/') +parser.add_argument('--as_agent_plugin', help='mode plugin', default=0,type=int) +parser.add_argument('--tentacle_port', help='tentacle port', default=41121) +parser.add_argument('--tentacle_address', help='tentacle adress', default=None) + + +args = parser.parse_args() + +username,password,server,smtp_address=args.username,args.password,args.server,args.smtp_address + + +### Pandora Tools ###------------------------------------------------------------------------------------------------------- +modules = [] + +configuration = { + "data_in": args.data_dir, + "group" : args.group +} + +######################################################################################### +# print_agent +######################################################################################### +def print_agent(agent, modules, data_dir="/var/spool/pandora/data_in/", log_modules= None, print_flag = None): + """Prints agent XML. Requires agent conf (dict) and modules (list) as arguments. + - Use print_flag to show modules' XML in STDOUT. + - Returns a tuple (xml, data_file). + """ + data_file=None + + header = "\n" + header += "\n" + "\t\n" + "\t" + str(data["type"]) + "\n" + ) + + if type(data["type"]) is not str and "string" not in data["type"]: #### Strip spaces if module not generic_data_string + data["value"] = data["value"].strip() + if isinstance(data["value"], list): # Checks if value is a list + module_xml += "\t\n" + for value in data["value"]: + if type(value) is dict and "value" in value: + module_xml += "\t\n" + module_xml += "\t\t\n" + if "timestamp" in value: + module_xml += "\t\t\n" + module_xml += "\t\n" + module_xml += "\t\n" + else: + module_xml += "\t\n" + if "desc" in data: + module_xml += "\t\n" + if "unit" in data: + module_xml += "\t\n" + if "interval" in data: + module_xml += "\t\n" + if "tags" in data: + module_xml += "\t" + str(data["tags"]) + "\n" + if "module_group" in data: + module_xml += "\t" + str(data["module_group"]) + "\n" + if "module_parent" in data: + module_xml += "\t" + str(data["module_parent"]) + "\n" + if "min_warning" in data: + module_xml += "\t\n" + if "min_warning_forced" in data: + module_xml += "\t\n" + if "max_warning" in data: + module_xml += "\t\n" + if "max_warning_forced" in data: + module_xml += "\t\n" + if "min_critical" in data: + module_xml += "\t\n" + if "min_critical_forced" in data: + module_xml += "\t\n" + if "max_critical" in data: + module_xml += "\t\n" + if "max_critical_forced" in data: + module_xml += "\t\n" + if "str_warning" in data: + module_xml += "\t\n" + if "str_warning_forced" in data: + module_xml += "\t\n" + if "str_critical" in data: + module_xml += "\t\n" + if "str_critical_forced" in data: + module_xml += "\t\n" + if "critical_inverse" in data: + module_xml += "\t\n" + if "warning_inverse" in data: + module_xml += "\t\n" + if "max" in data: + module_xml += "\t\n" + if "min" in data: + module_xml += "\t\n" + if "post_process" in data: + module_xml += "\t\n" + if "disabled" in data: + module_xml += "\t\n" + if "min_ff_event" in data: + module_xml += "\t\n" + if "status" in data: + module_xml += "\t\n" + if "timestamp" in data: + module_xml += "\t\n" + if "custom_id" in data: + module_xml += "\t\n" + if "critical_instructions" in data: + module_xml += "\t\n" + if "warning_instructions" in data: + module_xml += "\t\n" + if "unknown_instructions" in data: + module_xml += "\t\n" + if "quiet" in data: + module_xml += "\t\n" + if "module_ff_interval" in data: + module_xml += "\t\n" + if "crontab" in data: + module_xml += "\t\n" + if "min_ff_event_normal" in data: + module_xml += "\t\n" + if "min_ff_event_warning" in data: + module_xml += "\t\n" + if "min_ff_event_critical" in data: + module_xml += "\t\n" + if "ff_type" in data: + module_xml += "\t\n" + if "ff_timeout" in data: + module_xml += "\t\n" + if "each_ff" in data: + module_xml += "\t\n" + if "module_parent_unlink" in data: + module_xml += "\t\n" + if "global_alerts" in data: + for alert in data["alert"]: + module_xml += "\t\n" + module_xml += "\n" + + if print_flag: + print (module_xml) + + return (module_xml) + +######################################################################################### +# write_xml +######################################################################################### + +def write_xml(xml, agent_name, data_dir="/var/spool/pandora/data_in/"): + """Creates a agent .data file in the specified data_dir folder\n + Args: + - xml (str): XML string to be written in the file. + - agent_name (str): agent name for the xml and file name. + - data_dir (str): folder in which the file will be created.""" + Utime = datetime.now().strftime('%s') + data_file = "%s/%s.%s.data" %(str(data_dir),agent_name,str(Utime)) + try: + with open(data_file, 'x') as data: + data.write(xml) + except OSError as o: + sys.exit(f"ERROR - Could not write file: {o}, please check directory permissions") + except Exception as e: + sys.exit(f"{type(e).__name__}: {e}") + return (data_file) + +# # default agent +def clean_agent() : + global agent + agent = { + "agent_name" : "", + "agent_alias" : "", + "parent_agent_name" : "", + "description" : "", + "version" : "", + "os_name" : "", + "os_version" : "", + "timestamp" : datetime.today().strftime('%Y/%m/%d %H:%M:%S'), + #"utimestamp" : int(datetime.timestamp(datetime.today())), + "address" : "", + "group" : configuration["group"], + "interval" : "", + "agent_mode" : "1", + } + return agent + +# default module +def clean_module() : + global modulo + modulo = { + "name" : "", + "type" : "generic_data_string", + "desc" : "", + "value" : "", + } + return modulo + +######################################################################################### +# tentacle_xml +######################################################################################### +def tentacle_xml(file, tentacle_ops,tentacle_path='', debug=0): + """Sends file using tentacle protocol\n + - Only works with one file at time. + - file variable needs full file path. + - tentacle_opts should be a dict with tentacle options (address [password] [port]). + - tentacle_path allows to define a custom path for tentacle client in case is not in sys path). + - if debug is enabled, the data file will not be removed after being sent. + + Returns 0 for OK and 1 for errors. + """ + + if file is None : + sys.stderr.write("Tentacle error: file path is required.") + else : + data_file = file + + if tentacle_ops['address'] is None : + sys.stderr.write("Tentacle error: No address defined") + return 1 + + try : + with open(data_file, 'r') as data: + data.read() + data.close() + except Exception as e : + sys.stderr.write(f"Tentacle error: {type(e).__name__} {e}") + return 1 + + tentacle_cmd = f"{tentacle_path}tentacle_client -v -a {tentacle_ops['address']} " + if "port" in tentacle_ops: + tentacle_cmd += f"-p {tentacle_ops['port']} " + if "password" in tentacle_ops: + tentacle_cmd += f"-x {tentacle_ops['password']} " + tentacle_cmd += f"{data_file} " + + tentacle_exe=Popen(tentacle_cmd, stdout=PIPE, shell=True) + rc=tentacle_exe.wait() + + if rc != 0 : + sys.stderr.write("Tentacle error") + return 1 + elif debug == 0 : + os.remove(file) + + return 0 + +## funcion agent +def agentplugin(modules,agent,plugin_type="server",data_dir="/var/spool/pandora/data_in/",tentacle=False,tentacle_conf=None) : + if plugin_type == "server": + for modulo in modules: + print_module(modulo,1) + + elif tentacle == True and tentacle_conf is not None: + agent_file=print_agent(agent, modules,data_dir) + if agent_file[1] is not None: + tentacle_xml(agent_file[1],tentacle_conf) + print ("1") + else: + print_agent(agent, modules,data_dir) + print ("1") + +def parse_result(list_email,sep="")-> list: + """ + + Return list containing each line as element + """ + + result=[] + + for line in list_email: + str_line=sep.join(str(elem) for elem in line) + str_dict={"value":str_line} + result.append(str_dict) + + return result + +# Create agent +clean_agent() +agent.update( + agent_name = args.agent_name , + agent_alias =args.agent_name , + description ="" +) + + +def connect(username,password,server,smtp_address): + creds = Credentials( + username=args.username, + password=args.password + ) + + try: + config = Configuration(server=args.server, credentials=creds) + + account = Account( + primary_smtp_address=args.smtp_address, + autodiscover=False, + config=config, + access_type=DELEGATE + ) + return account + except Exception as e: + sys.exit(f"{type(e).__name__}: {e}") + #print(account.root.tree()) + +account=connect(args.username,args.password,args.server,args.smtp_address) + +## Only one parameter +if args.subject and args.sender==None and args.date_start==None and args.date_end == None: + filtered_items = account.inbox.filter(subject__contains=args.subject) +if args.subject==None and args.sender and args.date_start==None and args.date_end == None: + filtered_items = account.inbox.filter(sender__icontains=args.sender) +if args.subject==None and args.sender==None and args.date_start and args.date_end : + date_start=args.date_start.split("-") + date_end=args.date_end.split("-") + filtered_items = account.inbox.filter(datetime_received__range=(datetime(int(date_start[0].strip()), int(date_start[1].strip()), int(date_start[2].strip()), int(date_start[3].strip()), int(date_start[4].strip())).replace(tzinfo=timezone.utc),datetime(int(date_end[0].strip()), int(date_end[1].strip()), int(date_end[2].strip()), int(date_end[3].strip()), int(date_end[4].strip())).replace(tzinfo=timezone.utc))) + +## Subject + sender +if args.subject and args.sender and args.date_start==None and args.date_end==None : + filtered_items = account.inbox.filter(sender__icontains=args.sender,subject__contains=args.subject) + +## All parameters +if args.subject and args.sender and args.date_start and args.date_end : + date_start=args.date_start.split("-") + date_end=args.date_end.split("-") + filtered_items = account.inbox.filter(datetime_received__range=(datetime(int(date_start[0].strip()), int(date_start[1].strip()), int(date_start[2].strip()), int(date_start[3].strip()), int(date_start[4].strip())).replace(tzinfo=timezone.utc),datetime(int(date_end[0].strip()), int(date_end[1].strip()), int(date_end[2].strip()), int(date_end[3].strip()), int(date_end[4].strip())).replace(tzinfo=timezone.utc)),sender__icontains=args.sender,subject__contains=args.subject) + +# List Number email coincidences +list_email=[] +# Count number messages coincidences +count=0 + +for item in filtered_items: + + count=count+1 + + list_email.append("("+str(item.datetime_received) + ") - "+str(item.subject)+" - "+str(item.sender)) + + #print(item.subject, item.sender, item.datetime_received) + +list_email = parse_result(list_email) + +clean_module() +modulo.update( + name = f"{args.module_prefix}.Coincidences_count", + type = "generic_data", + desc = "Number of mails matching the filter used in the run", + value = count +) +modules.append(modulo) + +if args.mail_list: + clean_module() + modulo.update( + name = f"{args.module_prefix}.Coincidences_list", + type = "generic_data_string", + desc = "List of mails matching the filter used in the run", + timestamp=datetime.today().strftime('%Y/%m/%d %H:%M:%S'), + value = list_email + ) + modules.append(modulo) + + +if args.tentacle_address is not None: + tentacle_conf={"address":args.tentacle_address,"port":args.tentacle_port} + agentplugin(modules,agent,"agent",configuration["data_in"],True,tentacle_conf) +elif args.as_agent_plugin!=1: + agentplugin(modules,agent,"agent",configuration["data_in"]) +else: + agentplugin(modules,agent) 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 002/233] 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 a85a7eccf8c212f854dd9af6cc1cf561aa7b3dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Sun, 4 Jun 2023 10:34:33 -0600 Subject: [PATCH 003/233] Modifications to accept spaces in agent alias CLI --- pandora_server/util/pandora_manage.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 07c7bf6ad1..b11e862790 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -5389,6 +5389,8 @@ sub cli_get_agents_id_name_by_alias() { my @agents; my $where_value; + $agent_alias =~ s/ / /g; + if($strict eq 'strict') { $where_value = $agent_alias; } else { @@ -5404,14 +5406,14 @@ sub cli_get_agents_id_name_by_alias() { print "[ERROR] No agents retrieved.\n\n"; } else { if(is_metaconsole($conf) == 1) { - print "alias, id_agente, id_tagente, id_server, server_name\n"; + print "id_agente, alias, id_tagente, id_server, server_name\n"; foreach my $agent (@agents) { - print safe_output($agent->{'alias'}).", ".$agent->{'id_agente'}.", ".$agent->{'id_tagente'}.", ".$agent->{'id_server'}.", ".$agent->{'server_name'}."\n"; + print safe_output($agent->{'id_agente'}).", ".$agent->{'alias'}.", ".$agent->{'id_tagente'}.", ".$agent->{'id_server'}.", ".$agent->{'server_name'}."\n"; } } else { - print "alias, id_agente\n"; + print "id_agente, alias\n"; foreach my $agent (@agents) { print $agent->{'id_agente'}.",".safe_output($agent->{'alias'})."\n"; From b7a6c8f7301eea6145e1a1eef2094493ed512dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Mon, 5 Jun 2023 08:41:10 -0600 Subject: [PATCH 004/233] Validate entities with safe input. --- pandora_server/util/pandora_manage.pl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b11e862790..a7cc0af873 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -5384,13 +5384,11 @@ sub cli_get_agent_status() { ############################################################################## sub cli_get_agents_id_name_by_alias() { - my $agent_alias = @ARGV[2]; + my $agent_alias = safe_input(@ARGV[2]); my $strict = @ARGV[3]; my @agents; my $where_value; - $agent_alias =~ s/ / /g; - if($strict eq 'strict') { $where_value = $agent_alias; } else { 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 005/233] 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 006/233] 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 9c9467c2da9961f32606cabe098839eb437caa94 Mon Sep 17 00:00:00 2001 From: alejandro Date: Mon, 14 Aug 2023 13:57:14 +0200 Subject: [PATCH 007/233] fix in plugin output --- pandora_server/util/plugin/wizard_wmi_module.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/plugin/wizard_wmi_module.pl b/pandora_server/util/plugin/wizard_wmi_module.pl index 23e49a7f83..d9c1b3d1aa 100755 --- a/pandora_server/util/plugin/wizard_wmi_module.pl +++ b/pandora_server/util/plugin/wizard_wmi_module.pl @@ -172,5 +172,6 @@ foreach my $k (keys %{$fields_values}){ # Get operation result my $result = eval $operation; if (defined($result)){ - print $result . "\n"; + + print $result, "\n"; } From 682494f51fa15479cdefacbf6347838e3423fa19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20S=C3=A1nchez?= Date: Mon, 14 Aug 2023 11:59:41 +0000 Subject: [PATCH 008/233] remove clear line --- pandora_server/util/plugin/wizard_wmi_module.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_server/util/plugin/wizard_wmi_module.pl b/pandora_server/util/plugin/wizard_wmi_module.pl index d9c1b3d1aa..fa25c26d0b 100755 --- a/pandora_server/util/plugin/wizard_wmi_module.pl +++ b/pandora_server/util/plugin/wizard_wmi_module.pl @@ -172,6 +172,5 @@ foreach my $k (keys %{$fields_values}){ # Get operation result my $result = eval $operation; if (defined($result)){ - print $result, "\n"; } From 64d2d78137ef966d4f27d47c374a16e863bf6d1b Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 6 Sep 2023 13:59:12 +0200 Subject: [PATCH 009/233] #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 010/233] 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 011/233] 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 012/233] 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 013/233] 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 cc1c138552271abbcf2804f6bce13e46dc19df73 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 4 Dec 2023 11:23:43 +0100 Subject: [PATCH 014/233] #12518 Fixed up custom field type link --- pandora_console/operation/agentes/estado_generalagente.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index dd4effe693..6e6615df51 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -298,8 +298,9 @@ foreach ($fields as $field) { if ($custom_value[0]['is_password_type']) { $data[1] = '••••••••'; } else if ($field['is_link_enabled'] === '1') { - list($link_text, $link_url) = json_decode($custom_value[0]['description'], true); - + $custom_link_type = io_safe_output($custom_value[0]['description']); + $custom_link_type = json_decode($custom_link_type); + list($link_text, $link_url) = $custom_link_type; if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; $link_url = ''; @@ -309,7 +310,7 @@ foreach ($fields as $field) { $link_text = $link_url; } - $data[1] = ''.$link_text.''; + $data[1] = ''.$link_text.''; } else { $custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']); $data[1] = $custom_value[0]['description']; From 8a92b39eee596013fc4b95eedd425e5fe599999e Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Dec 2023 11:59:31 +0100 Subject: [PATCH 015/233] 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 6e68e04027e999cbd052e90e9d1349ba09b74b74 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Dec 2023 16:34:03 +0100 Subject: [PATCH 016/233] quit pagebreak pandora_enterprise#11605 --- pandora_console/include/functions_reporting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index dce7dd9efc..72c6fbd642 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -15847,8 +15847,8 @@ function reporting_translate_sla_status_for_graph($status) */ function reporting_header_table_for_pdf($title='', $description='') { - $result_pdf = ''; - $result_pdf .= ''; + // $result_pdf = ''; + $result_pdf = '
'; $result_pdf .= ''; $result_pdf .= ' + + + + + + + + + + + + + + + + + + + +
'; $result_pdf .= $title; 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 017/233] 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 018/233] 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 019/233] #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 86671c721193b5bc4e202e3ae5d49937a724ed32 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 11 Dec 2023 11:36:34 +0100 Subject: [PATCH 020/233] #12350 added agent name editing --- .../godmode/agentes/agent_manager.php | 69 ++++++++++++++++++- .../godmode/agentes/configurar_agente.php | 18 ++++- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 26bae75929..a6e0d7e987 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -357,7 +357,18 @@ if ($new_agent === false) { $tableAgent->data['caption_name'][0] = __('Agent name'); $tableAgent->rowclass['name'] = 'w540px'; $tableAgent->cellstyle['name'][0] = 'width: 100%;'; - $tableAgent->data['name'][0] = html_print_input_text('agente', $nombre_agente, '', 76, 100, true, false, false, '', 'w100p'); + $tableAgent->data['name'][0] = html_print_input_text( + 'agente', + $nombre_agente, + '', + 76, + 100, + true, + true, + false, + '', + 'w100p' + ); $tableAgent->data['name'][0] .= html_print_div( [ 'class' => 'moduleIdBox', @@ -365,6 +376,28 @@ if ($new_agent === false) { ], true ); + + // Other than Linux, Solaris, AIX, BSD, HPUX, MacOs, and Windows. + if ($id_os !== '1' && $id_os !== '2' && $id_os !== '3' && $id_os !== '4' + && $id_os !== '5' && $id_os !== '7' && $id_os !== '8' + ) { + $tableAgent->data['name'][0] .= html_print_anchor( + [ + 'content' => html_print_image( + 'images/edit.svg', + true, + [ + 'border' => 0, + 'title' => __('Edit agent name'), + 'class' => 'main_menu_icon invert_filter after_input_icon forced_title clickable', + 'onclick' => 'editAgent()', + ] + ), + ], + true + ); + } + // Agent options for QR code. $agent_options_update = 'agent_options_update'; } @@ -1429,7 +1462,6 @@ ui_require_jquery_file('bgiframe'); 128 ); } - $("#text-agente").prop('readonly', true); // Disable fixed ip button if empty. @@ -1458,4 +1490,37 @@ ui_require_jquery_file('bgiframe'); $('#basic_options').addClass('invisible'); } } + + function editAgent() { + $(`#text-agente`).attr(`readonly`, false); + const title = ''; + const text = ''; + const id = uniqId(); + $("body").append('
'); + $("#" + id).empty(); + $("#" + id).append(text); + $("#" + id).dialog({ + height: 150, + width: 528, + opacity: 1, + modal: true, + position: { + my: "center", + at: "center", + of: window, + collision: "fit" + }, + title: title, + closeOnEscape: true, + buttons: [{ + text: "OK", + click: function() { + $(this).dialog("close"); + } + }], + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + }, + }).show(); + } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index b4abfa1ad7..673919908e 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -956,6 +956,13 @@ if ($update_agent) { $mssg_warning = 0; $id_agente = (int) get_parameter_post('id_agente'); $nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', '')); + $repeated_name = db_get_row_sql( + sprintf( + 'SELECT nombre FROM tagente WHERE id_agente <> %s AND nombre like "%s"', + $id_agente, + $nombre_agente + ) + ); $alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', ''))); $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); @@ -1084,14 +1091,17 @@ if ($update_agent) { } } + // Verify if there is another agent with the same name but different ID. + if (empty($repeated_name) === false) { + ui_print_error_message(__('Agent with repeated name')); + } + if ($mssg_warning) { ui_print_warning_message(__('The ip or dns name entered cannot be resolved')); } - // Verify if there is another agent with the same name but different ID. if ($alias == '') { ui_print_error_message(__('No agent alias specified')); - // If there is an agent with the same name, but a different ID. } if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') { @@ -1152,6 +1162,10 @@ if ($update_agent) { 'vul_scan_enabled' => $vul_scan_enabled, ]; + if (empty($repeated_name) === true) { + $values['nombre'] = $nombre_agente; + } + if ($config['metaconsole_agent_cache'] == 1) { $values['update_module_count'] = 1; // Force an update of the agent cache. 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 021/233] 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 022/233] 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( '', - '
+ __('Show aggregate by destination port'), + 1 => __('Show InBound/Outbound traffic per SrcIP/DestIP'), + ]; + html_print_select( + $types, + 'top_n_type', + $top_n_type, + '' + ); + ?> +
+ + + +
+ + + +
+ + + +
data = []; $table->head = []; - $table->head[0] = ''.__('Source IP').''; - $table->head[1] = ''.__('Destination IP').''; - $table->head[2] = ''.__('Bytes').''; - $table->head[3] = ''.__('% Traffic').''; - $table->head[4] = ''.__('Avg. Throughput').''; - $table->style[0] = 'padding: 4px'; + if ($show_extended === false) { + $table->head[0] = ''.__('Source IP').''; + $table->head[1] = ''.__('Destination IP').''; + $table->head[2] = ''.__('Bytes').''; + $table->head[3] = ''.__('% Traffic').''; + $table->head[4] = ''.__('Avg. Throughput').''; + $table->style[0] = 'padding: 4px'; + } else { + $table->head[0] = ''.__('Source IP').''; + $table->head[1] = ''.__('Destination IP').''; + $table->head[2] = ''.__('Ingress bytes').''; + $table->head[3] = ''.__('Egress bytes').''; + $table->head[4] = ''.__('Ingress packets').''; + $table->head[5] = ''.__('Egress packets').''; + $table->head[6] = ''.__('% Traffic').''; + $table->head[7] = ''.__('Avg. Throughput').''; + $table->style[0] = 'padding: 4px'; + } $i = 0; foreach ($data as $value) { $table->data[$i][0] = $value['ip_src']; $table->data[$i][1] = $value['ip_dst']; - $table->data[$i][2] = network_format_bytes($value['bytes']); - $traffic = '-'; - - if ($total_bytes > 0) { - $traffic = sprintf( - '%.2f', - (($value['bytes'] / $total_bytes) * 100) - ); + if ($show_extended === true) { + $table->data[$i][2] = network_format_bytes($value['ibytes']); + $table->data[$i][3] = network_format_bytes($value['obytes']); + $table->data[$i][4] = network_format_bytes($value['ipackages']); + $table->data[$i][5] = network_format_bytes($value['opackages']); + $table->data[$i][6] = $value['traffic'].' %'; + } else { + $table->data[$i][2] = network_format_bytes($value['bytes']); + $table->data[$i][3] = $value['traffic'].' %'; } - $table->data[$i][3] = $traffic.' %'; - $units = [ 'bps', 'Kbps', @@ -382,7 +394,11 @@ function netflow_top_n_table(array $data, int $total_bytes) $value['bps'] /= pow(1024, $pow); - $table->data[$i][4] = round($value['bps'], 2).' '.$units[$pow]; + if ($show_extended === true) { + $table->data[$i][7] = round($value['bps'], 2).' '.$units[$pow]; + } else { + $table->data[$i][4] = round($value['bps'], 2).' '.$units[$pow]; + } $i++; } @@ -481,7 +497,9 @@ function netflow_get_top_N( string $end_date, array $filter, int $max, - string $connection_name='' + string $connection_name='', + bool $extended_info=false, + int $total_bytes=0 ) { global $nfdump_date_format; @@ -496,7 +514,8 @@ function netflow_get_top_N( return json_decode($data, true); } - $options = '-o "fmt:%sap,%dap,%ibyt,%bps" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $opts = ($extended_info === true) ? 'fmt:%sap,%dap,%ibyt,%obyt,%ipkt,%opkt,%bps' : 'fmt:%sap,%dap,%ibyt,%ipkt,%bps'; + $options = '-o "'.$opts.'" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); $command = netflow_get_command($options, $filter, $start_date, $end_date); @@ -516,8 +535,29 @@ function netflow_get_top_N( $values[$i]['ip_src'] = $parsed_line[0]; $values[$i]['ip_dst'] = $parsed_line[1]; - $values[$i]['bytes'] = $parsed_line[2]; - $values[$i]['bps'] = $parsed_line[3]; + + $traffic = '-'; + if ($total_bytes > 0) { + $conn_bytes = $parsed_line[2]; + + $traffic = sprintf( + '%.2f', + (($conn_bytes / $total_bytes) * 100) + ); + } + + $values[$i]['traffic'] = $traffic; + + if ($extended_info === true) { + $values[$i]['ibytes'] = $parsed_line[2]; + $values[$i]['obytes'] = $parsed_line[3]; + $values[$i]['ipackets'] = $parsed_line[4]; + $values[$i]['opackets'] = $parsed_line[5]; + $values[$i]['bps'] = $parsed_line[6]; + } else { + $values[$i]['bytes'] = $parsed_line[2]; + $values[$i]['bps'] = $parsed_line[3]; + } $i++; } @@ -1341,7 +1381,11 @@ function netflow_draw_item( $output='HTML', $address_resolution=false, $width_content=false, - $height_content=false + $height_content=false, + $extended=false, + $show_graph=true, + $show_summary=true, + $show_table=true ) { $aggregate = $filter['aggregate']; $interval = ($end_date - $start_date); @@ -1496,7 +1540,9 @@ function netflow_draw_item( $end_date, $filter, $max_aggregates, - $connection_name + $connection_name, + $extended, + $data_summary['totalbytes'] ); if (empty($data_top_n) === true) { @@ -1505,16 +1551,61 @@ function netflow_draw_item( if ($output === 'HTML' || $output === 'PDF') { $html = ''; - $html .= ''; - $html .= "'; - $html .= ''; - $html .= ''; - $html .= "'; - $html .= ''; + + if ($show_graph === true && $max_aggregates <= 10) { + $labels = array_map( + function ($conn) { + return __('% Traffic').' '.$conn['ip_src'].' - '.$conn['ip_dst']; + }, + $data_top_n + ); + + $pie_data = array_map( + function ($conn) { + return $conn['traffic']; + }, + $data_top_n + ); + + $graph_output = pie_graph( + $pie_data, + [ + 'legend' => [ + 'display' => true, + 'position' => 'right', + 'align' => 'center', + ], + 'labels' => $labels, + ] + ); + + $html .= ''; + $html .= "'; + $html .= ''; + } + + if ($show_summary === true) { + $html .= ''; + $html .= "'; + $html .= ''; + } + + if ($show_table === true) { + $html .= ''; + $html .= "'; + $html .= ''; + } + $html .= '
"; - $html .= netflow_summary_table($data_summary); - $html .= '
"; - $html .= netflow_top_n_table($data_top_n, $data_summary['totalbytes']); - $html .= '
"; + $html .= $graph_output; + $html .= '
"; + $html .= netflow_summary_table($data_summary); + $html .= '
"; + $html .= netflow_top_n_table( + $data_top_n, + $data_summary['totalbytes'], + $extended + ); + $html .= '
'; return $html; @@ -1638,7 +1729,8 @@ function netflow_get_item_data( string $type_netflow, array $filter, int $max_aggregates, - string $connection_name + string $connection_name, + bool $extended=false ) { $data = []; @@ -1656,7 +1748,9 @@ function netflow_get_item_data( $end_date, $filter, $max_aggregates, - $connection_name + $connection_name, + $extended, + $data_summary['totalbytes'] ); $data = [ diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index bccada9cb8..2b8a0f01ef 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -6981,6 +6981,20 @@ function reporting_netflow( $filter['aggregate'] = 'dstport'; } + $es = json_decode($content['external_source'], true); + + $extended = false; + $show_graph = false; + $show_summary = false; + $show_table = false; + + if (empty($es) === false) { + $extended = ((int) $es['top_n_type'] === 1); + $show_graph = ((int) $es['display_graph'] === 1); + $show_summary = ((int) $es['display_summary'] === 1); + $show_table = ((int) $es['display_data_table'] === 1); + } + switch ($type) { case 'dinamic': case 'static': @@ -6992,7 +7006,14 @@ function reporting_netflow( $filter, $content['top_n_value'], $content['server_name'], - (($pdf === true) ? 'PDF' : 'HTML') + (($pdf === true) ? 'PDF' : 'HTML'), + false, + false, + false, + $extended, + $show_graph, + $show_summary, + $show_table ); break; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 71118e529a..835c964758 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1017,6 +1017,10 @@ select:-internal-list-box { padding-bottom: 5px; } +.padding-bottom-25px { + padding-bottom: 25px; +} + .padding-right-2 { padding-right: 2em; } From f6ee798603d5e4d939a6f6f1555c3dd8f06d1084 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 8 Jan 2024 17:59:23 +0100 Subject: [PATCH 041/233] implement several changes in top-n connection report item --- pandora_console/include/functions_netflow.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index c4d6b4dfe0..51b74c59b0 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -349,8 +349,9 @@ function netflow_top_n_table(array $data, int $total_bytes, bool $show_extended= $table->head[0] = ''.__('Source IP').''; $table->head[1] = ''.__('Destination IP').''; $table->head[2] = ''.__('Bytes').''; - $table->head[3] = ''.__('% Traffic').''; - $table->head[4] = ''.__('Avg. Throughput').''; + $table->head[3] = ''.__('Packets').''; + $table->head[4] = ''.__('% Traffic').''; + $table->head[5] = ''.__('Avg. Throughput').''; $table->style[0] = 'padding: 4px'; } else { $table->head[0] = ''.__('Source IP').''; @@ -378,7 +379,8 @@ function netflow_top_n_table(array $data, int $total_bytes, bool $show_extended= $table->data[$i][6] = $value['traffic'].' %'; } else { $table->data[$i][2] = network_format_bytes($value['bytes']); - $table->data[$i][3] = $value['traffic'].' %'; + $table->data[$i][3] = network_format_bytes($value['ipackages']); + $table->data[$i][4] = $value['traffic'].' %'; } $units = [ @@ -397,7 +399,7 @@ function netflow_top_n_table(array $data, int $total_bytes, bool $show_extended= if ($show_extended === true) { $table->data[$i][7] = round($value['bps'], 2).' '.$units[$pow]; } else { - $table->data[$i][4] = round($value['bps'], 2).' '.$units[$pow]; + $table->data[$i][5] = round($value['bps'], 2).' '.$units[$pow]; } $i++; From 19024e63d304a6d854e1f8f05e324813a813f450 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 8 Jan 2024 18:05:29 +0100 Subject: [PATCH 042/233] implement several changes in top-n connection report item --- pandora_console/include/functions_netflow.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 51b74c59b0..770314f507 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -374,12 +374,12 @@ function netflow_top_n_table(array $data, int $total_bytes, bool $show_extended= if ($show_extended === true) { $table->data[$i][2] = network_format_bytes($value['ibytes']); $table->data[$i][3] = network_format_bytes($value['obytes']); - $table->data[$i][4] = network_format_bytes($value['ipackages']); - $table->data[$i][5] = network_format_bytes($value['opackages']); + $table->data[$i][4] = (empty($value['ipackages']) === true) ? 0 : $value['ipackages']; + $table->data[$i][5] = (empty($value['opackages']) === true) ? 0 : $value['opackages']; $table->data[$i][6] = $value['traffic'].' %'; } else { $table->data[$i][2] = network_format_bytes($value['bytes']); - $table->data[$i][3] = network_format_bytes($value['ipackages']); + $table->data[$i][3] = (empty($value['ipackages']) === true) ? 0 : $value['ipackages']; $table->data[$i][4] = $value['traffic'].' %'; } From 600797d531a2ba9e51db042f17a8fc3055c933fe Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Mon, 8 Jan 2024 14:50:11 -0600 Subject: [PATCH 043/233] Previous installation verification --- pandora_server/pandora_server_installer | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index ca831fb1e5..f77a2c294d 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -191,7 +191,36 @@ install () { esac shift done - + + # Alternative destdir has been selected + if [ ! -z "$DESTDIR" ] + then + # Files from previous installation were found + if [ -d "/usr/lib/perl5/PandoraFMS" ] + then + GREEN='\033[01;32m' + NONE='\033[0m' + + echo -e -n "Files from a previous installation were found in ${GREEN}/usr/lib/perl5/PandoraFMS/${NONE}. " + read -p "That directory will be deleted in order to preserve integrity. Do you wish to proceed? (y/N): " USERAPPROVAL + + if [ "${USERAPPROVAL,,}" = "y" ]; then + rm -rf "/usr/lib/perl5/PandoraFMS" + echo -e "Previous PandoraFMS directory deleted successfully" + else + echo -e -n "Files in ${GREEN}/usr/lib/perl5/PandoraFMS/${NONE} will not be deleted. This may cause issues. " + read -p "Do you want to proceed with the installation anyway? (y/N): " USERAPPROVAL + + if [ "${USERAPPROVAL,,}" = "y" ]; then + echo "Proceeding with the installation anyway. This may cause problems in the future due to the existence of files from previous installations." + else + echo "Installation aborted. You chose not to proceed." + exit 1 + fi + fi + fi + fi + if [ "$LINUX" = YES ] then echo "$DISTRO distribution detected" From e2471f817d41f9a30f453e238627bfa139db54d5 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 9 Jan 2024 14:38:44 +0100 Subject: [PATCH 044/233] #12321 Added widget Gis map --- pandora_console/extras/mr/68.sql | 7 + pandora_console/images/widgets/GisMap.png | Bin 0 -> 9713 bytes .../include/lib/Dashboard/Widgets/GisMap.php | 541 ++++++++++++++++++ .../operation/gis_maps/render_view.php | 18 +- pandora_console/pandoradb_data.sql | 3 +- .../views/dashboard/listWidgets.php | 4 + 6 files changed, 555 insertions(+), 18 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql create mode 100644 pandora_console/images/widgets/GisMap.png create mode 100644 pandora_console/include/lib/Dashboard/Widgets/GisMap.php diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..669eceaecd --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +SET @widget_id = NULL; +SELECT @widget_id := `id` FROM `twidget` WHERE `unique_name` = 'GisMap'; +INSERT IGNORE INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,`page`) VALUES (@widget_id,'GisMap','GisMap','Gis map','','GisMap.php'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/images/widgets/GisMap.png b/pandora_console/images/widgets/GisMap.png new file mode 100644 index 0000000000000000000000000000000000000000..0cbfbf37b6e2c794aa04ac7dae32173dae9ed536 GIT binary patch literal 9713 zcmVAczO!S-4f~A|{oet>r8iym4p-@8;?ZWUKx$U7d}8t4;|Ka zUW|fV0m(mDvAatSwl6M}6X|6aIXW-gE_;{tjm4N*X0*H2D28=SGy#`f(Q-~qDF4na z>>JRAnK33vwxK$B)djL4_wIEB6>$BER1J|oJayH&VG1Y z?>+Ko#J~%d{T3%U9dePC2pCxMdnDq(*+2bcGG&G|6tsegewQXD^f@a5vt6R1iNz|( zN6I3bITLPKvkTvDPZI%vxFXwS$q80Zw+Nw?s3B`x zuy#Uo8K_!VS6s~7j=T)P!GR@eX~C(<^7xkgwK@Y%O6+x1&Oy$<$T5HM#uyq2!o9V=k+fqYIy`VdoCWg!cH+jkhmk#etPHm*ISv}?Z6~uV=!|>h zaE*6c+|;{gk{s)FBJ!t|$dBs`d+mC1Fgs?y_7rkMenP8$1~FWk40wFsFy8`c0Od#@ zO2icOk2~=4PiCV=6CG-uoht@20ts1zp*a-h%77y|&YzKo5+%UvQyvhfD^rLLF^vWz zrp5#`==wgYU4BDE#t7Bs3LY5Lj1MIoKSZ}DO1OEn|t%T;M-xEjH$0xNAZJq^( zK5xc_Ls~pGakDZxzI{0#XAg)&i5y;{F-1;Q0*BFHJ|XvbPB(AGrf`i-h$#UMzn}pp zPPJ4Emu{*Gtux9AZHV9yOj^Nd(K!tki#G4_qjwID-_q3USv5Crw_PfAq^yQ-mAazcW}p?#UEry?@oGF`H5YR9(E z*cBkdOYURq6<++6C70F0*1^bn5wRkB^vOP1g6*iog)Ju#z{(W!!>&2N8 z9A+(Sg(h8Gqi#etjm+srY_#R#;c>3b0|P!fz6JVDGReCPDX~X&8BHMvqjP5B(DJSx z8N4((5n~4ZAf-X`1EDy(!r+m?gST}RGmwE44i8E=Jicph@uz^nD{~ejD}$*bNyp zW8U692KUewDY7dNk!?WpouRb!(cq6RzN3ua?0IH1ocSA?+#KY*|0?br6pPTWKgZ8Q zyWqDSoy3KxR9tQ!HUj;r8K3Hsfb6uiS-a{()NZLoSQQOk8&wsif+J|##DJ`H4RRt~ zYiNc)(%kKq(kpG%OkQ}Y1-hq1q4hxb9G)BQKuVk&+39_D{GDt^n*l~dR`**WVqU7T z7mh&8;KcTDG>E)goa0-K+<_fS+`G)Wt@Y@ZXcjY2&iAWd&sP#5x_v0&g}=0xuQeWE zv=ZtWZyv<=d*g6ymkmw3x~Q~UA-B)Zvn&|;9BtZ*cCJ!x9+^0t_Nu(I;5nQZ5^QoW z3z&TOJ_#Pf#h{#64jx# zpA(UJuZLwU<>26HSj?UdefE|EJ|7g)JnvC0R2HdV6Z3yoFMUG*UEX7(8g1HUTc2pbbr#CNuDERLgp^{ zwZ0abs@Gb9iz|;uZ(sP;mi7*ZT_(yq@wWBfG~K^<=iPR@z1&y*-g$ZZ!y+ON-8*^O zLho>;Ul$XZqFJzLJB=QNs-p)JFsN^rWo235D>E#MyK&>j!jrFl+|eHnJq-D^;q+YR zOTfvyw>~^)<}^s_dS1t~@jf?_;Dfb`!=o18ty?$0UkvA~7o0lxgy~h1f`YvGE?ql$ zg#vb~0IgO_KlKW53U>I3^1;OcE_^x>rxL(H*C#rIt3Nwz0y+=4M;Yzm4mb~JHQM~1 z4;VvksHa6}lm=OJYJK3FrkJsCr3VtplbxA?DU-S)ZkP#Y_d8LunHF{1xU%346Ypmv zb6|r5ntL8cpTW0FK_2$VZcXVpI$RFpv$H@ZAR)Zrnlx^2cNsw&a`l&eK90yrm9cQi zK{0&foMz~FyL)WlUB&)&cHG!)AnG)1f*9IYXL}K`Va*E6pYa@qJs;{pgil5)0Rah7 zfe$L^-071LoB~e$WyiM9ZFu_i579iK2mM^hc?Xt9TdKDoy9;SYcH_2}%`o!fxjr!Y z%_uZJ5{mpBd$GG6WnoH1h-v>`n2x3@@yPD1VPjCMZUcGG@l?~z&}Cf0L$`E5Xh#dR zl6#Td{(hi6%yL@31vJ=P-lz<{c#<0E)KpGLjuI0h-M=W2WMy2&fj@tT&2R!W>AK}u z(*j(nY7+}$$rcb2slk)O!zexs$#ezd&m_m^pwrGsc~g6)p8EDfEq#dy;nVYRW-~VZ z^bMjrT=c+qLo4>WMzMy+%_1RZsUWpaxmtj?H_7q7+jfcdWFB_VEh6o+C(r1I3+bou{gcyRw!5~(62|;a-C>We z3p!sB%?~R+$B~S87JT$U92EULCKGxX!sRPp&tPoRscXgg18xj#pb8Esq7~6Li z_I%^Sl68L};pSM}Iopg;Z@Gr$;V-!7l?avPs>31R=XWi1GDsh7F(nNcZ7sC4xb-Dh z(dxC;W8C|C9Iz(JWvzAAh&t2NjJ>$Ew7MLGMj_aQB_F!~8DTnjH#3Xs#Z|n&s2cooAo%hm*tk z^sQt4ndscJKk{<2asO?dFm{&jkrLl)9@=cf*;Kp7^`19wv4Gd>rb;4)H&=2^d*3Nb zK-aRZg)V!-xSnZTMwt+0fj{_aW7~>2AyMX07Prn2d31b2e3lZ2Dj`aMMT`Clvlz2t z0&Rtr@D<~B5@T53_&smtcPGTK+qbTTIi{ePH3DqtrN6$blRXb*AJA?MvcieG@d}rbhd2!)tcOc3%-tmEM%d~=( zR;d+aybB^_<1bu__h$=Er|*Wo2$=790ur))`!@Ky=+W!_cYY_Y)b;XQ>#uBLIA8Mc zLP@Xl#b>wMpf|ekkh5hVL;(q@-AV@~;|wEO{762Xv=a}JA0x5-t3`XCxO_de5cfa! z0tO5p;{$&8;CPID!#$oZnq+aEqxwL)0s<0}pCO2xLd;IgY~9PBD!`X?V(8B>H{A$2 z{yg-X4QKW{h_lXpWuQD|ueHI9HNRW1c&+PF$Q$3+pU=Zh_wbpo`qiE{Jo^KVS`F*= zK=;N=U_SX2&aNGd*^4&8M5pm;=BJg55Pwr2#D>0yCnhGtTc}3je>O5{#0{S1P;3WF4_0X_sh`ZUe9kn8)4RMI#vBZJIhIk$W|LwjEQo;ms2PPy?$^da6&3qYm&2t}6FMFZ@(a0H=$V%Ez&kdVcCYg zVxg7SJiq?967%1fiuS{d81)Vl==x;62Lv%;5dTU|i2m#;grxojO@RfrnzdnR--UXd ztIIt#eV&+gO41HIHTfpF7|FkH#aqu$LU=U?dX3kM(ok|FIg|qeUu7R^8T@&2i3yeiVfl+Ut>ZK|pkK9j?$s*?WR#O<3usI_X<0LLxL& zS<2M@-9eRT&GOIC?@>CxY-B}zM1%)6z9YBh3n-+Ym6ml^@|{@uLm@^?GpVvVbsl9# z?dxV+(Em}tD|opqo*3m|Pe4x;2N)S#T*8Dq{RC#p5_9eVpeW)_(aGR`_g zVmb^r;?my^RIRV0)(XMzD~i8q2&#|NYt&3+l8LJ|6R*y=gf&O1W7PeRqTP+%5gt`Z zB*GaM<{=2Va_eCqiNA=dTI6Rs@%LT__Iz)};zx63c6Y9MsYRH8JldT*=+;_K_s#Jm zOw6?xu+jrYaxE?l#&@AuxwaO+ zyl0`7kRUYyzpsFVB>%BhmfaZnx`~>5A+{V{AYqp6HE&qtmXZU>!5nqpY&{|e9o(S9 zKPPBNDl$Ac-~6DNYTi9eOL4{!4F>$n-N|W(=#=8r?0|%jaD+!1mhTCx;trEUY`feT z598teu*UediV^{SZqDil>yN8CZ7;<`P(H@GW>n)5OJ@n z7l8+c{p*5Tt}s81I+miW(hm}cr60q*CrZQ1k=6qYVxQV`ZZckbHUT$3;OfLIV>s$9 zGimwIBd^ZeB(@xj^wTHNwa;Mu{%JL2q^p1a+~Ii$&i+TB!w;=zhKkG`8f{)cLUcM~ z8uR+98D^m2jSpQyBdfAq=8$7p7FQoJ&2!ly;V_srqIL+nxfO%vEM1TNUpK(T6YirQ z3ATQm9veTfAp8amjK&aO9;qTgU2f)i&75WHqIFJvEh(|L{r;KFdhqc#-cds-Gu4!rOp;nA6&>b;aOsh8 zef}0dEtYbx=nN|gKNG>YMM54(xakVB3{_NS6@{0jdL-O(XJ@`AR&OFjTIr9=MDEpaG*w zO-Mkj#YA!?=rbZh1%urr*qkQlNXeL8FzGZp_4Rx)_{thBR;HddZVpYM#-J_K*z|?= z$~pPv#obqu@>NKKaCf>~aHf(|V~o`5wGsYQ!j+_;*8(heU8midL$~4CH<;^WstIwI zwVY*c5atTb)m^MX3;s&~SO4^8`WrgUoP8wF|{f62;|G;s#;ePkKA*RFq1f z;tG7d#4~%JU5_*VmLdM=2&zGN5h*yc8(hmw|NaQP7Q%UvtI?uPeFG86OxoWq zne#~2m5ZZ@^IK@vtQl(7tSKLp1xkCp$DKca-g)H65oU$fL{+J_{I+qE=PFhBmV`c5 z4mNpA|MX%dbORy%=-p?Zv|4iSSiO3+u2Ca8EBb$Ijvqgcp+ko{j3MD)`@1VBu6lHl zk*QiowxwoqfNJrg{6%&~0*fzjV=#X?YvKR##~(%T3l}cni!Z*wh7B7;|LN1G@%iVU zW81cEYUr-}Fs=ixi#)0muA9;j#BD*s_|7ngJd*^EhJ|5Bv#K^H$HkuKBt@De(SQhI zw2>5Rv!4~CvfpSlit*K}S1+?rK=7r!`jA{FNqdr;mnLU!3w>GSgO!1~2f&~?rw^J#wAce_^6b>maSa?O!>&D4#p)YM|3k&kwrlzK1%9JT3 zM$x);YnV*FtTTZSvFHs?pjX4xu3a0^(a`}v7}oZcoSZDeD9glk!gZqzD~Y?*4MJb4 zEhIV<4Mrsun;+{9`R$Ve3>kGV?tOG>vGCpi^QJ$8&Fj9y;3;O2`_ntVw0^5az#l8E zIJ(1z)*Wudq-STKdM&@ga&k6%c5KG$QyxUektVe4ODqx!bM!KCp=M}^L8El0)D03$ zc9%{%iCL@=t>SLN*IPb-&H0F3mFn`SPY6bXi zYYvY6VI!uwu9))lbX0pg+8b2W&qM4>kKT#n$Nt15+|3zNp8)c`#bh{>;_jAzM9 zkPGPtJlry_WA*3W{;&k8f&=9R!Yl7D_5o(TyZcFNdFRna)yCii68jrB0)H@>=N+ii zpfP&h+zX}vtE7- zHDmOM>FzmhOIdTTT(m0_@#n)(uTfL<>T@%UULtus$mDhGCMEH(^Ye1?3#qSP^VKKF zq@{ZOb_TTSuSf4GJk+`wHa!xRv*)^L5ElRAA*|CK%t}sYK1IVf3l!}5l4MK{+0c8? z2s}RPd4z>WKzHdMXpbI*z%Lt+agbt>DOT>F?mF1QEZEm}DGpuw5?j7>qVYj9 zqAnXzkV7{KJfV=O-%jtAdAy)Q6>HhPUgq(SJrL$s;FI?>$C?H1>E3h&F3H&_1xif?q}TOW2#zpmQ`SJN$IgB2_Fl#o{P4YNEv7_4I#l)XoDEepOx~#$+T4bzGXd{_b|X* zU4sZ(?6~b&99dmM)`=6Oi%?mDx^X9fyU*Z&cP@WZL51jRYccqgw&KI z)T3b~80juGT5UyY`#G+pU+?<47LulMqTOJlDC8Jcx%8VmeyZtL(zx%ivz}}LL#Kw2 zlw9fYdDB|14Z`F3Gvi0%;^jm1%xyTTk;1`-X}J&_DQHGVDkYI$_b%v}y1p`#!F;_e zb;_c!V`sXgOKDm|da46yJ8g(6dd;hVq)|`)X{Sw~fes6e@*YQ725tbBsjSmdFUvsM z3Iu%fVm=1_I|Pw6%BNAvtwC5(@R;wP{H%EN%}3z=jE3nif21(TN(W%1<=vI;7?JXk{#T|2O+j#jk6+XG$NENv6!XAuYIt@lTt<{`6 z1KYXN;+u-B%7%?#4uQQ=71(Okg`Mvt_){k1t}4+h{^QqG`1jUxkKm`bHe%3I?nb$A zl%9#9N~+qxmA-Zhsz^F2XYo-!nP#bemX_wBhhg}u-@C>to+h)T=f&d=@m)IUg%@|O zE*Gce#@+gP0dAq8N-`|Y&AQ+D_1)qGhov-XcA0w!_lD=`SUR?s9$TNBgHtIs#NF5p z57FBSHRuTfKDq5XBtiU11>onNy`OxR;!0xo954*Kp8W-x=?3in#)k7poS5*`Ye?C> z9UB+?LZ`DPasFVOk+iboFWK9eNaa0?nfntp_l9RbcUTrdKYzp_o~ub=yd`oys;-tQ zxG{-?@mWX~Ec6+}&0x0IzCzY!5WPGpuscl};}s96apA-Oo;!&;(`IYuFV0^EMAW z@glnR9W09Z^Rc?Rq2X%RZ-}RtOIUJAO}-;QQ03u< zP##P0;)9trURXQ`PVFDEiA<7-mU0~8Lx!J zcv*iCtHwz`M9-BDHKEB(dQqp)DSDoRFU3gKu!I=h8IlHlhcnPyZf?->bFsQLr3yAy zLE<_pA$@YWzws05IJ;;bmStt5d;eh=I{IF^aBAjJfL)t^5hwN9ElI0QrWRMuy7&qj z#l+HGc~6?hx+A7_doVkaKa;X&hZyBg%ZI;ohqu~E)07hlq&bI`Y_j2Du_2u(?_ERB zBVQDXLS1pe{^z#PlN?}y29Dr42#T=NWL-$Qigs8=?4W; zeB+wSsuOF^@G%cz;D~WzmMzJr^c2p6Pf?4z z{Ndep(W=F$ zMorVM`f{1rqykoyy+4;sPgW_*dTqH48L`p!Q){^Nk?!M~{~OjkYlep-;=wo{=z%uR6rR3PH;5-1@NtL!#6?}@0@&$N<3GfQ z>0PLb_LI77GxS#)R&!(o+XIR#Qn@vVzl?Yu`gHa7@cjJzh!CA2)b13*u9u}XFG=-U zO`gSJ%MT3=&AD%A*W5tkzrQ*tNqB`fNJ$FAjW=iQS|hFyuctBGWPr^`%3}2n&3)z_EZwuf`$D*W!VqpFP2ZE00000NkvXXu0mjfpGLkK literal 0 HcmV?d00001 diff --git a/pandora_console/include/lib/Dashboard/Widgets/GisMap.php b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php new file mode 100644 index 0000000000..3cb967cf8c --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php @@ -0,0 +1,541 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Cell Id. + $this->cellId = $cellId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Gis map'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'GisMap'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (empty($this->values['gis_map']) === true) { + $this->configurationRequired = true; + } + } + + + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['gis_map']) === true) { + $values['gis_map'] = $decoder['gis_map']; + } + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + if ((bool) $config['activate_gis'] === true) { + $maps = gis_get_maps(); + } + + $array_map = []; + foreach ($maps as $map) { + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + continue; + } + + $array_map[$map['id_tgis_map']] = $map['map_name']; + } + + // Filters. + $inputs[] = [ + 'class' => 'flex flex-row', + 'label' => __('GIS maps'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $array_map, + 'name' => 'gis_map', + 'return' => true, + 'selected' => ($this->values['gis_map'] === null) ? 0 : $this->values['gis_map'], + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost(): array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['gis_map'] = \get_parameter('gis_map', 0); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + include_once $config['homedir'].'/include/functions_agents.php'; + + \ui_require_javascript_file('openlayers.pandora', 'include/javascript/', true); + \ui_require_javascript_file('OpenLayers/OpenLayers', 'include/javascript/', true); + + $map = db_get_row('tgis_map', 'id_tgis_map', $this->values['gis_map']); + + $output = ''; + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + $output .= '
'; + $output .= ui_print_error_message( + __('You don\'t have access'), + '', + true + ); + $output .= '
'; + return $output; + } + + $confMap = gis_get_map_conf($this->values['gis_map']); + + // Default open map (used to overwrite unlicensed google map view). + $confMapDefault = get_good_con(); + $confMapDefaultFull = json_decode($confMapDefault['conection_data'], true); + $confMapUrlDefault = $confMapDefaultFull['url']; + + $num_baselayer = 0; + // Initialy there is no Gmap base layer. + $gmap_layer = false; + if ($confMap !== false) { + foreach ($confMap as $mapC) { + $baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type']; + $baselayers[$num_baselayer]['name'] = $mapC['conection_name']; + $baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels']; + $decodeJSON = json_decode($mapC['conection_data'], true); + + switch ($mapC['connection_type']) { + case 'OSM': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + break; + + case 'Gmap': + if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) { + // If there is not gmap_key, show the default view. + $baselayers[$num_baselayer]['url'] = $confMapUrlDefault; + $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM'; + } else { + $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; + $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; + $gmap_key = $decodeJSON['gmap_key']; + // Once a Gmap base layer is found we mark it to import the API. + $gmap_layer = true; + } + break; + + case 'Static_Image': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left']; + $baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right']; + $baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom']; + $baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top']; + $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; + $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; + break; + + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; + + default: + // Do nothing. + break; + } + + $num_baselayer++; + if ($mapC['default_map_connection'] == 1) { + $numZoomLevels = $mapC['num_zoom_levels']; + } + } + } + + if ($gmap_layer === true) { + if (https_is_running()) { + ?> + + + + values['gis_map']); + + $output .= '
'; + gis_print_map( + 'map_'.$this->cellId, + $map['zoom_level'], + $map['initial_latitude'], + $map['initial_longitude'], + $baselayers, + $controls + ); + $output .= '
'; + + if (empty($layers) === false) { + foreach ($layers as $layer) { + gis_make_layer( + $layer['layer_name'], + $layer['view_layer'], + null, + $layer['id_tmap_layer'] + ); + + // Calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB. + $agentNamesByGroup = []; + if ($layer['tgrupo_id_grupo'] >= 0) { + $agentNamesByGroup = agents_get_group_agents( + $layer['tgrupo_id_grupo'], + false, + 'none', + true, + true, + false + ); + } + + $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']); + + $groupsByAgentId = gis_get_groups_layer_by_agent_id($layer['id_tmap_layer']); + $agentNamesOfGroupItems = []; + foreach ($groupsByAgentId as $agentId => $groupInfo) { + $agentNamesOfGroupItems[$agentId] = $groupInfo['agent_name']; + } + + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer + $agentNamesOfGroupItems); + + foreach ($agentNames as $key => $agentName) { + $idAgent = $key; + $coords = gis_get_data_last_position_agent($idAgent); + + if ($coords === false) { + $coords['stored_latitude'] = $map['default_latitude']; + $coords['stored_longitude'] = $map['default_longitude']; + } else { + if ($show_history == 'y') { + $lastPosition = [ + 'longitude' => $coords['stored_longitude'], + 'latitude' => $coords['stored_latitude'], + ]; + gis_add_path($layer['layer_name'], $idAgent, $lastPosition); + } + } + + $status = agents_get_status($idAgent, true); + $icon = gis_get_agent_icon_map($idAgent, true, $status); + $icon_size = getimagesize($icon); + $icon_width = $icon_size[0]; + $icon_height = $icon_size[1]; + + // Is a group item. + if (empty($groupsByAgentId[$idAgent]) === false) { + $groupId = (int) $groupsByAgentId[$idAgent]['id']; + $groupName = $groupsByAgentId[$idAgent]['name']; + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($groupName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_group_info', + $groupId + ); + } else { + $parent = db_get_value('id_parent', 'tagente', 'id_agente', $idAgent); + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($agentName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_agent_info', + $parent + ); + } + } + } + + gis_add_parent_lines(); + + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); + + gis_activate_select_control(); + gis_activate_ajax_refresh($layers, $timestampLastOperation); + } + + return $output; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('GIS map'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'GisMap'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 500, + 'height' => 300, + ]; + + return $size; + } + + +} diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index e6cfaaee99..d826095a50 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -304,23 +304,7 @@ if ($layers != false) { gis_add_parent_lines(); - switch ($config['dbtype']) { - case 'mysql': - $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); - break; - - case 'postgresql': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))" - ); - break; - - case 'oracle': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) FROM dual' - ); - break; - } + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); gis_activate_select_control(); gis_activate_ajax_refresh($layers, $timestampLastOperation); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index a7df8d9764..25b7cc781d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2832,7 +2832,8 @@ INSERT INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,` (44,'WuxWidget','wux_transaction','Agent WUX transaction','','wux_transaction.php'), (45,'WuxStatsWidget','wux_transaction_stats','WUX transaction stats','','wux_transaction_stats.php'), (46,'SecurityHardening','security_hardening','Security Hardening','','security_hardening.php'), - (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'); + (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'), + (48,'GisMap','GisMap','Gis map','','GisMap.php'); INSERT INTO `tmap` (`id`,`id_group`,`id_user`,`type`,`subtype`,`name`,`description`,`height`,`width`,`center_x`,`center_y`,`background`,`background_options`,`source_period`,`source`,`source_data`,`generation_method`,`generated`,`filter`,`id_group_map`,`refresh_time`) VALUES (1,'0','admin',0,0,'Sample dynamic map','This is a sample dynamic map.',900,900,0,0,'',0,60,0,'0',6,0,'{\"dont_show_subgroups\":0,\"node_radius\":40,\"x_offs\":\"0\",\"y_offs\":\"0\",\"z_dash\":\"1\",\"node_sep\":\"0.25\",\"rank_sep\":\"0.5\",\"mindist\":\"1\",\"kval\":\"0.3\"}',0,300); INSERT INTO `treport` (`id_report`,`id_user`,`name`,`description`,`private`,`id_group`,`custom_logo`,`header`,`first_page`,`footer`,`custom_font`,`id_template`,`id_group_edit`,`metaconsole`,`non_interactive`,`hidden`,`orientation`,`cover_page_render`,`index_render`) VALUES (1,'admin','Sample report #1','This is a sample report, just to show you some general report items.',0,0,NULL,NULL,'<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="http://localhost/pandora_console//images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>',NULL,'Lato-Regular.ttf',0,0,0,0,0,'vertical',1,1); diff --git a/pandora_console/views/dashboard/listWidgets.php b/pandora_console/views/dashboard/listWidgets.php index 01767c1f9c..2c4272ddeb 100644 --- a/pandora_console/views/dashboard/listWidgets.php +++ b/pandora_console/views/dashboard/listWidgets.php @@ -71,6 +71,10 @@ foreach ($widgets as $widget) { continue; } + if ($widget['unique_name'] === 'GisMap' && (bool) $config['activate_gis'] === false) { + continue; + } + $imageWidget = '/images/widgets/'.$widget['unique_name'].'.png'; $output .= '
'; From 678972bc587a9938cf7931b938ee7545125db77b Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 9 Jan 2024 16:01:00 -0600 Subject: [PATCH 045/233] Add monitoring types --- pandora_agents/unix/pandora_agent | 59 ++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 65e217abf7..c56ccf33aa 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -3889,7 +3889,8 @@ sub module_logger ($) { my $status = grep_logs( $module->{'name'}, $module->{'params'}, - $module->{'filter'} + $module->{'filter'}, + $module->{'type'} ); return $status; @@ -3926,20 +3927,25 @@ my $encode_sub = defined(&MIME::Base64::encode_base64) ? \&MIME::Base64::encode_ }; sub grep_logs { - my ($str_name, $str_file, $str_regex) = @_; + my ($module_name, $log_file, $reg_exp, $module_type) = @_; - if(!$str_name){ + if(!$module_name){ log_message("module_logger", "Missing module name"); return; } - if(!$str_file){ + if(!$log_file){ log_message("module_logger", "Missing file name"); return; } - if(!$str_regex){ - $str_regex = '.*'; + if(!$module_type){ + log_message("module_logger", "Missing module type"); + return; + } + + if(!$reg_exp){ + $reg_exp = '.*'; } my $idx_dir = '/tmp/'; @@ -3947,9 +3953,6 @@ sub grep_logs { my $idx_pos = 0; my $idx_size = 0; my $idx_ino = ''; - my $module_name = $str_name; - my $log_file = $str_file; - my $reg_exp = $str_regex; # Check that log file exists if (! -e $log_file) { @@ -3975,7 +3978,7 @@ sub grep_logs { return if load_idx(\$idx_pos, \$idx_ino, \$idx_file, \$idx_size) == 1; my @data = parse_log(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$module_name, \$reg_exp, \$idx_size); - my $output = create_log($module_name, @data); + my $output = create_log($module_name, $module_type, @data); return $output; } @@ -4090,19 +4093,26 @@ sub grep_logs { } sub create_log { - my ($module_name, @data) = @_; + my ($module_name, $module_type, @data) = @_; # No data - if ($#data < 0) { + if ($#data < 0 && $module_type ne "generic_proc") { return; } # Log module my $output = "\n"; - $output .= "\n"; - $output .= "base64\n"; - $output .= "\n"; + $output .= " \n"; + + my $data_content = process_log_monitoring($module_type, @data); + + if($module_type eq "log"){ + $output .= " base64\n"; + } + + $output .= " \n"; $output .= "\n"; @@ -4111,6 +4121,23 @@ sub grep_logs { } +sub process_log_monitoring { + my ($module_type, @data) = @_; + my $output = ""; + + if ($module_type eq "log"){ + $output = &$encode_sub(join('', @data), ''); + } elsif ($module_type eq "generic_data") { + $output = scalar @data; + } elsif ($module_type eq "generic_proc"){ + $output = scalar @data > 0 ? 1 : 0; + } elsif ($module_type eq "generic_data_string" || $module_type eq "async_string"){ + $output = join('', @data); + } + + return $output; +} + ################################################################################ # TERM Handler ################################################################################ From 5cf9d70c6f57ccc00ef383e5b36a00de3be7d2cd Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 11 Jan 2024 09:58:06 -0600 Subject: [PATCH 046/233] Add config token for mail_subject_encoding --- pandora_server/conf/pandora_server.conf.new | 2 ++ pandora_server/lib/PandoraFMS/Config.pm | 5 +++++ pandora_server/lib/PandoraFMS/Tools.pm | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index bddb11a293..1945cbd08f 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -816,3 +816,5 @@ madeserver_autofit 7d # Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). madeserver_sensitivity 0.1 +# Encoding to use on mail subject (MIME-Header by default) +# mail_subject_encoding MIME-Header-ISO_2022_JP \ No newline at end of file diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 4f45c28b19..4b7a6c142a 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -589,6 +589,8 @@ sub pandora_load_config { $pa_config->{"madeserver"} = 0; # 774. + $pa_config->{"mail_subject_encoding"} = 'MIME-Header'; # 776. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -691,6 +693,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^mail_in_separate\s+([0-9]*)/i) { $pa_config->{'mail_in_separate'}= clean_blank($1); } + elsif ($parametro =~ m/^mail_subject_encoding\s(.*)/i) { + $pa_config->{'mail_subject_encoding'}= clean_blank($1); + } elsif ($parametro =~ m/^snmp_logfile\s(.*)/i) { $pa_config->{'snmp_logfile'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 580344542c..543ea45556 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -748,6 +748,7 @@ sub pandora_sendmail { my $subject = $_[2]; my $message = $_[3]; my $content_type = $_[4]; + my $encoding = $pa_config->{"mail_subject_encoding"} || 'MIME-Header'; $subject = decode_entities ($subject); @@ -758,7 +759,7 @@ sub pandora_sendmail { my %mail = ( To => $to_address, Message => $message, - Subject => encode('MIME-Header', $subject), + Subject => encode($encoding, $subject), 'X-Mailer' => $pa_config->{"rb_product_name"}, Smtp => $pa_config->{"mta_address"}, Port => $pa_config->{"mta_port"}, From c8a73f59f5026e5ab89f10296e2961108e64fce0 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 16 Jan 2024 11:53:11 +0100 Subject: [PATCH 047/233] #12569 added audit in discovery and task console --- pandora_console/include/constants.php | 1 + pandora_console/include/functions_cron_task.php | 8 ++++++++ pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 1 + 3 files changed, 10 insertions(+) diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index b2ce8d88b4..d68bba9c22 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -819,6 +819,7 @@ define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management'); define('AUDIT_LOG_UMC', 'Warp Manager'); define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation'); define('AUDIT_LOG_ENTERPRISE_VIOLATION', 'Enterprise Violation'); +define('AUDIT_LOG_CRON_TASK', 'Cron task'); // MIMEs. define( diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 40a6e159cc..c00fd441d8 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -419,6 +419,14 @@ function cron_task_run( WHERE id=".$id_user_task; } + db_pandora_audit( + AUDIT_LOG_CRON_TASK, + 'Executed cron task: '.$task['name'].' #'.$task['id'], + false, + false, + '' + ); + db_process_sql($sql); db_process_sql($sql2); } diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 6c2927f2a6..2df6dd31d0 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -524,6 +524,7 @@ sub exec_recon_app ($$$) { logger($pa_config, 'Invalid summary for recon app ID ' . $task->{'id_app'}, 10); } else { db_do($dbh, "UPDATE trecon_task SET summary=? WHERE id_rt=?", $summary_json, $task->{'id_rt'}); + pandora_audit ($pa_config, 'Discovery task' . ' Executed task '.$task->{'name'}.'#'.$task->{'id_app'}, 'SYSTEM', 'Discovery task', $dbh); } update_recon_task($dbh, $task->{'id_rt'}, $status); From d3ca5862b41a17bb09c1acfec48e12887ffead36 Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 17 Jan 2024 11:01:25 +0100 Subject: [PATCH 048/233] #12222 Fix timezone offset when modules has timezone data --- pandora_server/lib/PandoraFMS/DataServer.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 80e8bb4bd3..7dfee63af3 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -627,6 +627,11 @@ sub process_xml_data ($$$$$) { my $module_type = get_tag_value ($module_data, 'type', 'generic_data'); + # Apply timezone offset to module if timestamp is set. + if (defined($module_data->{'timestamp'} && $module_data->{'timestamp'} ne '')) { + $module_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime($module_data->{'timestamp'} + ($timezone_offset * 3600))); + } + # Single data if (! defined ($module_data->{'datalist'})) { my $data_timestamp = get_tag_value ($module_data, 'timestamp', $timestamp); From 6e820ab58c2cb759aeaca68259aab6b10912ddcd Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 17 Jan 2024 12:07:33 +0100 Subject: [PATCH 049/233] #12364 Added filter css --- pandora_console/include/styles/pandora.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..ce3d14c10a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -767,6 +767,10 @@ select:-internal-list-box { width: 80%; } +.w85p { + width: 85%; +} + .w88p { width: 88%; } From bb2d908de724b4af9cdd3c9864b13d24e37d8727 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 17 Jan 2024 12:25:57 +0100 Subject: [PATCH 050/233] #12460 fixed deprecated log --- .../godmode/wizards/Applications.class.php | 14 ++++++++++++++ pandora_console/godmode/wizards/Custom.class.php | 14 ++++++++++++++ .../godmode/wizards/DiscoveryTaskList.class.php | 7 +++++++ pandora_console/godmode/wizards/Wizard.main.php | 2 +- pandora_console/include/api.php | 4 +++- pandora_console/include/auth/mysql.php | 2 +- pandora_console/include/functions_events.php | 3 ++- pandora_console/include/functions_ui.php | 6 +----- .../lib/TacticalView/elements/SnmpTraps.php | 12 ++++++++++-- pandora_console/operation/events/events.php | 6 +++--- 10 files changed, 56 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/wizards/Applications.class.php b/pandora_console/godmode/wizards/Applications.class.php index 7458aea872..29fee2e73a 100644 --- a/pandora_console/godmode/wizards/Applications.class.php +++ b/pandora_console/godmode/wizards/Applications.class.php @@ -37,6 +37,20 @@ class Applications extends Wizard */ public $mode; + /** + * Task properties. + * + * @var array + */ + public $task; + + /** + * Class of styles. + * + * @var string + */ + public $class; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/Custom.class.php b/pandora_console/godmode/wizards/Custom.class.php index 41a177b3e3..9ddec3d9af 100644 --- a/pandora_console/godmode/wizards/Custom.class.php +++ b/pandora_console/godmode/wizards/Custom.class.php @@ -37,6 +37,20 @@ class Custom extends Wizard */ public $mode; + /** + * Task properties. + * + * @var array + */ + public $task; + + /** + * Class of styles. + * + * @var string + */ + public $class; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e831022c23..3a7628d8b9 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -47,6 +47,13 @@ ui_require_javascript_file('simTree'); class DiscoveryTaskList extends HTML { + /** + * Task properties. + * + * @var array + */ + public $task; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index a286b97fca..06276cb187 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -517,7 +517,7 @@ class Wizard public static function printBigButtonsList($list_data) { echo '
    '; - array_map('self::printBigButtonElement', $list_data); + array_map(['Wizard', 'printBigButtonElement'], $list_data); echo '
'; } diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index b29dd06bd3..4836f98c64 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -380,5 +380,7 @@ if (session_status() !== PHP_SESSION_DISABLED) { // Could give a warning if no session file is created. Ignore. @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), '/'); + } } diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 76a6458f32..0a132829bf 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -575,7 +575,7 @@ function get_user_info($user) function get_users($order='fullname', $filter=false, $fields=false) { if (is_array($order) === true) { - $filter['order'] = $order['field'].' '.$order['order']; + $filter['order'] = (string) $order['field'].' '.(string) $order['order']; } else { if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') { $order = 'fullname'; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..1f7a839e31 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6471,7 +6471,8 @@ function event_print_graph( ]; $color[] = '#82b92f'; } - } else { + } else if ((int) $num_intervals > 0) { + // We assume that if num_interval is 0, not exist events. $interval_length = (int) ($period / $num_intervals); $intervals = []; $intervals[0] = $start_utimestamp; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 4a0db88991..cbfe60d7db 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -147,11 +147,7 @@ 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)) { + if (isset($text_html_decoded) === true && 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/SnmpTraps.php b/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php index f606893429..9e1de4d891 100644 --- a/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php +++ b/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php @@ -83,7 +83,11 @@ class SnmpTraps extends Element { if ($this->isEnabled() === true) { $value = $this->valueMonitoring('snmp_trap_queue'); - $total = round($value[0]['data']); + if (isset($value[0]['data']) === true) { + $total = round($value[0]['data']); + } else { + $total = __('N/A'); + } } else { $total = __('N/A'); } @@ -109,7 +113,11 @@ class SnmpTraps extends Element { if ($this->isEnabled() === true) { $value = $this->valueMonitoring('total_trap'); - $total = round($value[0]['data']); + if (isset($value[0]['data']) === true) { + $total = round($value[0]['data']); + } else { + $total = __('N/A'); + } } else { $total = __('N/A'); } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c924794d6d..976012720a 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 (isset($tmp->server_name) === true && strlen($tmp->server_name) >= 10) { $tmp->server_name = ui_print_truncate_text( $tmp->server_name, 10, @@ -1216,7 +1216,7 @@ if (is_ajax() === true) { if (empty($tmp) === false && $regex !== '') { $regex_validation = false; foreach (json_decode(json_encode($tmp), true) as $key => $field) { - if (preg_match('/'.$regex.'/', $field)) { + if (isset($field) === true && preg_match('/'.$regex.'/', $field)) { $regex_validation = true; } } @@ -1234,7 +1234,7 @@ if (is_ajax() === true) { $data = array_values( array_filter( - $data, + ((is_array($data) === true) ? $data : []), function ($item) { return (bool) (array) $item; } From 209b4b3e8bbb2ec6c0dc7711395fa8b58b5f8298 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 17 Jan 2024 12:41:56 +0100 Subject: [PATCH 051/233] #12460 fixed deprecated in library phpchartjs --- .../vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php | 2 +- .../vendor/artica/phpchartjs/src/Options/Elements.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php b/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php index abf59aa9f6..c689aae0ac 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php @@ -15,7 +15,7 @@ trait JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize():mixed { return array_map(function ($value) { if ($value instanceof JsonSerializableInterface) { diff --git a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php index b63513bc23..4350718958 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php @@ -148,7 +148,7 @@ class Elements implements ArraySerializableInterface, JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize():mixed { return $this->getArrayCopy(); } From 0efe0041227b49766b1ba4da0d47397d8110b303 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 17 Jan 2024 13:29:21 +0100 Subject: [PATCH 052/233] #12767 Fixed password --- pandora_console/include/styles/pandora.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..7c188058f3 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12076,6 +12076,10 @@ div.relative > div > div#ui-datepicker-div { width: 400px; } +.container-div-input-password { + display: inline !important; +} + #message_dialog_connection { height: auto !important; } From 0ceb5787170bf28d951d7b161ccb966d1353bdb5 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 17 Jan 2024 16:48:38 +0100 Subject: [PATCH 053/233] #12522 fixed audit log in setup --- pandora_console/include/functions_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 9eb19be28d..9f4c38aa68 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -117,7 +117,7 @@ function config_update_value($token, $value, $noticed=false, $password=false) return true; } else { // Something in setup changes. - if ($noticed === false) { + if ($noticed === true) { db_pandora_audit( AUDIT_LOG_SETUP, 'Setup has changed', From ae3c9bc2f52fbe496a5c2ebf98fe0904f49af7ed Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 18 Jan 2024 10:28:57 +0100 Subject: [PATCH 054/233] #12754 Fixed status --- pandora_console/include/ajax/module.php | 29 ++++++++++++++----- .../lib/Dashboard/Widgets/ModulesByStatus.php | 14 ++++++++- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index bddf72a217..2a9580a000 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1900,12 +1900,24 @@ if (check_login()) { unset($expl[$exist]); } - array_push($expl, '1', '2'); + array_push($expl, '1', '2', '3', '4', '5'); $status = implode(',', $expl); } - if (empty($status) === false) { + if (str_contains($status, '5') === true) { + $expl = explode(',', $status); + $exist = array_search('5', $expl); + if (isset($exist) === true) { + unset($expl[$exist]); + } + + array_push($expl, '4', '5'); + + $status = implode(',', $expl); + } + + if (empty($status) === false || $status === '0') { $where .= sprintf( ' AND tagente_estado.estado IN (%s) AND tagente_modulo.delete_pending = 0', @@ -2148,24 +2160,25 @@ if (check_login()) { ); switch ((int) $row['estado']) { - case 0: + case AGENT_MODULE_STATUS_NORMAL: $status_img = ui_print_status_image(STATUS_MODULE_OK, __('Normal'), true); break; - case 1: - case 6: + case AGENT_MODULE_STATUS_CRITICAL_BAD: + case AGENT_MODULE_STATUS_NOT_NORMAL: $status_img = ui_print_status_image(STATUS_MODULE_CRITICAL, __('Critical'), true); break; - case 2: + case AGENT_MODULE_STATUS_WARNING: $status_img = ui_print_status_image(STATUS_MODULE_WARNING, __('Warning'), true); break; - case 3: + case AGENT_MODULE_STATUS_UNKNOWN: $status_img = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('Unknown'), true); break; - case 5: + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: $status_img = ui_print_status_image(STATUS_MODULE_NO_DATA, __('Not init'), true); break; diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index e490135734..866c14494a 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -523,7 +523,19 @@ class ModulesByStatus extends Widget unset($expl[$exist]); } - array_push($expl, '1', '2'); + array_push($expl, '1', '2', '3', '4', '5'); + + $status = implode(',', $expl); + } + + if (str_contains($status, '5') === true) { + $expl = explode(',', $status); + $exist = array_search('5', $expl); + if (isset($exist) === true) { + unset($expl[$exist]); + } + + array_push($expl, '4', '5'); $status = implode(',', $expl); } From f3f3c4728bdf4e2fb69b1cd2dbeaadb622adab67 Mon Sep 17 00:00:00 2001 From: Calvo Date: Thu, 18 Jan 2024 10:49:07 +0100 Subject: [PATCH 055/233] #11642. Fix missing sql in MR --- pandora_console/extras/mr/68.sql | 13 +++++++++++++ 1 file changed, 13 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..6ca548b1c9 --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,13 @@ +START TRANSACTION; + +ALTER TABLE `tevent_sound` MODIFY COLUMN `name` text NULL; +ALTER TABLE `tevent_sound` MODIFY COLUMN `sound` text NULL; +ALTER TABLE `treport_content` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1; +ALTER TABLE `treport_content_template` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1; +ALTER TABLE `tsesion_filter` MODIFY COLUMN `id_name` text NULL; +ALTER TABLE `tsesion_filter` MODIFY COLUMN `period` text NULL; +ALTER TABLE `tsesion_filter` MODIFY COLUMN `ip` text NULL; +ALTER TABLE `tsesion_filter` MODIFY COLUMN `type` text NULL; +ALTER TABLE `tsesion_filter` MODIFY COLUMN `user` text NULL; + +COMMIT; From a41d2214e6343e6d44081e35213b724356be689e Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 19 Jan 2024 09:33:53 +0100 Subject: [PATCH 056/233] #12767 Fixed password 2 --- pandora_console/include/styles/pandora.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c188058f3..526a6b73f8 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11843,7 +11843,7 @@ p.trademark-copyright { } .show-hide-pass { - position: fixed; + position: absolute; border: 0; outline: none; margin-left: -50px; @@ -12077,7 +12077,7 @@ div.relative > div > div#ui-datepicker-div { } .container-div-input-password { - display: inline !important; + display: block !important; } #message_dialog_connection { From f43279acc35e6ff075586e0ef261b79f1bbbcbb6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 09:27:02 +0100 Subject: [PATCH 057/233] #12777 qr name remove entities --- pandora_console/godmode/users/user_management.php | 2 +- pandora_console/include/javascript/qrcode.js | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 7a5abb8503..4fa30a253e 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -985,7 +985,7 @@ html_print_table($userManagementTable); $vcard_data = []; $vcard_data['version'] = '3.0'; -$vcard_data['firstName'] = $user_info['fullname']; +$vcard_data['firstName'] = io_safe_output($user_info['fullname']); $vcard_data['lastName'] = ''; $vcard_data['middleName'] = ''; $vcard_data['workPhone'] = $user_info['phone']; diff --git a/pandora_console/include/javascript/qrcode.js b/pandora_console/include/javascript/qrcode.js index 4f664b4659..33f38e1b6f 100644 --- a/pandora_console/include/javascript/qrcode.js +++ b/pandora_console/include/javascript/qrcode.js @@ -2413,22 +2413,11 @@ date: 2018-05-14 15:05:04 }); } + console.log(vCard); formattedVCardString += "FN" + encodingPrefix + ":" + e(formattedName) + nl(); formattedVCardString += - "N" + - encodingPrefix + - ":" + - e(vCard.lastName) + - ";" + - e(vCard.firstName) + - ";" + - e(vCard.middleName) + - ";" + - e(vCard.namePrefix) + - ";" + - e(vCard.nameSuffix) + - nl(); + "N" + encodingPrefix + ":" + e(vCard.firstName) + nl(); if (vCard.nickname && majorVersion >= 3) { formattedVCardString += From 5d5bfc654dfaad238c62540ba0819fef810e8f86 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 22 Jan 2024 12:39:43 +0100 Subject: [PATCH 058/233] #12753 fixed os command injection --- pandora_console/include/ajax/events.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 007ba77d89..851a22040b 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1335,6 +1335,15 @@ if ($perform_event_response === true) { } $command = $event_response['target']; + + // Prevent OS command injection. + $prev_command = get_events_get_response_target($event_id, $event_response, $server_id); + + if ($command !== $prev_command) { + echo __('unauthorized'); + return; + } + $command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90; if (enterprise_installed() === true) { if ($event_response !== false From 29207ed367a1c2383c0cc3ba0e9439bedc7e57a6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 12:59:11 +0100 Subject: [PATCH 059/233] #12617 add class correct colum --- pandora_console/godmode/servers/servers.build_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 23a284caf9..1589f33fc9 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -115,7 +115,7 @@ foreach ($servers as $server) { $table->cellclass[] = [ 3 => 'progress_bar', - 8 => 'table_action_buttons', + 9 => 'table_action_buttons', ]; $data[0] = ''.strip_tags($server['name']).''; From 54e3f94d62cd0dfdeaa84ee5c6c3edb790c59268 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 22 Jan 2024 15:07:25 +0100 Subject: [PATCH 060/233] #12782 fixed button sound events style in events --- pandora_console/include/styles/events.css | 16 ++++++++++++++++ pandora_console/operation/events/events.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 9a69ea8c56..4e3da3194c 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -569,3 +569,19 @@ div.container-filter-buttons { .ui-dialog.modal-sound .ui-widget-header { display: flex !important; } + +.responsive_button_sound_events { + margin-right: 25% !important; +} + +@media (max-width: 1640px) { + .responsive_button_sound_events { + margin-right: 10% !important; + } +} + +@media (max-width: 1420px) { + .responsive_button_sound_events { + margin-right: 10px !important; + } +} diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 79fe087a52..31d4336928 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2951,8 +2951,8 @@ if (check_acl( false, 'openSoundEventsDialog("'.$data_sound.'")', [ + 'class' => 'responsive_button_sound_events', 'icon' => 'sound', - 'style' => 'margin-right: 25% !important', 'minimize-arrow' => true, 'span_style' => 'width: 100%', ], From 17056e4ac33cf26abbb74d360e37bd967196f111 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 22 Jan 2024 15:30:46 +0100 Subject: [PATCH 061/233] #12460 merge with 12643 --- pandora_console/operation/events/events.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 86a499762f..a668829d49 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1253,15 +1253,6 @@ if (is_ajax() === true) { ); } - $data = array_values( - array_filter( - ((is_array($data) === true) ? $data : []), - function ($item) { - return (bool) (array) $item; - } - ) - ); - $count = count($data); // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ From a747308b268e4d3c9c1b04b1c5f721473e6e9b04 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 16:21:51 +0100 Subject: [PATCH 062/233] #12636 fix errors --- pandora_console/godmode/setup/os.builder.php | 6 ++-- pandora_console/godmode/setup/os.php | 8 ++++++ pandora_console/include/functions_ui.php | 30 ++++++++++++++------ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index 6313aa3edd..4f7b77099b 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -48,7 +48,7 @@ if ($idOS > 0) { } else { $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); + $icon = get_parameter('icon', 'os@svg.svg'); } $icon_upload = get_parameter('icon_upload', null); @@ -246,7 +246,7 @@ $iconData[] = html_print_select( 'icon', $icon, 'show_icon_OS();', - __('None'), + '', 0, true ); @@ -356,6 +356,8 @@ function get_list_os_icons_dir() } } + $return['os@svg.svg'] = __('None'); + return $return; } diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index dcfe95ecdb..403232c868 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -88,6 +88,14 @@ switch ($tab) { break; case 'manage_os': + $id_os = get_parameter('id_os', ''); + if ($id_os !== '') { + $headerTitle = __('Edit OS'); + } else { + $headerTitle = __('Create OS'); + } + break; + case 'list': if ($action === 'edit') { $headerTitle = __('Edit OS'); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d6078c56a7..f36b024ac1 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -969,15 +969,27 @@ function ui_print_os_icon( $options['title'] = $os_name; } - $output = html_print_image( - 'images/'.$subfolder.'/'.$icon, - true, - $options, - false, - $relative, - $no_in_meta, - true - ); + if ($icon === '.png') { + $output = html_print_image( + 'images/os@svg.svg', + true, + $options, + false, + $relative, + $no_in_meta, + true + ); + } else { + $output = html_print_image( + 'images/'.$subfolder.'/'.$icon, + true, + $options, + false, + $relative, + $no_in_meta, + true + ); + } } } else { // $output = "" . $os_name . ""; From 95f8519d5d3cab5b34e92b362b1820eb7f293575 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 22 Jan 2024 17:22:23 +0100 Subject: [PATCH 063/233] #12687 Added import/export prd --- pandora_console/godmode/menu.php | 3 + .../resources/resources_export_import.php | 160 ++++++++++ .../include/ajax/resources.ajax.php | 74 +++++ pandora_console/include/class/Prd.class.php | 281 ++++++++++++++++++ 4 files changed, 518 insertions(+) create mode 100644 pandora_console/godmode/resources/resources_export_import.php create mode 100644 pandora_console/include/ajax/resources.ajax.php create mode 100644 pandora_console/include/class/Prd.class.php diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index a77e63b95b..4f116502e3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -208,6 +208,9 @@ if ($access_console_node === true) { $sub['godmode/setup/os']['text'] = __('Operating systems'); $sub['godmode/setup/os']['id'] = 'edit_OS'; + + $sub['godmode/resources/resources_export_import']['text'] = __('Resources export/import'); + $sub['godmode/resources/resources_export_import']['id'] = 'resources_export_import'; } if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { diff --git a/pandora_console/godmode/resources/resources_export_import.php b/pandora_console/godmode/resources/resources_export_import.php new file mode 100644 index 0000000000..569c854278 --- /dev/null +++ b/pandora_console/godmode/resources/resources_export_import.php @@ -0,0 +1,160 @@ +id = 'import_data_table'; +$table->class = 'databox filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->size = []; + +$table->data[0][0] = html_print_label_input_block( + __('Resource importation'), + html_print_input_file('resource_import', true) +); + +$table->data[0][1] = html_print_label_input_block( + __('Group filter'), + html_print_select_groups(false, 'AW', true, 'group', '', '', __('All'), 0, true) +); + +html_print_table($table); + +$table = new stdClass(); +$table->id = 'export_data_table'; +$table->class = 'databox filter-table-adv'; +$table->width = '100%'; +$table->data = []; +$table->style = []; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; + +// Instance of the prd class. +$prd = new Prd(); + +$export_type = $prd->getTypesPrd(); + +$table->data[0][0] = html_print_label_input_block( + __('Export type'), + html_print_select( + $export_type, + 'export_type', + '', + '', + __('None'), + 0, + true, + false, + true, + 'w40p' + ) +); + +$table->data[1][0] = ''; + +$table->data[2][0] = html_print_button( + __('Export'), + 'export_button', + false, + '', + ['class' => 'flex_justify invisible_important'], + true +); + +html_print_table($table); + +?> + \ No newline at end of file diff --git a/pandora_console/include/ajax/resources.ajax.php b/pandora_console/include/ajax/resources.ajax.php new file mode 100644 index 0000000000..5c6c8ed02d --- /dev/null +++ b/pandora_console/include/ajax/resources.ajax.php @@ -0,0 +1,74 @@ +getOnePrdData($type); + if (empty($check) === false) { + switch ($type) { + case 'visual_console': + $result = html_print_label_input_block( + __('Visual console'), + io_safe_output( + html_print_select_from_sql( + 'SELECT id, name FROM tlayout', + 'select_value', + '', + '', + '', + 0, + true, + false, + true, + false, + false, + false, + GENERIC_SIZE_TEXT, + 'w40p', + ), + ) + ); + break; + + default: + // TODO. + break; + } + } + + echo $result; + return; + } + + if ($exportPrd === true) { + $type = (string) get_parameter('type', ''); + $value = (int) get_parameter('value', 0); + $name = (string) get_parameter('name', ''); + + $prd->exportPrd($type, $value, $name); + } +} diff --git a/pandora_console/include/class/Prd.class.php b/pandora_console/include/class/Prd.class.php new file mode 100644 index 0000000000..faf4a13c28 --- /dev/null +++ b/pandora_console/include/class/Prd.class.php @@ -0,0 +1,281 @@ +prdData = [ + 'visual_console' => [ + 'label' => __('Visual console'), + 'items' => [ + 'table' => 'tlayout', + 'value' => 'id', + 'show' => 'name', + ], + 'data' => [ + [ + 'table' => 'tlayout', + 'ref' => 'id', + ], + [ + 'table' => 'tlayout_data', + 'ref' => 'id_layout', + ], + ], + ], + ]; + + $this->columnRefs = [ + 'tlayout_data' => [ + 'id_agent' => [ + 'table' => 'tagente', + 'id' => 'id_agente', + 'column' => 'nombre', + ], + 'id_agente_modulo' => [ + 'table' => 'tagente_modulo', + 'id' => 'id_agente_modulo', + 'column' => 'nombre', + 'join' => [ + 'id_agente' => [ + 'table' => 'tagente', + 'id' => 'id_agente', + 'column' => 'nombre', + ], + ], + ], + ], + ]; + + $this->jsonRefs = [ + 'twidget_dashboard' => [ + 'options' => [ + 'agent' => [ + 'array' => false, + 'table' => 'tagente', + 'id' => 'id_agente', + 'column' => 'nombre', + ], + 'module' => [ + 'array' => false, + 'table' => 'tagente_modulo', + 'id' => 'id_agente_modulo', + 'column' => 'nombre', + 'join' => [ + 'id_agente' => [ + 'table' => 'tagente', + 'id' => 'id_agente', + 'column' => 'nombre', + ], + ], + ], + ], + ], + ]; + + $this->message = ''; + } + + + /** + * Generates a JSON error. + * + * @param string $msg Error message. + * + * @return void + */ + public function error(string $msg) + { + echo json_encode( + ['error' => $msg] + ); + } + + + /** + * Get $prdData. + * + * @return array + */ + public function getPrdData(): array + { + return $this->prdData; + } + + + /** + * Get one $prdData. + * + * @param string $item Item to be searched in array. + * + * @return boolean|array + */ + public function getOnePrdData(string $item): bool|array + { + if (isset($this->prdData[$item]) === false) { + return false; + } + + return $this->prdData[$item]; + } + + + /** + * Get $columnRefs. + * + * @return array + */ + public function getColumnRefs(): array + { + return $this->columnRefs; + } + + + /** + * Get one $columnRefs. + * + * @param string $item Item to be searched in array. + * + * @return boolean|array + */ + public function getOneColumnRefs(string $item): bool|array + { + if (isset($this->columnRefs[$item]) === false) { + return false; + } + + return $this->columnRefs[$item]; + } + + + /** + * Get $jsonRefs. + * + * @return array + */ + public function getJsonRefs(): array + { + return $this->jsonRefs; + } + + + /** + * Get types of prd. + * + * @return array + */ + public function getTypesPrd(): array + { + $result = []; + foreach ($this->prdData as $key => $value) { + $result[$key] = $value['label']; + } + + return $result; + } + + + /** + * Export prd. + * + * @return array + */ + public function exportPrd(string $type, $value, $name) :array + { + $result = []; + + $prd_data = $this->getOnePrdData($type); + if (empty($prd_data) === false) { + $result['prd_data'] = [ + 'type' => $type, + 'name' => $name, + ]; + + foreach ($prd_data['data'] as $key => $element) { + $sql = sprintf( + 'SELECT * FROM %s WHERE %s = %s', + $element['table'], + $element['ref'], + $value, + ); + + $test = db_get_all_rows_sql($sql); + + // $result[$element['table']] + // hd($test, true); + } + } + + return $result; + + } + + +} From 6948306d820c48a090dabb4ea47ad75a4f920692 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 22 Jan 2024 17:29:51 +0100 Subject: [PATCH 064/233] #12767 Fixed password 3 --- pandora_console/include/functions_html.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 06ab07598d..7052450b5f 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2728,8 +2728,8 @@ function html_print_input_text_extended( if ($hide_div_eye !== false) { echo ""; @@ -2746,9 +2746,11 @@ function html_print_input_text_extended( ]; foreach ($attrs as $attribute => $default) { - if (array_key_exists($attribute, $attributes)) { + if (array_key_exists($attribute, $attributes) + || ($password === true && $attribute === 'value') + ) { continue; - } //end if + } /* * Remember, this next code have a $$ that for example there is a var as @@ -2758,7 +2760,7 @@ function html_print_input_text_extended( * */ - // Exact operator because we want to show "0" on the value + // Exact operator because we want to show "0" on the value. if ($attribute !== '') { $output .= $attribute.'="'.$$attribute.'" '; } else if ($default != '') { @@ -2789,6 +2791,12 @@ function html_print_input_text_extended( ], true ); + + echo "'; } if (!$return) { From 510c28bb0925943cb74eb4bcda1b86d3e7349898 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Jan 2024 10:56:31 +0100 Subject: [PATCH 065/233] #12698 fix welcome messages --- .../lib/TacticalView/GeneralTacticalView.php | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php index e00bc8fcf8..06e27e4fd6 100644 --- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -224,18 +224,33 @@ class GeneralTacticalView $zone_location = $date_zone->getLocation(); $latitude = $zone_location['latitude']; - $emojiOptions = [ - 'have_good_day' => __('Have a good day %s ✌', $name), - 'welcome_back' => __('Welcome back! %s 👋', $name), - 'merry_christmas' => __('Welcome back! %s 🎅', $name), - 'good_morning' => __('Good morning, %s! ☕', $name), - 'good_evening' => __('Good evening, %s 🌇', $name), - 'good_night' => __('Good night, %s 🌕', $name), - 'happy_summer' => __('Happy summer, %s 🌞', $name), - 'happy_winter' => __('Happy winter, %s ⛄', $name), - 'happy_autumn' => __('Happy autumn, %s 🍂', $name), - 'happy_spring' => __('Happy spring, %s 🌻', $name), - ]; + if ($name !== '') { + $emojiOptions = [ + 'have_good_day' => __('Have a good day %s ✌', $name), + 'welcome_back' => __('Welcome back! %s 👋', $name), + 'merry_christmas' => __('Welcome back! %s 🎅', $name), + 'good_morning' => __('Good morning, %s! ☕', $name), + 'good_evening' => __('Good evening, %s 🌇', $name), + 'good_night' => __('Good night, %s 🌕', $name), + 'happy_summer' => __('Happy summer, %s 🌞', $name), + 'happy_winter' => __('Happy winter, %s ⛄', $name), + 'happy_autumn' => __('Happy autumn, %s 🍂', $name), + 'happy_spring' => __('Happy spring, %s 🌻', $name), + ]; + } else { + $emojiOptions = [ + 'have_good_day' => __('Have a good day ✌'), + 'welcome_back' => __('Welcome back! 👋'), + 'merry_christmas' => __('Welcome back! 🎅'), + 'good_morning' => __('Good morning! ☕'), + 'good_evening' => __('Good evening 🌇'), + 'good_night' => __('Good night 🌕'), + 'happy_summer' => __('Happy summer 🌞'), + 'happy_winter' => __('Happy winter ⛄'), + 'happy_autumn' => __('Happy autumn 🍂'), + 'happy_spring' => __('Happy spring 🌻'), + ]; + } // Welcome back. $user_last_connect = $user['last_connect']; From cd27935b4c762621ec855471023020fc1f95bd9a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Jan 2024 11:26:15 +0100 Subject: [PATCH 066/233] #12623 fix menu inventory modules --- pandora_console/include/functions_menu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index ca67825da1..37d4e11c38 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -155,6 +155,8 @@ function menu_print_menu(&$menu) } } else if ($sec2 === 'godmode/users/configure_user') { $sec2 = 'godmode/users/user_list'; + } else if ($sec2 === 'godmode/modules/manage_inventory_modules_form') { + $sec2 = 'godmode/modules/manage_inventory_modules'; } else if ($sec2 === 'godmode/groups/configure_group') { $sec2 = 'godmode/groups/group_list'; } else if ($sec2 === 'godmode/users/configure_profile') { From fc08e9b9b657df8c3b3e2454c1cb10f0f311c281 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Jan 2024 11:27:15 +0100 Subject: [PATCH 067/233] #12792 fix 500 change agent inventory --- pandora_console/include/ajax/inventory.ajax.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/ajax/inventory.ajax.php b/pandora_console/include/ajax/inventory.ajax.php index 71fac8d0ec..207adde03d 100644 --- a/pandora_console/include/ajax/inventory.ajax.php +++ b/pandora_console/include/ajax/inventory.ajax.php @@ -26,7 +26,8 @@ * ============================================================================ */ - check_login(); +require_once $config['homedir'].'/include/functions_inventory.php'; +check_login(); if (is_ajax() === true) { $id_agent = get_parameter('id_agent', '0'); From 3026c9d50dc47aac8932b859f7b6fb8a2e6e0ff4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Jan 2024 16:27:07 +0100 Subject: [PATCH 068/233] #12786 fix wizard open out of index --- pandora_console/general/register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 759e319dbd..ed583c7ed4 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,7 +100,7 @@ if ($initial && users_is_admin()) { ); } -if (check_acl($config['id_user'], 0, 'AW')) { +if (check_acl($config['id_user'], 0, 'AW') && empty($sec2)) { $welcome = !$initial; try { $welcome_window = new WelcomeWindow($welcome); From 538177c3e5b34df01527948183722236b2dac274 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 23 Jan 2024 17:08:06 +0100 Subject: [PATCH 069/233] #12753 fixed vul command in ajax --- pandora_console/include/functions_events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index cd22b55f1b..e328f4cd91 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3804,7 +3804,7 @@ function events_get_response_target( } $event = db_get_row('tevento', 'id_evento', $event_id); - $target = io_safe_output($event_response['target']); + $target = io_safe_output(db_get_value('target', 'tevent_response', 'id', $event_response['id'])); // Replace parameters response. if (isset($response_parameters) === true From 7f604f0c8dccbb4795fcfaeae9e33af860dc4b42 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 23 Jan 2024 17:47:26 +0100 Subject: [PATCH 070/233] #12460 fixed deprecated --- pandora_console/include/graphs/functions_gd.php | 7 +++++++ .../include/lib/ClusterViewer/ClusterWizard.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index e32e76222f..b34bed47f7 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -301,6 +301,13 @@ function gd_progress_bubble($width, $height, $progress, $title, $font, $out_of_l function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) { + $x1 = (int) $x1; + $y1 = (int) $y1; + $x2 = (int) $x2; + $y2 = (int) $y2; + $radius = (int) $radius; + $color = (int) $color; + // Draw rectangle without corners imagefilledrectangle($im, ($x1 + $radius), $y1, ($x2 - $radius), $y2, $color); imagefilledrectangle($im, $x1, ($y1 + $radius), $x2, ($y2 - $radius), $color); diff --git a/pandora_console/include/lib/ClusterViewer/ClusterWizard.php b/pandora_console/include/lib/ClusterViewer/ClusterWizard.php index 3c4c4eb293..0c67cc64f9 100644 --- a/pandora_console/include/lib/ClusterViewer/ClusterWizard.php +++ b/pandora_console/include/lib/ClusterViewer/ClusterWizard.php @@ -113,6 +113,13 @@ class ClusterWizard extends \HTML */ private $agent; + /** + * Id of clusters. + * + * @var integer + */ + public $id; + /** * Builds a Cluster Wizard. From 1bc9bc609561f76c7f9040c3f3291c5c7df8d365 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 23 Jan 2024 17:52:06 +0100 Subject: [PATCH 071/233] Fix MR --- pandora_console/extras/mr/68.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index ed186c4f91..7ab19fe840 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -8,7 +8,6 @@ ALTER TABLE `tevent_sound` MODIFY COLUMN `sound` text NULL; ALTER TABLE `treport_content` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1; ALTER TABLE `treport_content_template` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1; ALTER TABLE `tsesion_filter` MODIFY COLUMN `id_name` text NULL; -ALTER TABLE `tsesion_filter` MODIFY COLUMN `period` text NULL; ALTER TABLE `tsesion_filter` MODIFY COLUMN `ip` text NULL; ALTER TABLE `tsesion_filter` MODIFY COLUMN `type` text NULL; ALTER TABLE `tsesion_filter` MODIFY COLUMN `user` text NULL; @@ -17,4 +16,4 @@ ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`; ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`; -COMMIT; +COMMIT; \ No newline at end of file From dd252daaf2072a2435b67e788117bbe9d3c4f18f Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 24 Jan 2024 01:00:32 +0100 Subject: [PATCH 072/233] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el8.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el9.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e7c241251a..da5db137f5 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240123 +Version: 7.0NG.775-240124 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 00e1bec872..4617d8e745 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.775-240123" +pandora_version="7.0NG.775-240124" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 40317705f1..4ec522db43 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.775'; -use constant AGENT_BUILD => '240123'; +use constant AGENT_BUILD => '240124'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 8ed67cacd8..2786cafe56 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.775 -%define release 240123 +%define release 240124 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 e073b7a1b6..92cb781d5a 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.775 -%define release 240123 +%define release 240124 %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 ca44c46126..56dc5c9c0c 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.775 -%define release 240123 +%define release 240124 %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 857491d509..858147650c 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.775 -%define release 240123 +%define release 240124 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 1491df0b07..deff8bc50f 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.775 -%define release 240123 +%define release 240124 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 0232a6bf8c..9a94ff4cb4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240123" +PI_BUILD="240124" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 74ffb7b496..dd51dcf708 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240123} +{240124} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8e094eedae..22f49347f0 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.775 Build 240123") +#define PANDORA_VERSION ("7.0NG.775 Build 240124") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index b7d17d6756..cf88101947 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.775(Build 240123))" + VALUE "ProductVersion", "(7.0NG.775(Build 240124))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4d832ca478..d23840e972 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240123 +Version: 7.0NG.775-240124 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 95ee569569..4c11ce1bce 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.775-240123" +pandora_version="7.0NG.775-240124" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 6c993cc7ca..60dd8bf9a1 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 = 'PC240123'; +$build_version = 'PC240124'; $pandora_version = 'v7.0NG.775'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 6d491a85cb..ab50a8ec91 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 251e09b74e..d76f4f73f5 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240123 +%define release 240124 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 6c05f78ac2..fdafb2797e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240123 +%define release 240124 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index effa474fba..2202c82563 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240123" +PI_BUILD="240124" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 2ab5d89b6a..47f6f469ab 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.775 Build 240123"; +my $version = "7.0NG.775 Build 240124"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 2d1eec0b82..7801143234 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.775 Build 240123"; +my $version = "7.0NG.775 Build 240124"; # save program name for logging my $progname = basename($0); From 4fc3013cc3b15ef4981a1b5fdcc6688da65585b9 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 24 Jan 2024 09:15:32 +0100 Subject: [PATCH 073/233] #12522 fixed multiple audit when update setup --- pandora_console/include/functions_config.php | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 9f4c38aa68..0f552ac519 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -104,6 +104,7 @@ function config_update_value($token, $value, $noticed=false, $password=false) return true; } + $prev_value = $config[$token]; $config[$token] = $value; $value = io_safe_output($value); @@ -117,13 +118,24 @@ function config_update_value($token, $value, $noticed=false, $password=false) return true; } else { // Something in setup changes. - if ($noticed === true) { + $value_token = (empty($config[$token]) === true) ? 0 : $config[$token]; + $prev_value = (empty($prev_value) === true) ? 0 : $prev_value; + if (is_array($prev_value) === true) { + $prev_value = implode(';', $prev_value); + } + + if ($noticed === true && $prev_value !== $value_token) { db_pandora_audit( AUDIT_LOG_SETUP, 'Setup has changed', false, false, - sprintf('Token << %s >> updated.', $token) + sprintf( + 'Token << %s >> updated %s -> %s', + $token, + $prev_value, + $value_token + ) ); } @@ -2090,11 +2102,6 @@ function config_update_config() } else { $config['error_config_update_config'] = []; $config['error_config_update_config']['correct'] = true; - - db_pandora_audit( - AUDIT_LOG_SETUP, - 'Setup has changed' - ); } if (count($errors) > 0) { From 4e523e94cce55b4c3c025a2b430aaf3ac1198907 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Jan 2024 09:51:35 +0100 Subject: [PATCH 074/233] #12574 fix datepicker and give style --- pandora_console/extensions/insert_data.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 6f09d889f7..d06ff90118 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -283,8 +283,14 @@ function mainInsertData() secondText: '', currentText: '', closeText: ''}); - - $("#text-date").datepicker({dateFormat: ""}); + + $('#text-data').datepicker ({ + dateFormat: '', + changeMonth: true, + changeYear: true, + showAnim: 'slideDown', + firstDay: "", + }); $.datepicker.setDefaults($.datepicker.regional[ ""]); }); From bfb34d1c75dd02138c4aa7fd9c6ad98e46b634b6 Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 24 Jan 2024 11:56:58 +0100 Subject: [PATCH 075/233] #12719. Fix creating duplicated agents on tagente --- pandora_server/lib/PandoraFMS/DataServer.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 80e8bb4bd3..9db3f0f7ce 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -418,8 +418,10 @@ sub process_xml_data ($$$$$) { # A module with No-learn mode (modo = 0) creates its modules on database only when it is created my $new_agent = 0; - # Get agent id - my $agent_id = get_agent_id ($dbh, $agent_name); + # Get agent id from tagente. + my $agent_id = get_db_value ($dbh, "SELECT id_agente FROM tagente WHERE nombre = ?", safe_input($agent_name)); + $agent_id = -1 unless defined($agent_id); + my $group_id = 0; if ($agent_id < 1) { if ($pa_config->{'autocreate'} == 0) { From 401b1973bed7bde5e06a680d2d1973f1bb4184d4 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 24 Jan 2024 12:15:16 +0100 Subject: [PATCH 076/233] #12687 Added import/export prd 2 --- .../resources/resources_export_import.php | 28 +- .../include/ajax/resources.ajax.php | 94 ++++-- pandora_console/include/class/Prd.class.php | 318 ++++++++++++++++-- pandora_console/include/constants.php | 3 + 4 files changed, 381 insertions(+), 62 deletions(-) diff --git a/pandora_console/godmode/resources/resources_export_import.php b/pandora_console/godmode/resources/resources_export_import.php index 569c854278..146784f2e4 100644 --- a/pandora_console/godmode/resources/resources_export_import.php +++ b/pandora_console/godmode/resources/resources_export_import.php @@ -114,6 +114,7 @@ html_print_table($table); $("#button-export_button").addClass("invisible_important"); $("#export_data_table-1-0").html(''); } else { + $("#export_data_table-1-0").html(''); $.ajax({ type: "GET", url: "ajax.php", @@ -137,10 +138,18 @@ html_print_table($table); $("#button-export_button").click(function(e) { const value = $("#select_value").val(); if (value !== '0') { + //Show dialog. + confirmDialog({ + title: "", + message: "", + hideCancelButton: true + }, + "downloadDialog" + ); + $.ajax({ type: "GET", url: "ajax.php", - dataType: "html", data: { page: 'include/ajax/resources.ajax', exportPrd: 1, @@ -149,7 +158,24 @@ html_print_table($table); name: $("#select_value").text(), }, success: function(data) { + let a = document.createElement('a'); + const url = '' + data; + a.href = url; + a.download = data; + a.click(); + setTimeout(() => { + $.ajax({ + type: "DELETE", + url: "ajax.php", + data: { + page: 'include/ajax/resources.ajax', + deleteFile: 1, + filename: data, + }, + }); + $("#confirm_downloadDialog").dialog("close"); + }, 3000); }, error: function(data) { console.error("Fatal error in AJAX call to interpreter order", data) diff --git a/pandora_console/include/ajax/resources.ajax.php b/pandora_console/include/ajax/resources.ajax.php index 5c6c8ed02d..379a499407 100644 --- a/pandora_console/include/ajax/resources.ajax.php +++ b/pandora_console/include/ajax/resources.ajax.php @@ -20,6 +20,7 @@ if ((bool) is_ajax() === true) { $getResource = (bool) get_parameter('getResource', false); $exportPrd = (bool) get_parameter('exportPrd', false); + $deleteFile = (bool) get_parameter('deleteFile', false); $prd = new Prd(); @@ -27,37 +28,34 @@ if ((bool) is_ajax() === true) { $type = (string) get_parameter('type', ''); $result = false; - $check = $prd->getOnePrdData($type); - if (empty($check) === false) { - switch ($type) { - case 'visual_console': - $result = html_print_label_input_block( - __('Visual console'), - io_safe_output( - html_print_select_from_sql( - 'SELECT id, name FROM tlayout', - 'select_value', - '', - '', - '', - 0, - true, - false, - true, - false, - false, - false, - GENERIC_SIZE_TEXT, - 'w40p', - ), - ) - ); - break; - - default: - // TODO. - break; - } + $data = $prd->getOnePrdData($type); + if (empty($data) === false) { + $sql = sprintf( + 'SELECT %s FROM %s', + reset($data['items']['value']).', '.reset($data['items']['show']), + $data['items']['table'] + ); + $result = html_print_label_input_block( + $data['label'], + io_safe_output( + html_print_select_from_sql( + $sql, + 'select_value', + '', + '', + '', + 0, + true, + false, + true, + false, + false, + false, + GENERIC_SIZE_TEXT, + 'w40p', + ), + ) + ); } echo $result; @@ -69,6 +67,38 @@ if ((bool) is_ajax() === true) { $value = (int) get_parameter('value', 0); $name = (string) get_parameter('name', ''); - $prd->exportPrd($type, $value, $name); + $data = $prd->exportPrd($type, $value, $name); + + $return = ''; + + if (empty($data) === false) { + $filename = $type.'-'.date('Ymd').'-'.date('His').'.prd'; + $file = $config['attachment_store'].'/'.$filename; + + $file_pointer = fopen($file, 'a'); + if ($file_pointer !== false) { + $write = fwrite($file_pointer, $data); + + if ($write === false) { + $return = -2; + } else { + $return = $filename; + } + + fclose($file_pointer); + } else { + $return = -1; + } + } + + echo $return; + + return; + } + + if ($deleteFile === true) { + $filename = (string) get_parameter('filename', ''); + + unlink($config['attachment_store'].'/'.$filename); } } diff --git a/pandora_console/include/class/Prd.class.php b/pandora_console/include/class/Prd.class.php index faf4a13c28..c115b639a2 100644 --- a/pandora_console/include/class/Prd.class.php +++ b/pandora_console/include/class/Prd.class.php @@ -76,17 +76,219 @@ class Prd 'label' => __('Visual console'), 'items' => [ 'table' => 'tlayout', - 'value' => 'id', - 'show' => 'name', - ], - 'data' => [ - [ - 'table' => 'tlayout', - 'ref' => 'id', + 'value' => ['id'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'tlayout_data', + 'ref' => ['id_layout'], + 'value' => ['id'], + ], ], - [ - 'table' => 'tlayout_data', - 'ref' => 'id_layout', + ], + ], + 'custom_report' => [ + 'label' => __('Custom report'), + 'items' => [ + 'table' => 'treport', + 'value' => ['id_report'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'treport_content', + 'ref' => ['id_report'], + 'value' => ['id_rc'], + 'data' => [ + [ + 'table' => 'treport_content_item', + 'ref' => ['id_report_content'], + 'value' => ['id'], + ], + [ + 'table' => 'treport_content_sla_combined', + 'ref' => ['id_report_content'], + 'value' => ['id'], + ], + ], + ], + ], + ], + ], + 'policy' => [ + 'label' => __('Policy'), + 'items' => [ + 'table' => 'tpolicies', + 'value' => ['id'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'tpolicy_agents', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + [ + 'table' => 'tpolicy_alerts', + 'ref' => ['id_policy'], + 'value' => ['id'], + 'data' => [ + [ + 'table' => 'tpolicy_alerts_actions', + 'ref' => ['id_policy_alert'], + 'value' => ['id'], + ], + ], + ], + [ + 'table' => 'tpolicy_collections', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + [ + 'table' => 'tpolicy_group_agents', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + [ + 'table' => 'tpolicy_groups', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + [ + 'table' => 'tpolicy_modules', + 'ref' => ['id_policy'], + 'value' => ['id'], + 'data' => [ + [ + 'table' => 'ttag_policy_module', + 'ref' => ['id_policy_module'], + 'value' => [ + 'id_tag', + 'id_policy_module', + ], + ], + [ + 'table' => 'tpolicy_modules_synth', + 'ref' => ['id_agent_module_target'], + 'value' => ['id'], + ], + ], + ], + [ + 'table' => 'tpolicy_modules_inventory', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + [ + 'table' => 'tpolicy_plugins', + 'ref' => ['id_policy'], + 'value' => ['id'], + ], + ], + ], + ], + 'service' => [ + 'label' => __('Service'), + 'items' => [ + 'table' => 'tservice', + 'value' => ['id'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'tservice_element', + 'ref' => ['id_service'], + 'value' => ['id'], + ], + ], + ], + ], + 'network_map' => [ + 'label' => __('Network map'), + 'items' => [ + 'table' => 'tmap', + 'value' => ['id'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'titem', + 'ref' => ['id_map'], + 'value' => ['id'], + ], + [ + 'table' => 'trel_item', + 'ref' => ['id_map'], + 'value' => ['id'], + ], + ], + ], + ], + 'gis_map' => [ + 'label' => __('GIS map'), + 'items' => [ + 'table' => 'tgis_map', + 'value' => ['id_tgis_map'], + 'show' => ['map_name'], + 'data' => [ + [ + 'table' => 'tgis_map_layer', + 'ref' => ['tgis_map_id_tgis_map'], + 'value' => ['id_tmap_layer'], + 'data' => [ + [ + 'table' => 'tgis_map_layer_groups', + 'ref' => ['layer_id'], + 'value' => [ + 'layer_id', + 'group_id', + ], + ], + [ + 'table' => 'tgis_map_layer_has_tagente', + 'ref' => ['tgis_map_layer_id_tmap_layer'], + 'value' => [ + 'tgis_map_layer_id_tmap_layer', + 'tagente_id_agente', + ], + ], + ], + ], + [ + 'table' => 'tgis_map_has_tgis_map_con', + 'ref' => ['tgis_map_id_tgis_map'], + 'value' => [ + 'tgis_map_id_tgis_map', + 'tgis_map_con_id_tmap_con', + ], + ], + ], + ], + ], + 'custom_graph' => [ + 'label' => __('Custom graph'), + 'items' => [ + 'table' => 'tgraph', + 'value' => ['id_graph'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'tgraph_source', + 'ref' => ['id_graph'], + 'value' => ['id_gs'], + ], + ], + ], + ], + 'dashboard' => [ + 'label' => __('Dashboard'), + 'items' => [ + 'table' => 'tdashboard', + 'value' => ['id'], + 'show' => ['name'], + 'data' => [ + [ + 'table' => 'twidget_dashboard', + 'ref' => ['id_dashboard'], + 'value' => ['id'], + ], ], ], ], @@ -243,38 +445,96 @@ class Prd /** - * Export prd. + * Converts a resource into a string. * - * @return array + * @param string $type Item type. + * @param mixed $id Item value. + * @param string $name Item name. + * + * @return string */ - public function exportPrd(string $type, $value, $name) :array + public function exportPrd(string $type, mixed $id, string $name) :string { - $result = []; + $result = ''; $prd_data = $this->getOnePrdData($type); if (empty($prd_data) === false) { - $result['prd_data'] = [ - 'type' => $type, - 'name' => $name, - ]; + $result .= '[prd_data]'.LINE_BREAK.LINE_BREAK; + $result .= 'type="'.$type.'"'.LINE_BREAK; + $result .= 'name="'.$name.'"'.LINE_BREAK.LINE_BREAK; - foreach ($prd_data['data'] as $key => $element) { - $sql = sprintf( - 'SELECT * FROM %s WHERE %s = %s', - $element['table'], - $element['ref'], - $value, - ); + $result .= '['.$prd_data['items']['table'].']'.LINE_BREAK.LINE_BREAK; - $test = db_get_all_rows_sql($sql); + $sql = sprintf( + 'SELECT * FROM %s WHERE %s = %s', + $prd_data['items']['table'], + reset($prd_data['items']['value']), + $id, + ); - // $result[$element['table']] - // hd($test, true); + $row = db_get_row_sql($sql); + $primary_key = $row[reset($prd_data['items']['value'])]; + foreach ($row as $column => $value) { + $result .= $column.'['.$primary_key.']="'.$value.'"'.LINE_BREAK; + } + + $result .= LINE_BREAK; + + $result .= $this->recursiveExport($prd_data['items']['data'], $id); + } + + return $result; + } + + + /** + * Recursive function to traverse all data + * + * @param mixed $data Data. + * @param mixed $id Id value for search. + * + * @return string + */ + private function recursiveExport($data, $id): string + { + $result = ''; + + foreach ($data as $key => $element) { + $result .= '['.$element['table'].']'.LINE_BREAK.LINE_BREAK; + $sql = sprintf( + 'SELECT * FROM %s WHERE %s = %s', + $element['table'], + reset($element['ref']), + $id, + ); + + $rows = db_get_all_rows_sql($sql); + foreach ($rows as $row) { + if (count($element['value']) > 1) { + $primary_key = ''; + foreach ($element['value'] as $value) { + $primary_key .= $row[$value].'-'; + } + + $primary_key = substr($primary_key, 0, -1); + hd($primary_key, true); + } else { + $primary_key = $row[reset($element['value'])]; + } + + foreach ($row as $column => $value) { + $result .= $column.'['.$primary_key.']="'.$value.'"'.LINE_BREAK; + } + + $result .= LINE_BREAK; + } + + if (isset($element['data']) === true) { + $result .= $this->recursiveExport($element['data'], $primary_key); } } return $result; - } diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index b2ce8d88b4..422c2dcc95 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -906,3 +906,6 @@ define('DEMO_SERVICE', 6); define('DEMO_DASHBOARD', 7); define('DEMO_VISUAL_CONSOLE', 8); define('DEMO_PLUGIN', 9); + +// Export resources. +define('LINE_BREAK', "\n"); From fd8d233cf88cf2195f1242bdd3f4528de07527c4 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 24 Jan 2024 13:28:43 +0100 Subject: [PATCH 077/233] #12460 fixed deprecated --- pandora_console/godmode/agentes/module_manager_editor.php | 2 +- .../godmode/agentes/module_manager_editor_plugin.php | 7 ++++++- pandora_console/godmode/wizards/HostDevices.class.php | 2 +- pandora_console/include/class/Diagnostics.class.php | 7 +++++++ pandora_console/include/class/NetworkMap.class.php | 2 +- pandora_console/include/functions.php | 6 +++++- pandora_console/include/functions_io.php | 4 +--- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 130f31c79d..543d241fc9 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -150,7 +150,7 @@ if (is_ajax()) { $component = db_get_row('tlocal_component', 'id', $id_component); foreach ($component as $index => $element) { $component[$index] = html_entity_decode( - $element, + (isset($element) === true) ? $element : '', ENT_QUOTES, 'UTF-8' ); diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 9b5d98c27d..abbbc4d9c1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -60,7 +60,12 @@ $data[1] = html_print_select_from_sql( $disabledBecauseInPolicy ); // Store the macros in base64 into a hidden control to move between pages -$data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); +$data[1] .= html_print_input_hidden( + 'macros', + (isset($macros) === true) ? base64_encode($macros) : '', + true +); + $table_simple->colspan['plugin_1'][2] = 2; if (!empty($id_plugin)) { diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 4f0043f038..08a47b12f8 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1109,7 +1109,7 @@ class HostDevices extends Wizard 'return' => true, 'selected' => explode( ',', - $this->task['id_network_profile'] + (isset($this->task['id_network_profile']) === true) ? $this->task['id_network_profile'] : '' ), 'nothing_value' => 0, 'nothing' => __('None'), diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 9d4a3b2901..898d9f5af9 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -54,6 +54,13 @@ class Diagnostics extends Wizard */ public $pdf; + /** + * Product name. + * + * @var string + */ + public $product_name; + /** * Constructor. diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 184e830e9c..3a8b947926 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -706,7 +706,7 @@ class NetworkMap */ public function setNodes($nodes) { - $this->nodes = $nodes; + $this->nodes = (array) $nodes; } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7c1638f8fa..421d3e7725 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2925,6 +2925,10 @@ function delete_dir($dir) */ function is_image_data($data) { + if (isset($data) === false) { + return false; + } + return (substr($data, 0, 10) == 'data:image'); } @@ -2947,7 +2951,7 @@ function is_snapshot_data($data) */ function is_text_to_black_string($data) { - if (is_image_data($data)) { + if (isset($data) === false || is_image_data($data)) { return false; } diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 445504b11c..dd8dd1f6dc 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -561,10 +561,8 @@ function io_output_password($password, $wrappedBy='') ] ); - $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; - // If password already decrypt return same password. - $output = (empty($plaintext) === true) ? $password : $plaintext; + $output = (empty($plaintext) === true || $plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; return sprintf( '%s%s%s', From 8bbfa2803f86b3282d55183f0233eeba0891160a Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 25 Jan 2024 01:00:29 +0100 Subject: [PATCH 078/233] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el8.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el9.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index da5db137f5..b57934fc50 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240124 +Version: 7.0NG.775-240125 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 4617d8e745..cc3cf84853 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.775-240124" +pandora_version="7.0NG.775-240125" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 4ec522db43..b0f1c9f54c 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.775'; -use constant AGENT_BUILD => '240124'; +use constant AGENT_BUILD => '240125'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 2786cafe56..516ef3ec99 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.775 -%define release 240124 +%define release 240125 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 92cb781d5a..c0ff5e3f44 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.775 -%define release 240124 +%define release 240125 %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 56dc5c9c0c..14870a78ed 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.775 -%define release 240124 +%define release 240125 %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 858147650c..1e88ca4c7e 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.775 -%define release 240124 +%define release 240125 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 deff8bc50f..515dc4ea4d 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.775 -%define release 240124 +%define release 240125 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 9a94ff4cb4..20f63af782 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240124" +PI_BUILD="240125" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index dd51dcf708..81661ca1bf 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240124} +{240125} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 22f49347f0..91adc36bc7 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.775 Build 240124") +#define PANDORA_VERSION ("7.0NG.775 Build 240125") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index cf88101947..5ac5a2e47f 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.775(Build 240124))" + VALUE "ProductVersion", "(7.0NG.775(Build 240125))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d23840e972..971ba8b024 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240124 +Version: 7.0NG.775-240125 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 4c11ce1bce..6e7853f74f 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.775-240124" +pandora_version="7.0NG.775-240125" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 60dd8bf9a1..0cbf1c15e8 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 = 'PC240124'; +$build_version = 'PC240125'; $pandora_version = 'v7.0NG.775'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ab50a8ec91..1e2252fbae 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index d76f4f73f5..829d5ae091 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240124 +%define release 240125 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index fdafb2797e..c697aa9c8f 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240124 +%define release 240125 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 2202c82563..03fa6a84d0 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240124" +PI_BUILD="240125" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 47f6f469ab..66e75586cb 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.775 Build 240124"; +my $version = "7.0NG.775 Build 240125"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 7801143234..b154b38ada 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.775 Build 240124"; +my $version = "7.0NG.775 Build 240125"; # save program name for logging my $progname = basename($0); From 7b988664686a47e747292a83ad88cc35634db67b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 25 Jan 2024 10:38:24 +0100 Subject: [PATCH 079/233] #12681 fixed decimals in df_percent_used --- pandora_agents/win32/bin/util/df_percent_used.vbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_agents/win32/bin/util/df_percent_used.vbs b/pandora_agents/win32/bin/util/df_percent_used.vbs index 8499e8694f..090abf8ce7 100644 --- a/pandora_agents/win32/bin/util/df_percent_used.vbs +++ b/pandora_agents/win32/bin/util/df_percent_used.vbs @@ -25,7 +25,7 @@ For Each objItem in colItems If argc = 0 Or argv.Exists(objItem.Name) Then ' Include only harddrivers (type 3) If (objItem.FreeSpace <> "") AND (objItem.DriveType =3) Then - Percent = round (100 - (objItem.FreeSpace / objItem.Size) * 100, 2) + Percent = round (100 - (objItem.FreeSpace / objItem.Size) * 100, 0) Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine " " Wscript.StdOut.WriteLine " " From 874bd04aa82c4c9b25ef9358b4fa3f7183329f89 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 25 Jan 2024 15:23:48 +0100 Subject: [PATCH 080/233] #11799 hide interval for broker agents --- pandora_agents/pc/pandora_agent | 2 +- pandora_agents/unix/pandora_agent | 2 +- .../godmode/agentes/agent_manager.php | 45 ++++++++++++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index 88f78e31ac..50e901f0ce 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -585,7 +585,7 @@ sub write_broker_conf($){ # Change the agent name if ($line =~ m/^\s*#*\s*agent_name\s+/) { - $line = "agent_name $broker_agent\n"; + $line = "agent_name $broker_agent\n#broker active\n"; } # Change the logfile elsif ($line =~ m/^\s*logfile\s+(.*)/) { diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index b0f1c9f54c..62aa2e5040 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1860,7 +1860,7 @@ sub write_broker_conf($){ # Change the agent name if ($line =~ m/^\s*#*\s*agent_name\s+/) { - $line = "agent_name $broker_agent\n"; + $line = "agent_name $broker_agent\n#broker active\n"; } # Change the logfile elsif ($line =~ m/^\s*logfile\s+(.*)/) { diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 4e62337547..28b8da32d3 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -499,22 +499,37 @@ $tableAgent->data['primary_group'][0] .= ui_print_group_icon( 'after_input_icon' ); $tableAgent->data['primary_group'][0] .= ''; +// CHECK BROKER FOR SHOW INTERVAL. +enterprise_include('include/functions_config_agents.php'); +// Read configuration file. +$files = config_agents_get_agent_config_filenames($id_agente); +$file_name = $files['conf']; +$agent_config = file_get_contents($file_name); +$encoding = 'UTF-8'; +$agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding); +if ($agent_config_utf8 !== false) { + $agent_config = $agent_config_utf8; +} -$tableAgent->data['caption_interval'][0] = __('Interval'); -// $tableAgent->rowstyle['interval'] = 'width: 260px'; -$tableAgent->rowclass['interval'] = 'w540px'; -$tableAgent->data['interval'][0] = html_print_extended_select_for_time( - 'intervalo', - $intervalo, - '', - '', - '0', - 10, - true, - false, - true, - 'w33p' -); +$broker = str_contains($agent_config, '#broker active'); + +if ($broker === false) { + $tableAgent->data['caption_interval'][0] = __('Interval'); + // $tableAgent->rowstyle['interval'] = 'width: 260px'; + $tableAgent->rowclass['interval'] = 'w540px'; + $tableAgent->data['interval'][0] = html_print_extended_select_for_time( + 'intervalo', + $intervalo, + '', + '', + '0', + 10, + true, + false, + true, + 'w33p' + ); +} if ($intervalo < SECONDS_5MINUTES) { $tableAgent->data['interval'][0] .= clippy_context_help('interval_agent_min'); From cdd9af51080abfaec2be7b6c32a6e446a1203721 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 25 Jan 2024 15:25:08 +0100 Subject: [PATCH 081/233] #11799 hide interval for broker agents --- .../godmode/agentes/agent_manager.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 28b8da32d3..80a480dd12 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -499,19 +499,23 @@ $tableAgent->data['primary_group'][0] .= ui_print_group_icon( 'after_input_icon' ); $tableAgent->data['primary_group'][0] .= ''; -// CHECK BROKER FOR SHOW INTERVAL. -enterprise_include('include/functions_config_agents.php'); -// Read configuration file. -$files = config_agents_get_agent_config_filenames($id_agente); -$file_name = $files['conf']; -$agent_config = file_get_contents($file_name); -$encoding = 'UTF-8'; -$agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding); -if ($agent_config_utf8 !== false) { - $agent_config = $agent_config_utf8; -} -$broker = str_contains($agent_config, '#broker active'); +$broker = false; +if (enterprise_installed()) { + // CHECK BROKER FOR SHOW INTERVAL. + enterprise_include('include/functions_config_agents.php'); + // Read configuration file. + $files = config_agents_get_agent_config_filenames($id_agente); + $file_name = $files['conf']; + $agent_config = file_get_contents($file_name); + $encoding = 'UTF-8'; + $agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding); + if ($agent_config_utf8 !== false) { + $agent_config = $agent_config_utf8; + } + + $broker = str_contains($agent_config, '#broker active'); +} if ($broker === false) { $tableAgent->data['caption_interval'][0] = __('Interval'); From 18cb14bec6c45dd897cb5ca5598628b780d488b0 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 25 Jan 2024 16:03:48 +0100 Subject: [PATCH 082/233] minor fixes --- pandora_console/include/functions_netflow.php | 25 +++++++++++++++---- .../include/functions_reporting.php | 14 +++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 770314f507..5fc9e6b32f 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1553,8 +1553,7 @@ function netflow_draw_item( if ($output === 'HTML' || $output === 'PDF') { $html = ''; - - if ($show_graph === true && $max_aggregates <= 10) { + if ($show_graph === true) { $labels = array_map( function ($conn) { return __('% Traffic').' '.$conn['ip_src'].' - '.$conn['ip_dst']; @@ -1572,18 +1571,34 @@ function netflow_draw_item( $graph_output = pie_graph( $pie_data, [ - 'legend' => [ + 'width' => 200, + 'height' => 200, + 'ttl' => ($output === 'PDF') ? 2 : 1, + 'dataLabel' => ['display' => 'auto'], + 'layout' => [ + 'padding' => [ + 'top' => 15, + 'bottom' => 15, + ], + ], + 'legend' => [ 'display' => true, 'position' => 'right', 'align' => 'center', ], - 'labels' => $labels, + 'labels' => $labels, ] ); $html .= ''; $html .= "'; $html .= ''; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2b8a0f01ef..8cc539879c 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7036,11 +7036,15 @@ function reporting_netflow( break; } - $return['subtitle'] = netflow_generate_subtitle_report( - $filter['aggregate'], - $content['top_n'], - $type_netflow - ); + if ($extended === true) { + $return['subtitle'] = __('InBound/Outbound traffic per SrcIP/DestIP'); + } else { + $return['subtitle'] = netflow_generate_subtitle_report( + $filter['aggregate'], + $content['top_n'], + $type_netflow + ); + } return reporting_check_structure_content($return); } From cf500b68438fb1f90fcdcdc1f6b003afdd2d0f37 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 25 Jan 2024 16:41:58 +0100 Subject: [PATCH 083/233] #12681 added decimals in module module_freepercentdisk --- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/win32/bin/util/df_percent_used.vbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 4ec522db43..956fb984d8 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -3132,7 +3132,7 @@ sub module_freepercentdisk ($) { return () unless defined ($Parts{$module->{'params'}}) and defined ($Parts{$module->{'params'}}{'avail'}); - my $availp = sprintf("%d", $Parts{$module->{'params'}}{'avail'} * 100 / $Parts{$module->{'params'}}{'total'}); + my $availp = sprintf("%.2f", $Parts{$module->{'params'}}{'avail'} * 100 / $Parts{$module->{'params'}}{'total'}); return ($availp); } diff --git a/pandora_agents/win32/bin/util/df_percent_used.vbs b/pandora_agents/win32/bin/util/df_percent_used.vbs index 090abf8ce7..8499e8694f 100644 --- a/pandora_agents/win32/bin/util/df_percent_used.vbs +++ b/pandora_agents/win32/bin/util/df_percent_used.vbs @@ -25,7 +25,7 @@ For Each objItem in colItems If argc = 0 Or argv.Exists(objItem.Name) Then ' Include only harddrivers (type 3) If (objItem.FreeSpace <> "") AND (objItem.DriveType =3) Then - Percent = round (100 - (objItem.FreeSpace / objItem.Size) * 100, 0) + Percent = round (100 - (objItem.FreeSpace / objItem.Size) * 100, 2) Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine " " Wscript.StdOut.WriteLine " " From 1c094cd2193b8ba1aebc9929c14f4cd410e47f54 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 25 Jan 2024 16:58:21 +0100 Subject: [PATCH 084/233] #12802 fix date error --- pandora_console/extensions/insert_data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index d06ff90118..98e8886733 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -223,7 +223,7 @@ function mainInsertData() '', empty($agent_id) ); - $table->data[1][2] = html_print_input_text('data', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); + $table->data[1][2] = html_print_input_text('date', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); $table->data[1][2] .= ' '; $table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true); @@ -284,7 +284,7 @@ function mainInsertData() currentText: '', closeText: ''}); - $('#text-data').datepicker ({ + $('#text-date').datepicker ({ dateFormat: '', changeMonth: true, changeYear: true, From 31312eaa53083e9c7dac7a9803ed071f914a73c3 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 25 Jan 2024 17:19:05 +0100 Subject: [PATCH 085/233] visual fix --- pandora_console/godmode/events/event_responses.editor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/events/event_responses.editor.php b/pandora_console/godmode/events/event_responses.editor.php index 477aa70e85..52d5a48ad1 100644 --- a/pandora_console/godmode/events/event_responses.editor.php +++ b/pandora_console/godmode/events/event_responses.editor.php @@ -292,7 +292,12 @@ $data[0] = html_print_label_input_block( '', '', '', - true + true, + false, + true, + 'w100p', + false, + 'width: 100%' ).'' ); From 823e2b93aea8ef2f52cd6a480631c91d9aabbf24 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 25 Jan 2024 14:10:59 -0600 Subject: [PATCH 086/233] Add Powershell module --- pandora_agents/win32/Makefile.am | 4 +- .../win32/modules/pandora_module.cc | 2 + pandora_agents/win32/modules/pandora_module.h | 40 ++++---- .../modules/pandora_module_exec_powershell.cc | 91 +++++++++++++++++++ .../modules/pandora_module_exec_powershell.h | 43 +++++++++ .../win32/modules/pandora_module_factory.cc | 18 +++- .../win32/modules/pandora_module_list.cc | 7 ++ 7 files changed, 183 insertions(+), 22 deletions(-) create mode 100644 pandora_agents/win32/modules/pandora_module_exec_powershell.cc create mode 100644 pandora_agents/win32/modules/pandora_module_exec_powershell.h diff --git a/pandora_agents/win32/Makefile.am b/pandora_agents/win32/Makefile.am index 4641081570..94e77312c4 100644 --- a/pandora_agents/win32/Makefile.am +++ b/pandora_agents/win32/Makefile.am @@ -1,9 +1,9 @@ bin_PROGRAMS = PandoraAgent if DEBUG -PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp +PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp PandoraAgent_CXXFLAGS=-g -O0 else -PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc +PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc PandoraAgent_CXXFLAGS=-O2 endif diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index 2df46ad9d5..69a801e96b 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -236,6 +236,8 @@ Module_Kind Pandora_Module::parseModuleKindFromString (string kind) { if (kind == module_exec_str) { return MODULE_EXEC; + } else if (kind == module_exec_powershell_str) { + return MODULE_EXEC_POWERSHELL; } else if (kind == module_proc_str) { return MODULE_PROC; } else if (kind == module_service_str) { diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 111fc79c79..bb19b266b2 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -94,7 +94,8 @@ namespace Pandora_Modules { MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */ MODULE_PLUGIN, /**< Plugin */ MODULE_PING, /**< Ping module */ - MODULE_SNMPGET /**< SNMP get module */ + MODULE_SNMPGET, /**< SNMP get module */ + MODULE_EXEC_POWERSHELL /**< The module run a custom powershell command */ } Module_Kind; /** @@ -109,24 +110,25 @@ namespace Pandora_Modules { regex_t regexp; } Condition; - const string module_exec_str = "module_exec"; - const string module_proc_str = "module_proc"; - const string module_service_str = "module_service"; - const string module_freedisk_str = "module_freedisk"; - const string module_freedisk_percent_str = "module_freedisk_percent"; - const string module_freememory_str = "module_freememory"; - const string module_freememory_percent_str = "module_freememory_percent"; - const string module_cpuusage_str = "module_cpuusage"; - const string module_inventory_str = "module_inventory"; - const string module_logevent_str = "module_logevent"; - const string module_logchannel_str = "module_logchannel"; - const string module_wmiquery_str = "module_wmiquery"; - const string module_perfcounter_str = "module_perfcounter"; - const string module_tcpcheck_str = "module_tcpcheck"; - const string module_regexp_str = "module_regexp"; - const string module_plugin_str = "module_plugin"; - const string module_ping_str = "module_ping"; - const string module_snmpget_str = "module_snmpget"; + const string module_exec_str = "module_exec"; + const string module_proc_str = "module_proc"; + const string module_service_str = "module_service"; + const string module_freedisk_str = "module_freedisk"; + const string module_freedisk_percent_str = "module_freedisk_percent"; + const string module_freememory_str = "module_freememory"; + const string module_freememory_percent_str = "module_freememory_percent"; + const string module_cpuusage_str = "module_cpuusage"; + const string module_inventory_str = "module_inventory"; + const string module_logevent_str = "module_logevent"; + const string module_logchannel_str = "module_logchannel"; + const string module_wmiquery_str = "module_wmiquery"; + const string module_perfcounter_str = "module_perfcounter"; + const string module_tcpcheck_str = "module_tcpcheck"; + const string module_regexp_str = "module_regexp"; + const string module_plugin_str = "module_plugin"; + const string module_ping_str = "module_ping"; + const string module_snmpget_str = "module_snmpget"; + const string module_exec_powershell_str = "module_exec_powershell"; /** * Pandora module super-class exception. diff --git a/pandora_agents/win32/modules/pandora_module_exec_powershell.cc b/pandora_agents/win32/modules/pandora_module_exec_powershell.cc new file mode 100644 index 0000000000..99d37b7822 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_exec_powershell.cc @@ -0,0 +1,91 @@ +/* Pandora exec module. These modules exec a powershell command. + + Copyright (c) 2006-2023 Pandora FMS. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "pandora_module_exec_powershell.h" +#include "../pandora_strutils.h" + +#include +#include +#include +#include +#include +#include + +#define EXEC_OK 0 +#define EXEC_ERR -1 +#define BUFSIZE 4096 + +using namespace Pandora; +using namespace Pandora_Strutils; +using namespace Pandora_Modules; + +/** + * Creates a Pandora_Module_Exec_Powershell object. + * + * @param name Module name + * @param exec Command to be executed. + */ +Pandora_Module_Exec_Powershell::Pandora_Module_Exec_Powershell(string name, string exec) + : Pandora_Module (name) { + + string escaped_exec; + + for (char c : exec) { + if (c == '"' || c == '\\') { + escaped_exec += '\\'; + } + escaped_exec += c; + } + + this->module_exec = "powershell -C \"" + escaped_exec + "\""; + + this->setKind (module_exec_powershell_str); +} + +void Pandora_Module_Exec_Powershell::run() { + string output_result; + + this->has_output = false; + + FILE* pipe = popen(this->module_exec.c_str(), "r"); + if (!pipe) { + pandoraLog ("Error while executing command.", GetLastError ()); + return; + } + + char buffer[BUFSIZE]; + while (fgets(buffer, BUFSIZE, pipe) != NULL) { + output_result += buffer; + } + + int result = pclose(pipe); + + if (result == EXEC_ERR) { + pandoraLog ("Error while closing command process.", GetLastError ()); + return; + } + + if (result != EXEC_OK) { + pandoraLog ("Error invalid powershell command.", GetLastError ()); + return; + } + + this->has_output = true; + this->setOutput (output_result); +} \ No newline at end of file diff --git a/pandora_agents/win32/modules/pandora_module_exec_powershell.h b/pandora_agents/win32/modules/pandora_module_exec_powershell.h new file mode 100644 index 0000000000..d3c9785c29 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_exec_powershell.h @@ -0,0 +1,43 @@ +/* Pandora exec module. These modules exec a powershell command + + Copyright (c) 2006-2023 Pandora FMS. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef __PANDORA_MODULE_EXEC_POWERWSHELL_H__ +#define __PANDORA_MODULE_EXEC_POWERWSHELL_H__ + +#include "pandora_module.h" + +namespace Pandora_Modules { + /** + * Module to execute a powershell command. + * + * Any custom order that want to be executed can be put in + * the util directory into the Pandora agent path. + */ + class Pandora_Module_Exec_Powershell : public Pandora_Module { + + private: + string module_exec; + + public: + Pandora_Module_Exec_Powershell (string name, string exec); + void run (); + }; +} + +#endif diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index de149293ff..dd71dc2dd8 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -22,6 +22,7 @@ #include "pandora_module_factory.h" #include "pandora_module.h" #include "pandora_module_exec.h" +#include "pandora_module_exec_powershell.h" #include "pandora_module_proc.h" #include "pandora_module_service.h" #include "pandora_module_freedisk.h" @@ -129,6 +130,7 @@ using namespace Pandora_Strutils; #define TOKEN_ALERT_TEMPLATE ("module_alert_template") #define TOKEN_USER_SESSION ("module_user_session ") #define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ") +#define TOKEN_EXEC_POWERSHELL ("module_exec_powershell ") string parseLine (string line, string token) { @@ -158,7 +160,7 @@ Pandora_Module * Pandora_Module_Factory::getModuleFromDefinition (string definition) { list tokens; list::iterator iter; - string module_name, module_type, module_exec; + string module_name, module_type, module_exec, module_exec_powershell; string module_min, module_max, module_description; string module_interval, module_absoluteinterval; string module_proc, module_service; @@ -268,6 +270,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_user_session = ""; macro = ""; module_wait_timeout = ""; + module_exec_powershell = ""; stringtok (tokens, definition, "\n"); @@ -302,6 +305,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_exec == "") { module_exec = parseLine (line, TOKEN_EXEC); } + if (module_exec_powershell == "") { + module_exec_powershell = parseLine (line, TOKEN_EXEC_POWERSHELL); + } if (module_wait_timeout == "") { module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT); } @@ -626,6 +632,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } } + if (module_exec_powershell != "") { + pos_macro = module_exec_powershell.find(macro_name); + if (pos_macro != string::npos){ + module_exec_powershell.replace(pos_macro, macro_name.size(), macro_value); + } + } + if (module_proc != "") { pos_macro = module_proc.find(macro_name); if (pos_macro != string::npos){ @@ -1155,6 +1168,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module->setWaitTimeout (atoi (module_wait_timeout.c_str ())); } + } else if (module_exec_powershell != "") { + module = new Pandora_Module_Exec_Powershell (module_name, module_exec_powershell); + } else if (module_proc != "") { module = new Pandora_Module_Proc (module_name, module_proc); diff --git a/pandora_agents/win32/modules/pandora_module_list.cc b/pandora_agents/win32/modules/pandora_module_list.cc index be5cc32d45..b0612902a3 100644 --- a/pandora_agents/win32/modules/pandora_module_list.cc +++ b/pandora_agents/win32/modules/pandora_module_list.cc @@ -21,6 +21,7 @@ #include "pandora_module_factory.h" #include "pandora_module_list.h" #include "pandora_module_exec.h" +#include "pandora_module_exec_powershell.h" #include "pandora_module_proc.h" #include "pandora_module_service.h" #include "pandora_module_freedisk.h" @@ -235,6 +236,7 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) Pandora_Module_Plugin *module_plugin; Pandora_Module_Ping *module_ping; Pandora_Module_SNMPGet *module_snmpget; + Pandora_Module_Exec_Powershell *module_exec_powershell; module = Pandora_Module_Factory::getModuleFromDefinition (definition); @@ -244,6 +246,11 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) module_exec = (Pandora_Module_Exec *) module; modules->push_back (module_exec); + break; + case MODULE_EXEC_POWERSHELL: + module_exec_powershell = (Pandora_Module_Exec_Powershell *) module; + modules->push_back (module_exec_powershell); + break; case MODULE_PROC: module_proc = (Pandora_Module_Proc *) module; From c5cefb3c13e7f90b95b9f03755dfec0f88cd7941 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 26 Jan 2024 01:00:30 +0100 Subject: [PATCH 087/233] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el8.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el9.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index b57934fc50..c8ee8180a7 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240125 +Version: 7.0NG.775-240126 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 cc3cf84853..fa783cc923 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.775-240125" +pandora_version="7.0NG.775-240126" 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/pandora_agent b/pandora_agents/unix/pandora_agent index b0f1c9f54c..e0f3e5bdc3 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.775'; -use constant AGENT_BUILD => '240125'; +use constant AGENT_BUILD => '240126'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 516ef3ec99..5c05e6110e 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.775 -%define release 240125 +%define release 240126 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 c0ff5e3f44..78383784e9 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.775 -%define release 240125 +%define release 240126 %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 14870a78ed..b21d106a96 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.775 -%define release 240125 +%define release 240126 %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 1e88ca4c7e..7a15966693 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.775 -%define release 240125 +%define release 240126 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 515dc4ea4d..337a0ec5f3 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.775 -%define release 240125 +%define release 240126 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 20f63af782..2f6e9c4d3d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240125" +PI_BUILD="240126" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 81661ca1bf..95fa0dd4a3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240125} +{240126} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 91adc36bc7..f3961807fe 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.775 Build 240125") +#define PANDORA_VERSION ("7.0NG.775 Build 240126") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5ac5a2e47f..1bb160a879 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.775(Build 240125))" + VALUE "ProductVersion", "(7.0NG.775(Build 240126))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 971ba8b024..466722a50b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240125 +Version: 7.0NG.775-240126 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 6e7853f74f..a47efa89c2 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.775-240125" +pandora_version="7.0NG.775-240126" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 0cbf1c15e8..a721e82c12 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 = 'PC240125'; +$build_version = 'PC240126'; $pandora_version = 'v7.0NG.775'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 1e2252fbae..c6329db34e 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 829d5ae091..e7e972a801 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240125 +%define release 240126 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c697aa9c8f..f443bc4b03 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240125 +%define release 240126 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 03fa6a84d0..bc5676b742 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240125" +PI_BUILD="240126" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 66e75586cb..f079a42194 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.775 Build 240125"; +my $version = "7.0NG.775 Build 240126"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b154b38ada..e7921bff4a 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.775 Build 240125"; +my $version = "7.0NG.775 Build 240126"; # save program name for logging my $progname = basename($0); From c07ecff571a86fff706c65290698912beb2fdac7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 26 Jan 2024 08:13:10 +0100 Subject: [PATCH 088/233] #12807 check id_agent for alert view --- .../operation/agentes/alerts_status.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index a4f7c7d81c..68988900bc 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -536,19 +536,21 @@ echo '
'; ui_require_css_file('cluetip', 'include/styles/js/'); ui_require_jquery_file('cluetip'); -$system_higher = false; -$modules_agent = db_get_all_rows_sql(sprintf('SELECT id_agente FROM tagente_modulo WHERE id_agente = %s', $id_agente)); -if (is_array($modules_agent)) { - $all_modules = db_get_all_rows_sql('SELECT id_agente FROM tagente_modulo'); - $all_agents = db_get_all_rows_sql('SELECT id_agente FROM tagente'); - if (is_array($all_modules) && is_array($all_agents)) { - if ((count($all_modules) / count($all_agents)) >= 200) { - $system_higher = true; +if (isset($id_agente)) { + $system_higher = false; + $modules_agent = db_get_all_rows_sql(sprintf('SELECT id_agente FROM tagente_modulo WHERE id_agente = %s', $id_agente)); + if (is_array($modules_agent)) { + $all_modules = db_get_all_rows_sql('SELECT id_agente FROM tagente_modulo'); + $all_agents = db_get_all_rows_sql('SELECT id_agente FROM tagente'); + if (is_array($all_modules) && is_array($all_agents)) { + if ((count($all_modules) / count($all_agents)) >= 200) { + $system_higher = true; + } } } -} -echo '
'.__('Your system has a much higher rate of modules per agent than recommended (200 modules per agent). This implies performance problems in the system, please consider reducing the number of modules in this agent.').'
'; + echo '
'.__('Your system has a much higher rate of modules per agent than recommended (200 modules per agent). This implies performance problems in the system, please consider reducing the number of modules in this agent.').'
'; +} ?> From 65385f36c18eb24ac62613350ffdc19304e712b4 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 26 Jan 2024 09:18:47 +0100 Subject: [PATCH 089/233] fix visual errors in widgets dashboard pandora_enterprise#12267 --- pandora_console/include/functions_ui.php | 6 +++--- .../lib/Dashboard/Widgets/ModulesByStatus.php | 4 ++-- pandora_console/include/styles/dashboards.css | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d6078c56a7..0062b52e70 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4257,15 +4257,15 @@ function ui_print_datatable(array $parameters) // * END JAVASCRIPT. $info_msg_arr = []; $info_msg_arr['message'] = $emptyTable; - $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id; + $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-info-massage datatable-msg-info-'.$table_id; $info_msg_arr_filter = []; $info_msg_arr_filter['message'] = __('Please apply a filter to display the data.'); - $info_msg_arr_filter['div_class'] = 'info_box_container invisible_important datatable-msg-info-filter-'.$table_id; + $info_msg_arr_filter['div_class'] = 'info_box_container invisible_important datatable-info-massage datatable-msg-info-filter-'.$table_id; $spinner = ''; - $info_msg = '
'.ui_print_info_message($info_msg_arr, '', true).'
'; + $info_msg = '
'.ui_print_info_message($info_msg_arr, '', true).'
'; $info_msg_filter = '
'.ui_print_info_message($info_msg_arr_filter, true).'
'; diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index 86a6cde7ed..69c0a36f44 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -521,7 +521,7 @@ class ModulesByStatus extends Widget 'server_name', [ 'text' => 'last_status_change', - 'class' => 'flex-column', + 'class' => '', ], 'estado', ]; @@ -538,7 +538,7 @@ class ModulesByStatus extends Widget 'alias', [ 'text' => 'last_status_change', - 'class' => 'flex-column', + 'class' => '', ], 'estado', ]; diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 8786faa843..00a780be6d 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -977,3 +977,19 @@ input.resize_button { .event-cardboard-widget td { cursor: pointer; } + +.datatable-container-info-massage:not(:has(.invisible_important)) { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; + width: 100%; +} + +.info_box_information.datatable-info-massage.info_box_container + .info_box.info.textodialogo { + display: flex; + width: 100%; + justify-content: center; +} From bba32495a4f8518f92e8e1fa7f4d69f5120ede03 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 26 Jan 2024 10:15:01 +0100 Subject: [PATCH 090/233] fix visual errors in msg umc offline pandora_enterprise#12399 --- .../resources/javascript/umc_offline.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pandora_console/update_manager_client/resources/javascript/umc_offline.js b/pandora_console/update_manager_client/resources/javascript/umc_offline.js index ad2432a306..11e397d996 100644 --- a/pandora_console/update_manager_client/resources/javascript/umc_offline.js +++ b/pandora_console/update_manager_client/resources/javascript/umc_offline.js @@ -428,11 +428,14 @@ function install_package(url, auth, packageId, version, serverUpdate) { var response = d.result; document.getElementById("log_zone").innerText = response.result; - $("#input-progress") - .val(100) - .change(); + if (response.error == undefined || response.error == "") { + $("#input-progress") + .val(100) + .change(); + + $("#result li").removeClass("error"); + } - $("#result li").removeClass("error"); $("#result li") .find("p") .text(response.result); From 139b92441032d69bed35199f7e5a817997113841 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 26 Jan 2024 14:01:32 +0100 Subject: [PATCH 091/233] #12681 added decimals in module windows --- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/win32/windows/pandora_wmi.cc | 6 +++--- pandora_agents/win32/windows/pandora_wmi.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 956fb984d8..4ec522db43 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -3132,7 +3132,7 @@ sub module_freepercentdisk ($) { return () unless defined ($Parts{$module->{'params'}}) and defined ($Parts{$module->{'params'}}{'avail'}); - my $availp = sprintf("%.2f", $Parts{$module->{'params'}}{'avail'} * 100 / $Parts{$module->{'params'}}{'total'}); + my $availp = sprintf("%d", $Parts{$module->{'params'}}{'avail'} * 100 / $Parts{$module->{'params'}}{'total'}); return ($availp); } diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index 7bf1091602..5e382232ae 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -188,7 +188,7 @@ Pandora_Wmi::getDiskFreeSpace (string disk_id) { * @exception Pandora_Wmi_Exception Throwd if an error occured when reading * from WMI database. */ -unsigned long +double Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) { CDhInitialize init; CDispPtr wmi_svc, quickfixes; @@ -202,7 +202,7 @@ Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) { dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc, L".ExecQuery(%T)", query.c_str ())); - + FOR_EACH (quickfix, quickfixes, NULL) { dhGetValue (L"%e", &free_space, quickfix, L".FreeSpace"); @@ -213,7 +213,7 @@ Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) { return 0; } - return (unsigned long) (free_space * 100 / size); + return (free_space * 100 / size); } NEXT_THROW (quickfix); } catch (string errstr) { pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ()); diff --git a/pandora_agents/win32/windows/pandora_wmi.h b/pandora_agents/win32/windows/pandora_wmi.h index 5eeb5d6a90..857b228471 100644 --- a/pandora_agents/win32/windows/pandora_wmi.h +++ b/pandora_agents/win32/windows/pandora_wmi.h @@ -44,7 +44,7 @@ namespace Pandora_Wmi { int isProcessRunning (string process_name); int isServiceRunning (string service_name); unsigned long getDiskFreeSpace (string disk_id); - unsigned long getDiskFreeSpacePercent (string disk_id); + double getDiskFreeSpacePercent (string disk_id); int getCpuUsagePercentage (int cpu_id); long getFreememory (); long getFreememoryPercent (); From babb7bce3895bb955bb752a27176b2376d293dd9 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 26 Jan 2024 15:06:09 +0100 Subject: [PATCH 092/233] #12681 fixed double number parse --- pandora_agents/win32/modules/pandora_module_freedisk_percent.cc | 2 +- pandora_agents/win32/windows/pandora_wmi.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc index c061d4394b..d117b0feca 100755 --- a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc +++ b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc @@ -59,7 +59,7 @@ Pandora_Module_Freedisk_Percent::run () { try { res = Pandora_Wmi::getDiskFreeSpacePercent (this->disk_id); - this->setOutput (longtostr (res)); + this->setOutput (res); } catch (Pandora_Wmi::Pandora_Wmi_Exception e) { this->has_output = false; } diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index 5e382232ae..d0b3f5dc30 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -192,7 +192,7 @@ double Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) { CDhInitialize init; CDispPtr wmi_svc, quickfixes; - double free_space = 0, size = 0; + double free_space = 0, size = 0; string query; query = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\""; From 1b9cd2d36cd225e01a447947ffa1495d2ec97730 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 26 Jan 2024 15:26:29 +0100 Subject: [PATCH 093/233] #12681 fixed double parse --- pandora_agents/win32/modules/pandora_module_freedisk_percent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc index d117b0feca..032810dfc4 100755 --- a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc +++ b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc @@ -59,7 +59,7 @@ Pandora_Module_Freedisk_Percent::run () { try { res = Pandora_Wmi::getDiskFreeSpacePercent (this->disk_id); - this->setOutput (res); + this->setOutput(std::to_string(res)); } catch (Pandora_Wmi::Pandora_Wmi_Exception e) { this->has_output = false; } From b8973ecab49cea55d1bb117d549a8888b610d02b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 09:04:03 +0100 Subject: [PATCH 094/233] #12681 fixed decimals in module freepercent --- pandora_agents/win32/modules/pandora_module_freedisk_percent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc index 032810dfc4..bda0043b0d 100755 --- a/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc +++ b/pandora_agents/win32/modules/pandora_module_freedisk_percent.cc @@ -48,7 +48,7 @@ Pandora_Module_Freedisk_Percent::Pandora_Module_Freedisk_Percent (string name, s void Pandora_Module_Freedisk_Percent::run () { - long res; + double res; try { Pandora_Module::run (); From f01902903c4e006765c9ad3541ee4fb7f1bbb115 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 13:38:29 +0100 Subject: [PATCH 095/233] #12789 fixed regex in event table --- .../include/javascript/datatablesFunction.js | 16 +++++++++- pandora_console/operation/events/events.php | 31 ++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/javascript/datatablesFunction.js b/pandora_console/include/javascript/datatablesFunction.js index b517830ce9..dae44dd6b1 100644 --- a/pandora_console/include/javascript/datatablesFunction.js +++ b/pandora_console/include/javascript/datatablesFunction.js @@ -1,3 +1,5 @@ +/* global $ */ + var dt = dt; var config = config; @@ -141,6 +143,8 @@ if (dt.no_move_elements_to_action === true) { noMoveElementsToAction = true; } +var showAlwaysPagination = false; + $(document).ready(function() { function checkPages() { if (dt_table.page.info().pages > 1) { @@ -253,7 +257,11 @@ $(document).ready(function() { $("div.pagination-child-div").hide(); $("div.dataTables_info").hide(); $(`#${dt.id}_wrapper`).hide(); - $(`.action_buttons_right_content .pagination-child-div`).hide(); + if (showAlwaysPagination) { + $(`.action_buttons_right_content .pagination-child-div`).show(); + } else { + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } } else { $(`.datatable-msg-info-${dt.id}`).hide(); $(`table#${dt.id}`).show(); @@ -283,6 +291,12 @@ $(document).ready(function() { $(`#${dt.form_id}_loading`).remove(); } + if (json.showAlwaysPagination) { + showAlwaysPagination = true; + } else { + showAlwaysPagination = false; + } + if (json.error) { console.error(json.error); $(`#error-${dt.id}`).html(json.error); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c9962483f5..1086b8f908 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1229,26 +1229,28 @@ if (is_ajax() === true) { } } - $no_return = false; + $regex_validation = false; if (empty($tmp) === false && $regex !== '') { - $regex_validation = false; foreach (json_decode(json_encode($tmp), true) as $key => $field) { + if ($key === 'b64') { + continue; + } + + $field = strip_tags($field); + if (preg_match('/'.$regex.'/', $field)) { $regex_validation = true; } } - if ($regex_validation === false) { - $no_return = true; + if ($regex_validation === true) { + $carry[] = $tmp; } + } else { + $carry[] = $tmp; } - if ($no_return === false) { - $carry[] = $tmp; - return $carry; - } else { - return; - } + return $carry; } ); } @@ -1256,10 +1258,11 @@ if (is_ajax() === true) { // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ - 'data' => ($data ?? []), - 'buffers' => $buffers, - 'recordsTotal' => $count, - 'recordsFiltered' => $count, + 'data' => ($data ?? []), + 'buffers' => $buffers, + 'recordsTotal' => $count, + 'recordsFiltered' => $count, + 'showAlwaysPagination' => (empty($regex) === false) ? true : false, ] ); } catch (Exception $e) { From 1738a06cf20ce34c2f298c16e508ea254951b4bb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 13:42:09 +0100 Subject: [PATCH 096/233] #12789 added tip in regex search --- pandora_console/operation/events/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 1086b8f908..e99ac14fca 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2109,7 +2109,7 @@ $in .= $data.''; $inputs[] = $in; // REGEX search datatable. -$in = '
'; +$in = '
'; $in .= html_print_input_text('regex', $regex, '', '', 255, true); $in .= '
'; $inputs[] = $in; From 22598b4bc26f08bdba5e5b019da31a99081b156a Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 17:31:19 +0100 Subject: [PATCH 097/233] #12460 fixed deprecated --- pandora_console/include/ajax/heatmap.ajax.php | 1 + .../include/class/OrderInterpreter.class.php | 7 +++++++ .../include/functions_forecast.php | 2 +- .../include/lib/Dashboard/Manager.php | 14 +++++++++++++ .../include/lib/Dashboard/Widget.php | 21 +++++++++++++++++++ .../lib/Dashboard/Widgets/AgentHive.php | 2 +- .../lib/Dashboard/Widgets/DataMatrix.php | 7 +++++++ .../lib/Dashboard/Widgets/ModulesByStatus.php | 7 +++++++ .../lib/Dashboard/Widgets/agent_module.php | 2 +- .../lib/Dashboard/Widgets/events_list.php | 14 +++++++++++++ .../include/lib/Dashboard/Widgets/heatmap.php | 6 +++--- pandora_console/views/dashboard/cell.php | 7 ++++++- 12 files changed, 83 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/ajax/heatmap.ajax.php b/pandora_console/include/ajax/heatmap.ajax.php index 71020ad67f..83c7226388 100644 --- a/pandora_console/include/ajax/heatmap.ajax.php +++ b/pandora_console/include/ajax/heatmap.ajax.php @@ -250,6 +250,7 @@ if (is_ajax() === true) { if ($getInfo === true) { enterprise_include_once('include/functions_agents.php'); + include_once $config['homedir'].'/include/functions_graph.php'; $id = get_parameter('id', 0); $id_server = get_parameter('id_server', 0); if (empty($id_server) === false) { diff --git a/pandora_console/include/class/OrderInterpreter.class.php b/pandora_console/include/class/OrderInterpreter.class.php index d41fbbf837..b96ad6e510 100644 --- a/pandora_console/include/class/OrderInterpreter.class.php +++ b/pandora_console/include/class/OrderInterpreter.class.php @@ -52,6 +52,13 @@ class OrderInterpreter extends Wizard */ public $ajaxController; + /** + * Pages menu + * + * @var array + */ + public $pages_menu; + /** * Generates a JSON error. diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 540bbf7174..1f0d1e59d9 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -100,7 +100,7 @@ function forecast_projection_graph( $data[0] = ''; $data[1] = $cont; - $data[2] = date($config['date_format'], $row[0]); + $data[2] = date($config['date_format'], (int) $row[0]); $data[3] = $row[0]; $data[4] = $row[1]; $data[5] = ($row[0] * $row[1]); diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 670487081d..c5b75dcb4d 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -167,6 +167,20 @@ class Manager implements PublicLogin */ private $duplicateCellId; + /** + * Url + * + * @var string + */ + public $url; + + /** + * Widget + * + * @var Widget + */ + public $cWidget; + /** * Allowed methods to be called using AJAX request. * diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 5746bdb142..f8079571c4 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -65,6 +65,27 @@ class Widget */ private $dateTo; + /** + * Data cell + * + * @var array + */ + public $dataCell; + + /** + * Overflow scrollbar. + * + * @var boolean + */ + public $overflow_scrollbars; + + /** + * Position + * + * @var array + */ + public $position; + /** * Contructor widget. diff --git a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php index 0e426ed08a..b393f786ec 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php +++ b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php @@ -226,7 +226,7 @@ class AgentHive extends Widget 'name' => 'groups[]', 'returnAllGroup' => false, 'privilege' => 'AR', - 'selected' => explode(',', $values['groups'][0]), + 'selected' => (isset($values['groups'][0]) === true) ? explode(',', $values['groups'][0]) : [], 'return' => true, 'multiple' => true, 'required' => true, diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php index 770a3152fe..337f33364e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php +++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php @@ -117,6 +117,13 @@ class DataMatrix extends Widget */ protected $cellId; + /** + * Position + * + * @var array + */ + public $size; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index e490135734..767410c25b 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -115,6 +115,13 @@ class ModulesByStatus extends Widget */ protected $cellId; + /** + * Size + * + * @var array + */ + public $size; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index 56ab854375..f5c4ff5a96 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -355,7 +355,7 @@ class AgentModuleWidget extends Widget */ public function getIdCacheAgent($id_agents) { - $target_agents = explode(',', $id_agents); + $target_agents = explode(',', ($id_agents ?? '')); $cache_id_agents = []; foreach ($target_agents as $agent_id) { if (str_contains($agent_id, '|') === false) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index a50cab93e4..beb7a92b5f 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -111,6 +111,20 @@ class EventsListWidget extends Widget */ protected $publicLink; + /** + * Overflow scrollbar. + * + * @var boolean + */ + public $overflow_scrollbars; + + /** + * Position + * + * @var array + */ + public $position; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php index e199a80ad8..ada804bedb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -271,7 +271,7 @@ class HeatmapWidget extends Widget 'name' => 'groups[]', 'returnAllGroup' => true, 'privilege' => 'AR', - 'selected' => explode(',', $values['groups'][0]), + 'selected' => (isset($values['groups'][0]) === true) ? explode(',', $values['groups'][0]) : [], 'return' => true, 'multiple' => true, ], @@ -305,7 +305,7 @@ class HeatmapWidget extends Widget 'type' => 'select', 'fields' => $tags, 'name' => 'tags[]', - 'selected' => explode(',', $values['tags'][0]), + 'selected' => (isset($values['tags'][0]) === true) ? explode(',', $values['tags'][0]) : [], 'return' => true, 'multiple' => true, ], @@ -332,7 +332,7 @@ class HeatmapWidget extends Widget 'type' => 'select', 'fields' => $module_groups, 'name' => 'module_groups[]', - 'selected' => explode(',', $values['module_groups'][0]), + 'selected' => (isset($values['module_groups'][0]) === true) ? explode(',', $values['module_groups'][0]) : [], 'return' => true, 'multiple' => true, 'nothing' => __('Not assigned'), diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index 5b4e7f311e..910e7a114b 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -34,7 +34,12 @@ if ($redraw === false) { $output .= '
'; $output .= '
'; -$options = json_decode($cellData['options'], true); +if (isset($cellData['options']) === true) { + $options = json_decode($cellData['options'], true); +} else { + $options = []; +} + if ($cellData['id_widget'] !== '0') { $output .= $options['title']; } else { From e07d89883f1ba7d667c7370bf2228c80d8e75ee9 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 29 Jan 2024 17:38:01 +0100 Subject: [PATCH 098/233] #12687 Added import/export prd 3 --- .../resources/resources_export_import.php | 36 +- pandora_console/include/class/Prd.class.php | 1278 ++++++++++++++++- 2 files changed, 1275 insertions(+), 39 deletions(-) diff --git a/pandora_console/godmode/resources/resources_export_import.php b/pandora_console/godmode/resources/resources_export_import.php index 146784f2e4..d1dcfc2123 100644 --- a/pandora_console/godmode/resources/resources_export_import.php +++ b/pandora_console/godmode/resources/resources_export_import.php @@ -43,6 +43,21 @@ if (check_acl($config['id_user'], 0, 'PM') === false) { require_once $config['homedir'].'/include/class/Prd.class.php'; +// Instance of the prd class. +$prd = new Prd(); + +$msg = ''; +if (isset($_FILES['resource_import']) === true) { + $data = parse_ini_file($_FILES['resource_import']['tmp_name'], true); + if ($data !== false) { + $msg[] = $prd->importPrd($data); + } else { + $msg[] = 'Esto es una prueba'; + } +} + +$msg = json_encode($msg); + $table = new stdClass(); $table->id = 'import_data_table'; $table->class = 'databox filter-table-adv'; @@ -56,12 +71,17 @@ $table->data[0][0] = html_print_label_input_block( html_print_input_file('resource_import', true) ); -$table->data[0][1] = html_print_label_input_block( - __('Group filter'), - html_print_select_groups(false, 'AW', true, 'group', '', '', __('All'), 0, true) +$table->data[0][0] .= html_print_submit_button( + __('Import resource'), + 'upload', + false, + [], + true ); +echo '
'; html_print_table($table); +echo ''; $table = new stdClass(); $table->id = 'export_data_table'; @@ -73,9 +93,6 @@ $table->size = []; $table->size[0] = '50%'; $table->size[1] = '50%'; -// Instance of the prd class. -$prd = new Prd(); - $export_type = $prd->getTypesPrd(); $table->data[0][0] = html_print_label_input_block( @@ -109,6 +126,12 @@ html_print_table($table); ?>
"; - $html .= $graph_output; + + if ($output === 'PDF') { + $html .= ''; + } else { + $html .= $graph_output; + } + $html .= '
'; - echo ''; - echo "'; - echo ''; - echo "'; - echo '
"; - echo ''.__('Group filter: ').''; - html_print_select_groups(false, 'AW', true, 'group'); - echo '"; - echo '
';*/ - - if (isset($_FILES['resource_upload']['tmp_name']) === false) { - return; - } - - $xml = simplexml_load_file($_FILES['resource_upload']['tmp_name'], null, LIBXML_NOCDATA); - - if ($xml === false) { - ui_print_error_message( - __('Error uploading resource. Check if the selected file is a valid resource template in .ptr format') - ); - } else { - process_upload_xml($xml); - } -} - - -extensions_add_godmode_menu_option(__('Resource registration'), 'PM', 'gagente', '', 'v1r1'); -extensions_add_godmode_function('resource_registration_extension_main'); diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index f3eada8070..b3fbea46dd 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1736,3 +1736,5 @@ extensions/files_repo/sql/files_repo.oracle.sql extensions/files_repo/sql/files_repo.postgreSQL.sql extensions/files_repo/sql/files_repo.sql extensions/files_repo +extensions/resource_exportation.php +extensions/resource_registration.php diff --git a/pandora_console/godmode/resources/resources_export_import.php b/pandora_console/godmode/resources/resources_export_import.php index b7fc23704a..9fe4eb2852 100644 --- a/pandora_console/godmode/resources/resources_export_import.php +++ b/pandora_console/godmode/resources/resources_export_import.php @@ -42,6 +42,7 @@ if (check_acl($config['id_user'], 0, 'PM') === false) { } require_once $config['homedir'].'/include/class/Prd.class.php'; +$msg = ''; // Instance of the prd class. $prd = new Prd(); @@ -50,11 +51,17 @@ if (isset($_FILES['resource_import']) === true) { $data = parse_ini_file($_FILES['resource_import']['tmp_name'], true); if ($data !== false) { $msg = $prd->importPrd($data); + $array_msg = []; + foreach ($msg['items'] as $key => $value) { + $array_msg[$value[0]][key($value[1])][$value[1][key($value[1])]] = $value[1][key($value[1])]; + } + + $msg['items'] = $array_msg; } else { $msg = [ 'status' => false, - 'items' => [], - 'errors' => ['Unexpected error: Unable to parse PRD file.'] + 'items' => [], + 'errors' => ['Unexpected error: Unable to parse PRD file.'], ]; } } @@ -130,10 +137,48 @@ html_print_table($table); ?> \ No newline at end of file + diff --git a/pandora_console/include/ajax/resources.ajax.php b/pandora_console/include/ajax/resources.ajax.php index 379a499407..7035655620 100644 --- a/pandora_console/include/ajax/resources.ajax.php +++ b/pandora_console/include/ajax/resources.ajax.php @@ -69,10 +69,11 @@ if ((bool) is_ajax() === true) { $data = $prd->exportPrd($type, $value, $name); - $return = ''; + $return = []; if (empty($data) === false) { - $filename = $type.'-'.date('Ymd').'-'.date('His').'.prd'; + $filename = uniqid().'.prd'; + $filename_download = date('YmdHis').'-'.$type.'-'.$name.'.prd'; $file = $config['attachment_store'].'/'.$filename; $file_pointer = fopen($file, 'a'); @@ -80,18 +81,19 @@ if ((bool) is_ajax() === true) { $write = fwrite($file_pointer, $data); if ($write === false) { - $return = -2; + $return['error'] = -2; } else { - $return = $filename; + $return['name'] = $filename; + $return['name_download'] = $filename_download; } fclose($file_pointer); } else { - $return = -1; + $return['error'] = -1; } } - echo $return; + echo json_encode($return); return; } From cf12d9dfd0c53b0c83ad6ed4131a66186173961f Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 7 Feb 2024 16:29:39 +0100 Subject: [PATCH 162/233] #12525 added control for verify default emails in update manager --- .../update_manager_client/views/register.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandora_console/update_manager_client/views/register.php b/pandora_console/update_manager_client/views/register.php index bfc70570f3..666c026b89 100644 --- a/pandora_console/update_manager_client/views/register.php +++ b/pandora_console/update_manager_client/views/register.php @@ -132,6 +132,15 @@ $product_name = get_product_name(); ?> + \ No newline at end of file From bf4786e8fb8b538bdad4a56aa2b9da235afc367c Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 8 Feb 2024 10:22:20 +0100 Subject: [PATCH 169/233] fix toggling log in linux agent --- pandora_console/godmode/agentes/agent_manager.php | 13 +++++++++++++ .../godmode/agentes/configurar_agente.php | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 283610e06a..e6b1d5ca9e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -674,6 +674,19 @@ if (enterprise_installed()) { } } + if ($id_os === '1') { + $modules = $agent_plugin->getModules(); + foreach ($modules as $key => $row) { + if (preg_match('/Syslog/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_log_collector = 0; + } else { + $enable_log_collector = 1; + } + } + } + } + if ($id_os === '9') { $modules = $agent_plugin->getModules(); foreach ($modules as $key => $row) { diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c2e3a2f4f6..a10833081c 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1299,8 +1299,11 @@ if ($update_agent) { } $modules = $agent->getModules(); + foreach ($modules as $key => $row) { - if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) { + if (preg_match('/PandoraAgent_log/', $row['raw']) === 1 + || ($id_os === 1 && preg_match('/Syslog/', $row['raw']) === 1) + ) { if ($enable_log_collector === 1) { if ($row['disabled'] === 1) { $agent->enableModule($row['module_name'], $row); From 86c33119c80a98daa30d2c031bb2b02ce1023620 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 8 Feb 2024 11:32:45 +0100 Subject: [PATCH 170/233] Updated welcome windows styles --- .../include/class/WelcomeWindow.class.php | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 23ccab438d..a610359933 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -920,27 +920,31 @@ class WelcomeWindow extends Wizard echo '
'; + $spacing = ''; + for ($i = 0; $i < 12; $i++) { + $spacing .= ' '; + } + // WMI Credentials - echo html_print_label_input_block( - __('WMI credentials'), - html_print_div( - [ - 'id' => 'wmi-creds', - 'content' => '' - ], - true - ) + echo '
'; + echo ''.__('WMI credentials').''; + echo html_print_div( + [ + 'id' => 'wmi-creds', + 'content' => '' + ], + true ); echo html_print_div( [ 'id' => 'wmi-cred-form', 'hidden' => true, - 'style' => 'margin: 3px; display: flex; align-items: center;', + 'style' => 'margin: 10px; display: flex; align-items: center;', 'content' => html_print_div( [ 'id' => 'wmi-cred-user-div', 'style' => 'width: 260px;', - 'content' => html_print_label_input_block(' '.__('User').' ', html_print_input_text( + 'content' => html_print_label_input_block(__('User').' ', html_print_input_text( 'wmi-cred-user', '', '', @@ -969,7 +973,7 @@ class WelcomeWindow extends Wizard [ 'id' => 'wmi-cred-pass-div', 'style' => 'width: 260px;', - 'content' => html_print_label_input_block(' '.__('Password').' ', html_print_input_password( + 'content' => html_print_label_input_block($spacing.__('Password').' ', html_print_input_password( 'wmi-cred-pass', '', '', @@ -991,7 +995,7 @@ class WelcomeWindow extends Wizard [ 'id' => 'wmi-cred-namespace-div', 'style' => 'width: 260px;', - 'content' => html_print_label_input_block(' '.__('Namespace').' ', html_print_input_text( + 'content' => html_print_label_input_block($spacing.__('Namespace').' ', html_print_input_text( 'wmi-cred-namespace', '', '', @@ -1028,7 +1032,7 @@ class WelcomeWindow extends Wizard ], true ); - echo '
'; + echo '
'; echo html_print_button( __('Add'), 'add-wmi-cred', @@ -1044,30 +1048,30 @@ class WelcomeWindow extends Wizard false, '' ); + echo '
'; echo '
'; // RCM Credentials - echo html_print_label_input_block( - __('Remote commands credentials'), - html_print_div( - [ - 'id' => 'rcmd-creds', - 'content' => '' - ], - true - ) + echo '
'; + echo ''.__('Remote commands credentials').''; + echo html_print_div( + [ + 'id' => 'rcmd-creds', + 'content' => '' + ], + true ); echo html_print_div( [ 'id' => 'rcmd-cred-form', 'hidden' => true, - 'style' => 'margin: 3px; display: flex; align-items: center;', + 'style' => 'margin: 10px; display: flex; align-items: center;', 'content' => html_print_div( [ 'id' => 'rcmd-cred-user-div', 'style' => 'width: 260px;', - 'content' => html_print_label_input_block(' '.__('User').' ', html_print_input_text( + 'content' => html_print_label_input_block(__('User').' ', html_print_input_text( 'rcmd-cred-user', '', '', @@ -1096,7 +1100,7 @@ class WelcomeWindow extends Wizard [ 'id' => 'rcmd-cred-pass-div', 'style' => 'width: 260px;', - 'content' => html_print_label_input_block(' '.__('Password').' ', html_print_input_password( + 'content' => html_print_label_input_block($spacing.__('Password').' ', html_print_input_password( 'rcmd-cred-pass', '', '', @@ -1126,7 +1130,7 @@ class WelcomeWindow extends Wizard ], true ); - echo '
'; + echo '
'; echo html_print_button( __('Add'), 'add-rcmd-cred', @@ -1142,6 +1146,7 @@ class WelcomeWindow extends Wizard false, '' ); + echo '
'; echo html_print_submit_button(__('Create'), 'basic_net', false, ['icon' => 'next', 'style' => 'margin-top:15px; float:right;']); ?> From cf3b8e7359f828e43177ccdf7bb59c68072a533c Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 8 Feb 2024 15:42:00 +0100 Subject: [PATCH 171/233] #12687 changes in css --- .../resources/resources_export_import.php | 217 ++++++++++++++---- .../include/ajax/resources.ajax.php | 8 +- pandora_console/include/styles/pandora.css | 75 ++++++ 3 files changed, 249 insertions(+), 51 deletions(-) diff --git a/pandora_console/godmode/resources/resources_export_import.php b/pandora_console/godmode/resources/resources_export_import.php index ac9fdd44a4..159375744f 100644 --- a/pandora_console/godmode/resources/resources_export_import.php +++ b/pandora_console/godmode/resources/resources_export_import.php @@ -48,65 +48,133 @@ $msg = ''; $prd = new Prd(); if (isset($_FILES['resource_import']) === true) { - $data = parse_ini_file($_FILES['resource_import']['tmp_name'], true); - if ($data !== false) { - if (isset($data['prd_data']['name']) === true - && isset($data['prd_data']['type']) === true - ) { - $name = $data['prd_data']['name']; - $type = $data['prd_data']['type']; - } + if (empty($_FILES['resource_import']['tmp_name']) === false) { + $data = parse_ini_file($_FILES['resource_import']['tmp_name'], true); + if ($data !== false) { + if (isset($data['prd_data']['name']) === true + && isset($data['prd_data']['type']) === true + ) { + $name = $data['prd_data']['name']; + $type = $data['prd_data']['type']; + } - $msg = $prd->importPrd($data); + $msg = $prd->importPrd($data); + } else { + $msg = [ + 'status' => false, + 'items' => [], + 'errors' => ['Unexpected error: Unable to parse PRD file.'], + ]; + } } else { $msg = [ 'status' => false, 'items' => [], - 'errors' => ['Unexpected error: Unable to parse PRD file.'], + 'errors' => ['No files have selected'], ]; } } $msg = json_encode($msg); -$table = new stdClass(); -$table->id = 'import_data_table'; -$table->class = 'databox filter-table-adv'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->size = []; - -$table->data[0][0] = html_print_label_input_block( - __('Resource importation'), - html_print_input_file('resource_import', true) +echo '
'; +// Import section. +$label_import = html_print_label( + __('Import resources to').' '.get_product_name(), + 'label_import', + true, + ['style' => 'font-size: 13px; line-height: 16px'], ); -$table->data[0][0] .= html_print_submit_button( - __('Import resource'), - 'upload', - false, - [], +$div_label_import = html_print_div( + [ + 'style' => 'padding-bottom: 20px;', + 'content' => $label_import, + ], true ); -echo '
'; -html_print_table($table); +$input_file = ''; + +$div_input_file = html_print_div( + [ + 'style' => 'padding-bottom: 20px;display: flex; justify-content: left;width:100%; height: 60px;', + 'content' => $input_file, + ], + true +); + +$button_import = html_print_submit_button( + __('Import'), + 'upload', + false, + ['icon' => 'import'], + true +); + +$div_button_import = html_print_div( + [ + 'style' => 'padding-bottom: 20px', + 'content' => $button_import, + ], + true +); + +$div_import = html_print_div( + [ + 'style' => 'width: 80%', + 'content' => $div_label_import.$div_input_file.$div_button_import, + ], + true +); + +$img_import = html_print_image( + 'images/import_to.svg', + true, + [ + 'border' => '0', + 'width' => '100%', + ] +); + +$div_img_import = html_print_div( + [ + 'style' => 'margin-left: 40px; margin-right: 20px', + 'content' => $img_import, + ], + true +); + +echo ''; +echo html_print_div( + [ + 'class' => 'div-import', + 'content' => $div_import.$div_img_import, + ], + true +); echo '
'; -$table = new stdClass(); -$table->id = 'export_data_table'; -$table->class = 'databox filter-table-adv'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->size = []; -$table->size[0] = '50%'; -$table->size[1] = '50%'; + +// Export section. +$label_export = html_print_label( + __('Export resources from').' '.get_product_name(), + 'label_export', + true, + ['style' => 'font-size: 13px; line-height: 16px'], +); + +$div_label_export = html_print_div( + [ + 'style' => 'padding-bottom: 20px', + 'content' => $label_export, + ], + true +); $export_type = $prd->getTypesPrd(); -$table->data[0][0] = html_print_label_input_block( +$select_export_type = html_print_label_input_block( __('Export type'), html_print_select( $export_type, @@ -118,22 +186,74 @@ $table->data[0][0] = html_print_label_input_block( true, false, true, - 'w40p' - ) + 'w90p' + ), + ['div_style' => 'display: flex; flex-direction: column; width: 50%'], ); -$table->data[1][0] = ''; +$div_select_export = html_print_div( + [ + 'id' => 'div_select_export', + 'style' => 'padding-bottom: 20px;display: flex; flex-direction: row; height: 60px', + 'content' => $select_export_type, + ], + true +); -$table->data[2][0] = html_print_button( +$button_export = html_print_button( __('Export'), 'export_button', false, '', - ['class' => 'flex_justify invisible_important'], + [ + 'class' => 'flex_justify', + 'icon' => 'export', + ], true ); -html_print_table($table); +$div_button_export = html_print_div( + [ + 'style' => '', + 'content' => $button_export, + ], + true +); + +$div_export = html_print_div( + [ + 'style' => 'padding-bottom: 20px; width: 80%', + 'content' => $div_label_export.$div_select_export.$div_button_export, + ], + true +); + +$img_export = html_print_image( + 'images/export_to.svg', + true, + [ + 'border' => '0', + 'width' => '100%', + ] +); + +$div_img_export = html_print_div( + [ + 'style' => 'margin-left: 40px; margin-right: 20px', + 'content' => $img_export, + ], + true +); + +echo html_print_div( + [ + 'class' => 'div-export', + 'content' => $div_export.$div_img_export, + ], + true +); + +echo '
'; ?>