diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 95794e46e8..47b4424bcf 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.773.3-230913 +Version: 7.0NG.773.3-231002 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 8c83d59614..43113c2cbc 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.773.3-230913" +pandora_version="7.0NG.773.3-231002" 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 aa7ed21bfd..ee38d65811 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1031,7 +1031,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.773.3'; -use constant AGENT_BUILD => '230913'; +use constant AGENT_BUILD => '231002'; # 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 9a2561e95f..61d81e4f20 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.773.3 -%define release 230913 +%define release 231002 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 new file mode 100644 index 0000000000..1615f10ae1 --- /dev/null +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -0,0 +1,169 @@ +# +#Pandora FMS Linux Agent +# +%global __os_install_post %{nil} +%define name pandorafms_agent_linux_bin +%define source_name pandorafms_agent_linux +%define version 7.0NG.773.3 +%define release 230919 +%define debug_package %{nil} + +Summary: Pandora FMS Linux agent, binary version +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: ArticaST +Source0: %{source_name}-%{version}.tar.gz +URL: http://pandorafms.org +Group: System/Monitoring +Packager: Sancho Lerena +Prefix: /usr/share +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildArch: x86_64 +Requires(pre): shadow-utils +Requires(post): chkconfig /bin/ln +Requires(preun): chkconfig /bin/rm /usr/sbin/userdel +Requires: coreutils unzip +Requires: util-linux procps grep +Requires: /sbin/ip /bin/awk +Requires: perl-interpreter +Requires: perl-IO-Compress +Requires: libnsl +AutoReq: 0 +Provides: %{name}-%{version} + +%description +Pandora FMS agent for unix. Pandora FMS is an OpenSource full-featured monitoring software. + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -q -n unix + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/sbin/ +mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ +mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ +mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ +cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ + +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew + +install -m 0644 pandora_agent_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_agent + +if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then + rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +fi + +%clean +rm -Rf $RPM_BUILD_ROOT + +%pre +getent passwd pandora >/dev/null || \ + /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +exit 0 +chown pandora:root /var/log/pandora + +%post +if [ ! -d /etc/pandora ] ; then + mkdir -p /etc/pandora +fi + +if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then + cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf +fi + +if [ ! -f /etc/pandora/pandora_agent.conf ] ; then + ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf +else + [[ ! -f /etc/pandora/pandora_agent.conf.rpmnew ]] && ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew +fi + +if [ ! -e /etc/pandora/plugins ]; then + ln -s /usr/share/pandora_agent/plugins /etc/pandora +fi + +if [ ! -e /etc/pandora/collections ]; then + mkdir -p /usr/share/pandora_agent/collections + ln -s /usr/share/pandora_agent/collections /etc/pandora +fi + +if [ ! -e /etc/pandora/commands ]; then + mkdir -p /usr/share/pandora_agent/commands + ln -s /usr/share/pandora_agent/commands /etc/pandora +fi + +mkdir -p /var/spool/pandora/data_out +if [ ! -d /var/log/pandora ]; then + mkdir -p /var/log/pandora +fi + +if [ `command -v systemctl` ]; +then + echo "Copying new version of pandora_agent_daemon service" + cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/ + chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service +# Enable the services on SystemD + systemctl enable pandora_agent_daemon.service +else + /sbin/chkconfig --add pandora_agent_daemon + /sbin/chkconfig pandora_agent_daemon on +fi + +if [ "$1" -gt 1 ] +then + + echo "If Pandora Agent daemon was running with init.d script," + echo "please stop it manually and start the service with systemctl" + +fi + + +%preun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +/sbin/chkconfig --del pandora_agent_daemon +/etc/rc.d/init.d/pandora_agent_daemon stop >/dev/null 2>&1 || : + +# Remove symbolic links +pushd /etc/pandora +for f in pandora_agent.conf plugins collections +do + [ -L $f ] && rm -f $f +done +exit 0 + +%files +%defattr(750,root,root) +/usr/bin/pandora_agent + +%defattr(755,pandora,root) +%{prefix}/pandora_agent + +%defattr(755,root,root) +/usr/bin/pandora_agent_exec +/usr/bin/tentacle_client +/etc/rc.d/init.d/pandora_agent_daemon + +%defattr(644,root,root) +/usr/share/man/man1/pandora_agent.1.gz +/usr/share/man/man1/tentacle_client.1.gz +%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_agent diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec new file mode 100644 index 0000000000..0f63a6d626 --- /dev/null +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -0,0 +1,170 @@ +# +#Pandora FMS Linux Agent +# +%global __os_install_post %{nil} +%define name pandorafms_agent_linux_bin +%define source_name pandorafms_agent_linux +%define version 7.0NG.773.3 +%define release 230919 +%define debug_package %{nil} + +Summary: Pandora FMS Linux agent, binary version +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: ArticaST +Source0: %{source_name}-%{version}.tar.gz +URL: http://pandorafms.org +Group: System/Monitoring +Packager: Sancho Lerena +Prefix: /usr/share +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildArch: x86_64 +Requires(pre): shadow-utils +Requires(post): chkconfig /bin/ln +Requires(preun): chkconfig /bin/rm /usr/sbin/userdel +Requires: coreutils unzip +Requires: util-linux procps grep +Requires: /sbin/ip /bin/awk +Requires: perl-interpreter +Requires: perl-IO-Compress +Requires: libnsl +Requires: libxcrypt-compat +AutoReq: 0 +Provides: %{name}-%{version} + +%description +Pandora FMS agent for unix. Pandora FMS is an OpenSource full-featured monitoring software. + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -q -n unix + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/sbin/ +mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ +mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ +mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ +cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ + +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew + +install -m 0644 pandora_agent_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_agent + +if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then + rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +fi + +%clean +rm -Rf $RPM_BUILD_ROOT + +%pre +getent passwd pandora >/dev/null || \ + /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +exit 0 +chown pandora:root /var/log/pandora + +%post +if [ ! -d /etc/pandora ] ; then + mkdir -p /etc/pandora +fi + +if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then + cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf +fi + +if [ ! -f /etc/pandora/pandora_agent.conf ] ; then + ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf +else + [[ ! -f /etc/pandora/pandora_agent.conf.rpmnew ]] && ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew +fi + +if [ ! -e /etc/pandora/plugins ]; then + ln -s /usr/share/pandora_agent/plugins /etc/pandora +fi + +if [ ! -e /etc/pandora/collections ]; then + mkdir -p /usr/share/pandora_agent/collections + ln -s /usr/share/pandora_agent/collections /etc/pandora +fi + +if [ ! -e /etc/pandora/commands ]; then + mkdir -p /usr/share/pandora_agent/commands + ln -s /usr/share/pandora_agent/commands /etc/pandora +fi + +mkdir -p /var/spool/pandora/data_out +if [ ! -d /var/log/pandora ]; then + mkdir -p /var/log/pandora +fi + +if [ `command -v systemctl` ]; +then + echo "Copying new version of pandora_agent_daemon service" + cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/ + chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service +# Enable the services on SystemD + systemctl enable pandora_agent_daemon.service +else + /sbin/chkconfig --add pandora_agent_daemon + /sbin/chkconfig pandora_agent_daemon on +fi + +if [ "$1" -gt 1 ] +then + + echo "If Pandora Agent daemon was running with init.d script," + echo "please stop it manually and start the service with systemctl" + +fi + + +%preun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +/sbin/chkconfig --del pandora_agent_daemon +/etc/rc.d/init.d/pandora_agent_daemon stop >/dev/null 2>&1 || : + +# Remove symbolic links +pushd /etc/pandora +for f in pandora_agent.conf plugins collections +do + [ -L $f ] && rm -f $f +done +exit 0 + +%files +%defattr(750,root,root) +/usr/bin/pandora_agent + +%defattr(755,pandora,root) +%{prefix}/pandora_agent + +%defattr(755,root,root) +/usr/bin/pandora_agent_exec +/usr/bin/tentacle_client +/etc/rc.d/init.d/pandora_agent_daemon + +%defattr(644,root,root) +/usr/share/man/man1/pandora_agent.1.gz +/usr/share/man/man1/tentacle_client.1.gz +%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_agent diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 3cdc1d8439..e2a248ac0d 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.773.3 -%define release 230913 +%define release 231002 Summary: Pandora FMS Linux agent, binary version Name: %{name} @@ -26,6 +26,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel Requires: coreutils unzip Requires: util-linux procps grep Requires: /sbin/ip /bin/awk +Requires: perl #Requires: libnsl AutoReq: 0 Provides: %{name}-%{version} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 875c814b72..8ea67efe7a 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.773.3 -%define release 230913 +%define release 231002 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 7c98756364..770f884057 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.773.3" -PI_BUILD="230913" +PI_BUILD="231002" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 764180984c..713324e963 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230913} +{231002} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 58d4761fd3..0c9fd22936 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.773.3 Build 230913") +#define PANDORA_VERSION ("7.0NG.773.3 Build 231002") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 72b399f9ba..139d9f9d03 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.773.3(Build 230913))" + VALUE "ProductVersion", "(7.0NG.773.3(Build 231002))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8ee785de6c..a5c5741bb8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.773.3-230913 +Version: 7.0NG.773.3-231002 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 490af531e9..41da81dd2b 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.773.3-230913" +pandora_version="7.0NG.773.3-231002" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 26eaa93392..513b626262 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1707,4 +1707,12 @@ enterprise/godmode/wizards/Applications.class.php enterprise/godmode/wizards/Cloud.class.php enterprise/images/wizard/applications.png enterprise/images/wizard/cloud.png -enterprise/images/wizard/consoletasks.png \ No newline at end of file +enterprise/images/wizard/consoletasks.png +operation/incidents/configure_integriaims_incident.php +operation/incidents/dashboard_detail_integriaims_incident.php +operation/incidents/incident_statistics.php +operation/incidents/integriaims_export_csv.php +operation/incidents/list_integriaims_incidents.php +include/functions_incidents.php +include/functions_integriaims.php +include/ajax/integria_incidents.ajax.php diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql index 8161c4c2b6..4c13c4f51d 100644 --- a/pandora_console/extras/mr/66.sql +++ b/pandora_console/extras/mr/66.sql @@ -1,5 +1,6 @@ START TRANSACTION; +ALTER TABLE tevent_filter ADD private_filter_user text NULL; ALTER TABLE `ttrap` ADD COLUMN `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0; UPDATE ttrap SET utimestamp=UNIX_TIMESTAMP(timestamp); @@ -13,6 +14,43 @@ CREATE TABLE IF NOT EXISTS `tgraph_analytics_filter` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +ALTER TABLE `tusuario` MODIFY COLUMN `integria_user_level_pass` TEXT; + +DROP TABLE `tincidencia`; +DROP TABLE `tnota`; +DROP TABLE `tattachment`; + +ALTER TABLE `talert_commands` ADD CONSTRAINT UNIQUE (`name`); + +ALTER TABLE `talert_actions` MODIFY COLUMN `name` VARCHAR(500); +ALTER TABLE `talert_actions` ADD CONSTRAINT UNIQUE (`name`); + +SET @command_name = 'Pandora ITSM Ticket'; +SET @command_description = 'Create a ticket in Pandora ITSM'; +SET @action_name = 'Create Pandora ITSM ticket'; + +UPDATE `talert_commands` SET `name` = @command_name, `description` = @command_description WHERE `name` = 'Integria IMS Ticket' AND `internal` = 1; +INSERT IGNORE INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@command_name,'Internal type',@command_description,1,'["Ticket title","Ticket group ID","Ticket priority","Ticket owner","Ticket type","Ticket status","Ticket description","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]','["", "_ITSM_groups_", "_ITSM_priorities_","_ITSM_users_","_ITSM_types_","_ITSM_status_","_html_editor_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_","_custom_field_ITSM_"]'); + +SELECT @id_alert_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +UPDATE `talert_actions` SET `name` = @action_name WHERE `name` = 'Create Integria IMS ticket' AND `id_alert_command` = @id_alert_command; +INSERT IGNORE INTO `talert_actions` (`name`, `id_alert_command`) VALUES (@action_name,@id_alert_command); + +SET @event_response_name = 'Create ticket in Pandora ITSM from event'; +SET @event_response_description = 'Create a ticket in Pandora ITSM from an event'; +SET @event_response_target = 'index.php?sec=manageTickets&sec2=operation/ITSM/itsm&operation=edit&from_event=_event_id_'; +SET @event_response_type = 'url'; +SET @event_response_id_group = 0; +SET @event_response_modal_width = 0; +SET @event_response_modal_height = 0; +SET @event_response_new_window = 1; +SET @event_response_params = ''; +SET @event_response_server_to_exec = 0; +SET @event_response_command_timeout = 90; +SET @event_response_display_command = 1; +UPDATE `tevent_response` SET `name` = @event_response_name, `description` = @event_response_description, `target` = @event_response_target, `display_command` = @event_response_display_command WHERE `name` = 'Create ticket in IntegriaIMS from event'; +INSERT IGNORE INTO `tevent_response` (`name`, `description`, `target`,`type`,`id_group`,`modal_width`,`modal_height`,`new_window`,`params`,`server_to_exec`,`command_timeout`,`display_command`) VALUES (@event_response_name, @event_response_description, @event_response_target, @event_response_type, @event_response_id_group, @event_response_modal_width, @event_response_modal_height, @event_response_new_window, @event_response_params, @event_response_server_to_exec, @event_response_command_timeout, @event_response_display_command); + UPDATE `twelcome_tip` SET title = 'Scheduled downtimes', url = 'https://pandorafms.com/manual/en/documentation/04_using/11_managing_and_administration#scheduled_downtimes' @@ -22,6 +60,12 @@ UPDATE tagente_modulo SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; UPDATE tpolicy_modules SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; UPDATE tnetwork_component SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; +ALTER TABLE talert_templates +ADD COLUMN `time_window` ENUM ('thirty_days','this_month','seven_days','this_week','one_day','today'), +ADD COLUMN `math_function` ENUM ('avg', 'min', 'max', 'sum'), +ADD COLUMN `condition` ENUM ('lower', 'greater', 'equal'), +MODIFY COLUMN `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always', 'not_normal', 'complex'); + ALTER TABLE `tsesion_filter_log_viewer` CHANGE COLUMN `date_range` `custom_date` INT NULL DEFAULT NULL , CHANGE COLUMN `start_date_defined` `date` VARCHAR(45) NULL DEFAULT NULL , @@ -44,4 +88,107 @@ ADD COLUMN `time_init` VARCHAR(45) NULL AFTER `date_init`, ADD COLUMN `date_end` VARCHAR(45) NULL AFTER `time_init`, ADD COLUMN `time_end` VARCHAR(45) NULL AFTER `date_end`; +UPDATE `tdiscovery_apps` SET `version` = '1.1' WHERE `short_name` = 'pandorafms.vmware'; + +-- Insert new Proxmox APP +SET @short_name = 'pandorafms.proxmox'; +SET @name = 'Proxmox'; +SET @section = 'app'; +SET @description = 'Monitor Proxmox VMs, LXC, backups and nodes from a specific host'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_proxmox'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' -g '__taskGroup__' --host '_host_' --port '_port_' --user '_user_' --password '_password_' --vm '_scanVM_' --lxc '_scanLXC_' --backups '_scanBackups_' --nodes '_scanNodes_' --transfer_mode tentacle --tentacle_address '_tentacleIP_' --tentacle_port '_tentaclePort_' --as_discovery_plugin 1'); + +-- Insert new EC2 APP +SET @short_name = 'pandorafms.aws.ec2'; +SET @name = 'Amazon EC2'; +SET @section = 'cloud'; +SET @description = 'Monitor AWS EC2 instances'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_aws_ec2'); +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec2_', 'bin/aws_ec2'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' --conf '_tempfileEC2_''); + +-- Insert new RDS APP +SET @short_name = 'pandorafms.aws.rds'; +SET @name = 'Amazon RDS'; +SET @section = 'cloud'; +SET @description = 'Monitor AWS RDS instances'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_aws_rds'); +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec2_', 'bin/aws_rds'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' --conf '_tempfileRDS_''); + +-- Insert new S3 APP +SET @short_name = 'pandorafms.aws.s3'; +SET @name = 'Amazon S3'; +SET @section = 'cloud'; +SET @description = 'Monitor AWS S3 buckets'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_aws_s3'); +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec2_', 'bin/aws_s3'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' --conf '_tempfileS3_''); + +-- Insert new Azure APP +SET @short_name = 'pandorafms.azure.mc'; +SET @name = 'Azure Microsoft Compute'; +SET @section = 'cloud'; +SET @description = 'Monitor Azure Microsoft Compute VMs'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_azure_mc'); +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec2_', 'bin/azure_vm'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' --conf '_tempfileAzureMC_''); + +-- Insert new Google APP +SET @short_name = 'pandorafms.gcp.ce'; +SET @name = 'Google Cloud Compute Engine'; +SET @section = 'cloud'; +SET @description = 'Monitor Google Cloud Platform Compute Engine VMs'; +SET @version = '1.0'; +INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); +SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; + +-- Insert into tdiscovery_apps_scripts +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec1_', 'bin/pandora_gcp_ce'); +INSERT IGNORE INTO `tdiscovery_apps_scripts` (`id_app`, `macro`, `value`) VALUES (@id_app, '_exec2_', 'bin/google_instances'); + +-- Insert into tdiscovery_apps_executions +INSERT IGNORE INTO `tdiscovery_apps_executions` (`id`, `id_app`, `execution`) VALUES (1, @id_app, ''_exec1_' --conf '_tempfileGoogleCE_''); + +ALTER TABLE `treport_content` ADD COLUMN `cat_security_hardening` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `ignore_skipped` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `status_of_check` TINYTEXT; + +ALTER TABLE `tservice` ADD COLUMN `enable_horizontal_tree` TINYINT NOT NULL DEFAULT 0; + COMMIT; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index a77548de53..28311371bf 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -352,6 +352,21 @@ echo sprintf('
', $menuTypeClass); $display_counter = 'display:none'; } + $header_setup = ''; + if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { + $header_setup .= ''; + } + $header_autorefresh = '
'; $header_autorefresh .= $autorefresh_link_open_img; $header_autorefresh .= $autorefresh_img; @@ -428,7 +443,7 @@ echo sprintf('
', $menuTypeClass); ); // Logout. - $header_logout = '
'; + $header_logout = '
'; - return; -} else { - $count = count($result); - $result = array_slice($result, $offset, $config['block_size']); +try { + $ITSM = new ITSM(); + echo $ITSM->getTableIncidencesForAgent($id_agente); +} catch (Exception $e) { + echo $e->getMessage(); } -// Show pagination. -ui_pagination($count, $url, $offset, 0, false, 'offset'); -// ($count + $offset) it's real count of incidents because it's use LIMIT $offset in query. -echo '
'; - -// Show headers. -$table->width = '100%'; -$table->class = 'databox'; -$table->cellpadding = 4; -$table->cellspacing = 4; -$table->head = []; -$table->data = []; -$table->size = []; -$table->align = []; - -$table->head[0] = __('ID'); -$table->head[1] = __('Status'); -$table->head[2] = __('Incident'); -$table->head[3] = __('Priority'); -$table->head[4] = __('Group'); -$table->head[5] = __('Updated'); - -$table->size[0] = 43; -$table->size[7] = 50; - -$table->align[1] = 'center'; -$table->align[3] = 'center'; -$table->align[4] = 'center'; - -$rowPair = true; -$iterator = 0; -foreach ($result as $row) { - if ($rowPair) { - $table->rowclass[$iterator] = 'rowPair'; - } else { - $table->rowclass[$iterator] = 'rowOdd'; - } - - $rowPair = !$rowPair; - $iterator++; - - $data = []; - - $data[0] = '
'.$row['id_incidencia'].''; - $attach = incidents_get_attach($row['id_incidencia']); - - if (!empty($attach)) { - $data[0] .= '  '.html_print_image('images/attachment.png', true, ['style' => 'align:middle;']); - } - - $data[1] = incidents_print_status_img($row['estado'], true); - $data[2] = ''.substr(io_safe_output($row['titulo']), 0, 45).''; - $data[3] = incidents_print_priority_img($row['prioridad'], true); - $data[4] = $row['id_grupo']; - $data[5] = ui_print_timestamp($row['actualizacion'], true); - - array_push($table->data, $data); -} - -html_print_table($table); - -echo '
'; -unset($table); -echo '

'; - -echo '
 
'; +html_print_action_buttons(''); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 701ce4894b..91d911ae24 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -39,6 +39,7 @@ ui_require_javascript_file('encode_decode_base64'); ui_require_css_file('agent_manager'); use PandoraFMS\Event; +use PandoraFMS\ITSM\ITSM; check_login(); @@ -437,7 +438,7 @@ if ($id_agente) { [ 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente, 'content' => html_print_image( - 'images/alert@svg.svg', + 'images/add-alert.svg', true, [ 'title' => __('Alerts'), @@ -607,23 +608,6 @@ if ($id_agente) { $agent_wizard['active'] = false; } - - $total_incidents = agents_get_count_incidents($id_agente); - - // Incident tab. - if ($total_incidents > 0) { - $incidenttab['text'] = html_print_menu_button( - [ - 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agente, - 'image' => 'images/logs@svg.svg', - 'title' => __('Incidents'), - ], - true - ); - - $incidenttab['active'] = ($tab === 'incident'); - } - if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) { if ($has_remote_conf !== false) { $agent_name = agents_get_name($id_agente); @@ -2092,7 +2076,6 @@ if ($create_module) { if ($disable_module) { - hd($disable_module, true); $result = modules_change_disabled($disable_module, 1); $module_name = modules_get_agentmodule_name($disable_module); @@ -2116,13 +2099,11 @@ if ($create_module) { if ($result === NOERR) { - hd($disable_module, true); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Disable #'.$disable_module.' | '.$module_name.' | '.io_safe_output($agent['alias']) ); } else { - hd($disable_module, true); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Fail to disable #'.$disable_module.' | '.$module_name.' | '.io_safe_output($agent['alias']) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index a14bff4b92..487fe54e07 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -751,6 +751,10 @@ if ($agents !== false) { 'index.php?sec=reporting&sec2=operation/cluster/cluster&op=view&id=%s', $cluster->id() ); + $agentAlertUrl = sprintf( + 'index.php?sec=estado&sec2=operation/cluster/cluster&op=update&id=%s&page=6', + $cluster->id() + ); } else { $main_tab = ($check_aw === true) ? 'main' : 'module'; $agentNameUrl = sprintf( @@ -762,6 +766,10 @@ if ($agents !== false) { 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=%s', $agent['id_agente'] ); + $agentAlertUrl = sprintf( + 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=%s', + $agent['id_agente'] + ); } if (empty($agent['alias']) === true) { @@ -825,7 +833,7 @@ if ($agents !== false) { ); } - if ((int) $agent['id_os'] !== 100) { + if ((int) $agent['id_os'] != CLUSTER_OS_ID) { $additionalOptionsAgentName[] = html_print_anchor( [ 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$agent['id_agente']), @@ -837,7 +845,7 @@ if ($agents !== false) { $additionalOptionsAgentName[] = html_print_anchor( [ - 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$agent['id_agente']), + 'href' => ui_get_full_url($agentAlertUrl), 'content' => __('Alerts'), ], true @@ -942,7 +950,7 @@ if ($agents !== false) { $os ) ), - 'onClick' => ($agent['id_os'] === CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;', + 'onClick' => ($agent['id_os'] == CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;', 'image' => sprintf('images/%s', $agentDisableEnableIcon), 'title' => $agentDisableEnableTitle, ], @@ -950,7 +958,7 @@ if ($agents !== false) { ); if ($check_aw === true && is_management_allowed() === true) { - if ($agent['id_os'] !== CLUSTER_OS_ID) { + if ($agent['id_os'] != CLUSTER_OS_ID) { $onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;'; } else { $onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;'; diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 97a492809e..e8915b05eb 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -405,6 +405,12 @@ $actions = array_slice($actions, $offset, $limit); $rowPair = true; $iterator = 0; foreach ($actions as $action) { + if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) + && $action['name'] === 'Create Pandora ITSM ticket' + ) { + continue; + } + if ($rowPair) { $table->rowclass[$iterator] = 'rowPair'; } else { diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index b6231544d1..a59de7f5e2 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -1,16 +1,33 @@ '; @@ -187,7 +215,7 @@ if (is_ajax()) { 0, '', false, - $is_management_allowed, + $management_is_not_allowed, "UndefineTinyMCE('#textarea_field".$i."_recovery_value')", '', true @@ -199,7 +227,7 @@ if (is_ajax()) { 0, '', true, - $is_management_allowed, + $management_is_not_allowed, "defineTinyMCE('#textarea_field".$i."_recovery_value')", '', true @@ -214,7 +242,7 @@ if (is_ajax()) { 'class="fields_recovery"', true, '', - $is_management_allowed + $management_is_not_allowed || $recovery_disabled ); } else if (preg_match('/^_content_type_$/i', $field_value)) { $editor_type_chkbx = '
'; @@ -228,7 +256,7 @@ if (is_ajax()) { 'text/plain', '', '', - $is_management_allowed, + $management_is_not_allowed, '', '', true @@ -240,7 +268,7 @@ if (is_ajax()) { 'text/html', '', 'text/html', - $is_management_allowed, + $management_is_not_allowed, '', '', true @@ -259,7 +287,7 @@ if (is_ajax()) { 'text/plain', '', '', - $is_management_allowed, + $management_is_not_allowed, '', '', true @@ -271,7 +299,7 @@ if (is_ajax()) { 'text/html', '', 'text/html', - $is_management_allowed, + $management_is_not_allowed, '', '', true @@ -279,78 +307,304 @@ if (is_ajax()) { $editor_type_chkbx .= '
'; $rfield = $editor_type_chkbx; // Select type. - } else if (preg_match('/^_integria_type_custom_field_$/i', $field_value)) { - $ffield = ''; - $rfield = ''; + } else if (preg_match('/^_custom_field_ITSM_$/i', $field_value)) { + $ffield = ''; + $rfield = ''; - $ffield .= '
'.html_print_switch( - [ - 'name' => 'field'.$i.'_value[]', - 'value' => '', - ] - ).'
'; - $rfield .= '
'.html_print_switch( - [ - 'name' => 'field'.$i.'_recovery_value[]', - 'value' => '', - ] - ).'
'; + $ffield .= '
'.html_print_switch( + [ + 'name' => 'field'.$i.'_value[]', + 'value' => '', + ] + ).'
'; + $rfield .= '
'.html_print_switch( + [ + 'name' => 'field'.$i.'_recovery_value[]', + 'value' => '', + 'disabled' => $management_is_not_allowed || $recovery_disabled, + ] + ).'
'; - $ffield .= html_print_select( - '', - 'field'.$i.'_value[]', + $ffield .= html_print_select( + '', + 'field'.$i.'_value[]', + '', + '', + __('None'), + '', + true, + false, + false, + 'fields', + $management_is_not_allowed, + 'width: 100%;', + false, + false, + false, + '', + false, + false, + false, + false, + false + ); + + $rfield .= html_print_select( + '', + 'field'.$i.'_recovery_value[]', + '', + '', + __('None'), + '', + true, + false, + false, + 'fields', + $management_is_not_allowed || $recovery_disabled, + 'width: 100%;', + false, + false, + false, + '', + false, + false, + false, + false, + false + ); + + $ffield .= html_print_input_text( + 'field'.$i.'_value[]', + '', + '', + 50, + 50, + true, + false, + false, + '', + 'datepicker', + '', + 'off', + false, + '', + '', + '', + $management_is_not_allowed + ); + $rfield .= html_print_input_text( + 'field'.$i.'_recovery_value[]', + '', + '', + 50, + 50, + true, + false, + false, + '', + 'datepicker', + '', + 'off', + false, + '', + '', + '', + $management_is_not_allowed || $recovery_disabled + ); + + $ffield .= html_print_textarea( + 'field'.$i.'_value[]', + 5, + 1, + '', + 'style="min-height:40px; '.$style.'" class="fields"', + true, + '', + $management_is_not_allowed + ); + + $rfield .= html_print_textarea( + 'field'.$i.'_recovery_value[]', + 5, + 1, + '', + 'style="min-height:40px; '.$style.'" class="fields_recovery', + true, + '', + $management_is_not_allowed || $recovery_disabled + ); + + $values_input_number = [ + 'name' => 'field'.$i.'_value[]', + 'value' => 0, + 'id' => 'field'.$i.'_value', + 'return' => true, + ]; + + if ($management_is_not_allowed === true) { + $values_input_number['disabled'] = true; + } + + $ffield .= html_print_input_number($values_input_number); + + $values_input_number_recovery = [ + 'name' => 'field'.$i.'_recovery_value[]', + 'value' => 0, + 'id' => 'field'.$i.'_recovery_value', + 'return' => true, + ]; + + if ($management_is_not_allowed || $recovery_disabled) { + $values_input_number_recovery['disabled'] = true; + } + + $rfield .= html_print_input_number($values_input_number_recovery); + + $ffield .= html_print_input_text( + 'field'.$i.'_value[]', + '', + '', + 50, + 255, + true, + false, + false, + '', + 'normal w98p', + '', + 'off', + false, + false, + '', + '', + $management_is_not_allowed + ); + $rfield .= html_print_input_text( + 'field'.$i.'_recovery_value[]', + '', + '', + 50, + 255, + true, + false, + false, + '', + 'normal w98p', + '', + 'off', + false, + false, + '', + '', + $management_is_not_allowed || $recovery_disabled + ); + } else if (str_starts_with($field_value, '_ITSM_')) { + $nothing = ''; + $nothing_value = 0; + $mode = 'select'; + switch ($field_value) { + case '_ITSM_groups_': + $fields_array = []; + try { + $ITSM = new ITSM(); + $fields_array = $ITSM->getGroups(); + } catch (\Throwable $th) { + $error = $th->getMessage(); + $fields_array = []; + } + break; + + case '_ITSM_priorities_': + $fields_array = []; + try { + $ITSM = new ITSM(); + $fields_array = $ITSM->getPriorities(); + } catch (\Throwable $th) { + $error = $th->getMessage(); + $fields_array = []; + } + break; + + case '_ITSM_types_': + $fields_array = []; + try { + $ITSM = new ITSM(); + $fields_array = $ITSM->getObjectypes(); + } catch (\Throwable $th) { + $error = $th->getMessage(); + $fields_array = []; + } + + $nothing = __('None'); + $nothing_value = 0; + break; + + case '_ITSM_status_': + $fields_array = []; + try { + $ITSM = new ITSM(); + $fields_array = $ITSM->getStatus(); + } catch (\Throwable $th) { + $error = $th->getMessage(); + $fields_array = []; + } + break; + + default: + // Nothing. + $mode = ''; + break; + } + + if ($mode === 'select') { + $ffield = html_print_select( + $fields_array, + 'field'.$i.'_value', '', '', - __('None'), - '', + $nothing, + $nothing_value, true, false, false, 'fields', - $is_management_allowed, - 'width: 100%;' + $management_is_not_allowed ); - $rfield .= html_print_select( - '', - 'field'.$i.'_recovery_value[]', + $rfield = html_print_select( + $fields_array, + 'field'.$i.'_recovery_value', '', '', - __('None'), - '', + $nothing, + $nothing_value, true, false, false, - 'fields', - $is_management_allowed, - 'width: 100%;' + 'fields_recovery', + $management_is_not_allowed || $recovery_disabled ); - - $ffield .= html_print_input_text('field'.$i.'_value[]', '', '', 10, 10, true, false, false, '', 'datepicker'); - $rfield .= html_print_input_text('field'.$i.'_recovery_value[]', '', '', 10, 10, true, false, false, '', 'datepicker'); - - $ffield .= html_print_textarea( - 'field'.$i.'_value[]', - 5, - 1, + } else { + $ffield = html_print_autocomplete_users_from_pandora_itsm( + 'field'.$i.'_value', '', - 'style="min-height:40px; '.$style.'" class="fields"', true, - '', - $is_management_allowed + 0, + $management_is_not_allowed, + false, + 'ITSM_users' ); - - $rfield .= html_print_textarea( - 'field'.$i.'_recovery_value[]', - 5, - 1, + $rfield = html_print_autocomplete_users_from_pandora_itsm( + 'field'.$i.'_recovery_value', '', - 'style="min-height:40px; '.$style.'" class="fields_recovery', true, - '', - $is_management_allowed + 0, + $management_is_not_allowed || $recovery_disabled, + false, + 'ITSM_users' ); + } } else { $fields_value_select = []; $force_print_select = false; @@ -468,7 +722,7 @@ if (is_ajax()) { false, false, 'fields', - $is_management_allowed + $management_is_not_allowed ); $rfield = html_print_select( $fields_value_select, @@ -481,7 +735,7 @@ if (is_ajax()) { false, false, 'fields_recovery', - $is_management_allowed + $management_is_not_allowed || $recovery_disabled ); } else { $ffield = html_print_textarea( @@ -492,7 +746,7 @@ if (is_ajax()) { 'style="'.$style.'" class="fields min-height-40px w100p"', true, '', - $is_management_allowed + $management_is_not_allowed ); $rfield = html_print_textarea( 'field'.$i.'_recovery_value', @@ -502,7 +756,7 @@ if (is_ajax()) { 'style="'.$style.'" class="fields_recovery min-height-40px w100p', true, '', - $is_management_allowed + $management_is_not_allowed || $recovery_disabled ); } } @@ -515,7 +769,7 @@ if (is_ajax()) { 'style="'.$style.'" class="fields min-height-40px w100p"', true, '', - $is_management_allowed + $management_is_not_allowed ); $rfield = html_print_textarea( 'field'.$i.'_recovery_value', @@ -525,7 +779,7 @@ if (is_ajax()) { 'style="'.$style.'" class="fields_recovery min-height-40px w100p"', true, '', - $is_management_allowed + $management_is_not_allowed || $recovery_disabled ); } @@ -684,9 +938,7 @@ if ($delete_command) { $result = alerts_delete_alert_command($id); - $auditMessage = ((bool) $result === true) - ? sprintf('Delete alert command #%s', $id) - : sprintf('Fail try to delete alert command #%s', $id); + $auditMessage = ((bool) $result === true) ? sprintf('Delete alert command #%s', $id) : sprintf('Fail try to delete alert command #%s', $id); db_pandora_audit( AUDIT_LOG_ALERT_MANAGEMENT, @@ -775,6 +1027,12 @@ $commands = array_slice($commands, $offset, $limit); foreach ($commands as $command) { $data = []; + if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) + && $command['name'] === 'Pandora ITSM Ticket' + ) { + continue; + } + $data['name'] = ''; // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index de07bce961..13151b4de9 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -105,8 +105,8 @@ $groups_user = users_get_groups($config['id_user']); if (!empty($groups_user)) { $groups = implode(',', array_keys($groups_user)); - if ($config['integria_enabled'] == 0) { - $integria_command = 'Integria IMS Ticket'; + if ($config['ITSM_enabled'] == 0) { + $integria_command = 'Pandora ITSM Ticket'; $sql = sprintf('SELECT taa.id, taa.name FROM talert_actions taa INNER JOIN talert_commands tac ON taa.id_alert_command = tac.id WHERE tac.name <> "%s" AND taa.id_group IN (%s)', $integria_command, $groups); } else { $sql = "SELECT id, name FROM talert_actions WHERE id_group IN ($groups)"; @@ -206,9 +206,10 @@ $table->data[2][0] = html_print_label_input_block( if (isset($step) === false) { echo '
'; - html_print_table($table); } +html_print_table($table); + if (isset($step) === false) { $output = ''; diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index fa848c845d..5d71895ecd 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -620,7 +620,21 @@ foreach ($simple_alerts as $alert) { $main_tab = 'module'; } - $data[0] = ''; + if ((int) agents_get_os($id_agent) === CLUSTER_OS_ID) { + $cluster = PandoraFMS\Cluster::loadFromAgentId($id_agent); + $agentAlertUrl = sprintf( + 'index.php?sec=estado&sec2=operation/cluster/cluster&op=update&id=%s&page=6', + $cluster->id() + ); + } else { + $agentAlertUrl = sprintf( + 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=%s&id_agente=%s', + $main_tab, + $id_agent + ); + } + + $data[0] = ''; if ($alert['disabled']) { $data[0] .= ''; diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 17669ab248..1dc32ba086 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -650,6 +650,11 @@ if ($id_agente) { echo $messageAction; include_once 'godmode/alerts/alert_list.list.php'; + + if (isset($step) === true && $step === true) { + return; + } + $all_groups = agents_get_all_groups_agent($id_agente, $agent['id_grupo']); if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) { include_once 'godmode/alerts/alert_list.builder.php'; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 033171953b..4883467c10 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -11,12 +11,12 @@ // 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. -// Load global vars +use PandoraFMS\ITSM\ITSM; +// Load global vars. global $config; require_once $config['homedir'].'/include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_users.php'; -require_once $config['homedir'].'/include/functions_integriaims.php'; enterprise_include_once('meta/include/functions_alerts_meta.php'); check_login(); @@ -39,11 +39,19 @@ if (is_ajax()) { $get_integria_ticket_custom_types = (bool) get_parameter('get_integria_ticket_custom_types'); if ($get_integria_ticket_custom_types) { - $ticket_type_id = get_parameter('ticket_type_id'); + $ticket_type_id = (int) get_parameter('ticket_type_id', 0); + if (empty($ticket_type_id) === false) { + $error = ''; + try { + $ITSM = new ITSM(); + $fields = $ITSM->getObjecTypesFields($ticket_type_id); + } catch (\Throwable $th) { + $error = $th->getMessage(); + } - $api_call = integria_api_call(null, null, null, null, 'get_incident_fields', $ticket_type_id, false, 'json'); + echo json_encode($fields); + } - echo $api_call; return; } } @@ -150,6 +158,22 @@ if ($id) { $action = alerts_get_alert_action($id); $name = $action['name']; $id_command = $action['id_alert_command']; + $command = alerts_get_alert_command($id_command); + if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) { + $action['field1'] = io_safe_output(($action['field1'] ?? $config['incident_title'])); + $action['field2'] = io_safe_output(($action['field2'] ?? $config['default_group'])); + $action['field3'] = io_safe_output(($action['field3'] ?? $config['default_criticity'])); + $action['field4'] = io_safe_output(($action['field4'] ?? $config['default_owner'])); + $action['field5'] = io_safe_output(($action['field5'] ?? $config['incident_type'])); + $action['field6'] = io_safe_output(($action['field6'] ?? $config['incident_status'])); + $action['field7'] = io_safe_output(($action['field7'] ?? $config['incident_content'])); + $action['field2_recovery'] = io_safe_output(($action['field2'] ?? $config['default_group'])); + $action['field3_recovery'] = io_safe_output(($action['field3'] ?? $config['default_criticity'])); + $action['field4_recovery'] = io_safe_output(($action['field4'] ?? $config['default_owner'])); + $action['field5_recovery'] = io_safe_output(($action['field5'] ?? $config['incident_type'])); + $action['field6_recovery'] = io_safe_output(($action['field6_recovery'] ?? $config['incident_status'])); + $action['field7_recovery'] = io_safe_output(($action['field7_recovery'] ?? $config['incident_content'])); + } $group = $action['id_group']; $action_threshold = $action['action_threshold']; @@ -235,11 +259,11 @@ $table->data[0][1] = html_print_label_input_block( ) ); -$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket')); +$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Pandora ITSM Ticket')); $sql_exclude_command_id = ''; -if (!is_metaconsole() && $config['integria_enabled'] == 0 && $create_ticket_command_id !== false) { +if (!is_metaconsole() && $config['ITSM_enabled'] == 0 && $create_ticket_command_id !== false) { $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id; } @@ -355,24 +379,26 @@ $table_macros->data[1][2] = html_print_label_input_block( ) ); -// Selector will work only with Integria activated. -$integriaIdName = 'integria_wu'; -$table_macros->colspan[$integriaIdName][0] = 3; -$table_macros->data[$integriaIdName][0] = html_print_label_input_block( - __('Create workunit on recovery').ui_print_help_tip( - __('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'), - true - ), - html_print_checkbox_switch_extended( - 'create_wu_integria', - 1, - $create_wu_integria, - false, - '', - $disabled_attr, - true - ) -); +if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) { + // Selector will work only with Integria activated. + $integriaIdName = 'integria_wu'; + $table_macros->colspan[$integriaIdName][0] = 3; + $table_macros->data[$integriaIdName][0] = html_print_label_input_block( + __('Create workunit on recovery').ui_print_help_tip( + __('If closed status is set on recovery, a workunit will be added to the ticket in Pandora ITSM rather that closing the ticket.'), + true + ), + html_print_checkbox_switch_extended( + 'create_wu_integria', + 1, + $create_wu_integria, + false, + '', + $disabled_attr, + true + ) + ); +} for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table_macros->data['field'.$i][0] = html_print_image( @@ -504,7 +530,6 @@ $(document).ready (function () { }, function(data) { var max_macro_fields = ; - data.forEach(function(custom_field, key) { var custom_field_key = key+8; // Custom fields start from field 8. @@ -523,9 +548,9 @@ $(document).ready (function () { custom_field_row.html(new_html_content); switch (custom_field.type) { - case 'checkbox': - var checkbox_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]'); - var checkbox_recovery_selector = $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]'); + case 'CHECKBOX': + var checkbox_selector = $('input[type="checkbox"][name=field'+custom_field_key+'_value\\[\\]]'); + var checkbox_recovery_selector = $('input[type="checkbox"][name=field'+custom_field_key+'_recovery_value\\[\\]]'); checkbox_selector.on('change', function() { if (checkbox_selector.prop('checked')) { @@ -565,17 +590,17 @@ $(document).ready (function () { $('[name=field'+custom_field_key+'_value_container]').show(); $('[name=field'+custom_field_key+'_recovery_value_container]').show(); - $('input:not(.datepicker)[name=field'+custom_field_key+'_value\\[\\]]').show(); - $('input:not(.datepicker)[name=field'+custom_field_key+'_recovery_value\\[\\]]').show(); + $('input[type="checkbox"][name=field'+custom_field_key+'_value\\[\\]]').show(); + $('input[type="checkbox"][name=field'+custom_field_key+'_recovery_value\\[\\]]').show(); break; - case 'combo': + case 'COMBO': var combo_input = $('select[name=field'+custom_field_key+'_value\\[\\]]'); var combo_input_recovery = $('select[name=field'+custom_field_key+'_recovery_value\\[\\]]'); combo_input.find('option').remove(); combo_input_recovery.find('option').remove(); - var combo_values_array = custom_field.combo_value.split(','); + var combo_values_array = custom_field.comboValue.split(','); combo_values_array.forEach(function(value) { combo_input.append($('' ); + + $table->data['math_function'][0] = html_print_label_input_block( + __('Math function'), + html_print_select( + alerts_get_alert_templates_functions(), + 'math_function', + $math_function, + '', + __('None'), + 0, + true, + false, + false, + 'w100p', + (!$is_management_allowed | $disabled) + ) + ); + + $table->data['time_window'][0] = html_print_label_input_block( + __('Time window').ui_print_help_tip(__('Limits to data in the following time window.'), true), + html_print_select( + alerts_get_alert_templates_windows(), + 'time_window', + $time_window, + '', + __('None'), + 0, + true, + false, + false, + 'w100p', + (!$is_management_allowed | $disabled) + ) + ); + + $table->data['condition'][0] = html_print_label_input_block( + __('Alert condition'), + html_print_select( + alerts_get_alert_templates_conditions(), + 'condition', + $condition, + '', + __('None'), + 0, + true, + false, + false, + 'w100p', + (!$is_management_allowed | $disabled) + ) + ); + $table->data['value'][1] = html_print_label_input_block( __('Value'), html_print_input_text( @@ -1088,6 +1149,12 @@ if ($step == 2) { $table->rowstyle['min'] = ''; break; + case 'complex': + $table->rowstyle['math_function'] = ''; + $table->rowstyle['condition'] = ''; + $table->rowstyle['time_window'] = ''; + break; + case 'onchange': $show_matches = true; break; @@ -1299,6 +1366,7 @@ var onchange_not = ; var error_message_min_max_zero = ; var not_normal = ; +var complex = within ')."'"; ?>; function check_fields_step2() { var correct = true; @@ -1361,6 +1429,68 @@ function render_example () { else { $("span#value").empty ().append (vvalue); } + + /* Set math function */ + var vfunction = $("select#math_function").val(); + var functionMessage = ""; + + if (vfunction == "0") { + functionMessage = ""; + } else { + if (vfunction == "avg"){ + $("span#value").empty (); + } + functionMessage = vfunction; + } + $("span#math_function").empty ().append (functionMessage); + + /* Set complex value */ + if($("select#type").val() == "complex"){ + var valueMessage = ""; + + if(vfunction == "avg"){ + valueMessage = ""; + }else if (vvalue == "") { + valueMessage = "" ; + } else { + valueMessage = vvalue; + } + + $("span#value").empty ().append (valueMessage); + } + + /* Set condition */ + var vCondition = $("select#condition").val(); + var conditionMessage = "" ; + switch (vCondition){ + case "greater": + conditionMessage = (vfunction == "avg") ? "increases" : "is more than"; + break + case "lower": + conditionMessage = (vfunction == "avg") ? "decreases" : "is less than"; + break + case "equal": + conditionMessage = (vfunction == "avg") ? "remains the same" : "is equal to"; + break + } + + $("span#condition").empty ().append (conditionMessage); + + var vWindow = $("select#time_window").val(); + + /* Set time window */ + var timeWindowMessages = { + "thirty_days": "the last 30 days", + "month": "the last month", + "seven_days": "the last 7 days", + "week": "the last week", + "one_day": "the last 24 hours", + "today": "today" + }; + var windowMessage = timeWindowMessages[vWindow] || ""; + + $("span#time_window").empty().append(windowMessage); + } // Fix for metaconsole toggle @@ -1388,6 +1518,18 @@ if ($step == 2) { $("input#text-value").keyup (render_example); $("input#text-max").keyup (render_example); $("input#text-min").keyup (render_example); + $("#condition").change (render_example); + $("#time_window").change (render_example); + + $("#math_function").change (function () { + if (["0", 'avg'].includes(this.value)) { + $("#template-value").hide(); + } else { + $("#template-value").show (); + } + + render_example (); + }) $("#type").change (function () { switch (this.value) { @@ -1395,6 +1537,7 @@ if ($step == 2) { case "not_equal": $("img#regex_good, img#regex_bad, span#matches_value").hide (); $("#template-max, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-value, #template-example").show (); /* Show example */ @@ -1405,6 +1548,7 @@ if ($step == 2) { break; case "regex": $("#template-max, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-value, #template-example, span#matches_value").show (); check_regex (); @@ -1416,6 +1560,7 @@ if ($step == 2) { break; case "max_min": $("#template-value").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-max, #template-min, #template-example, span#matches_value").show (); /* Show example */ @@ -1424,9 +1569,25 @@ if ($step == 2) { else $("span#example").empty ().append (between_not); + break; + case "complex": + $("pan#matches_value, #template-example, #template-value, #template-max, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").show (); + $("#template-example").show (); + + if (["0", 'avg'].includes($("#math_function").val())) { + $("#template-value").hide(); + }else { + $("#template-value").show(); + } + + /* Show example */ + $("span#example").empty ().append (complex); + break; case "max": $("#template-value, #template-min, span#matches_value").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-max, #template-example").show (); /* Show example */ @@ -1434,6 +1595,7 @@ if ($step == 2) { break; case "min": $("#template-value, #template-max, span#matches_value").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-min, #template-example").show (); /* Show example */ @@ -1441,6 +1603,7 @@ if ($step == 2) { break; case "warning": $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-example").show (); /* Show example */ @@ -1448,6 +1611,7 @@ if ($step == 2) { break; case "critical": $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-example").show (); /* Show example */ @@ -1455,6 +1619,7 @@ if ($step == 2) { break; case "not_normal": $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-example").show (); /* Show example */ @@ -1462,6 +1627,7 @@ if ($step == 2) { break; case "onchange": $("#template-value, #template-max, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-example, span#matches_value").show (); /* Show example */ @@ -1472,6 +1638,7 @@ if ($step == 2) { break; case "unknown": $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); $("#template-example").show (); if ($("#text-min_alerts").val() > 0 ) { @@ -1483,6 +1650,7 @@ if ($step == 2) { break; default: $("#template-value, #template-max, #template-min, #template-example, span#matches_value").hide (); + $("#template-math_function, #template-condition, #template-time_window").hide (); break; } diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index e230055f1e..113c156df3 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -61,6 +61,9 @@ if ($id) { $filter = events_get_event_filter($id); $id_group_filter = $filter['id_group_filter']; $id_group = $filter['id_group']; + // Get owner user private filter. + $private_filter = ($filter['private_filter_user'] === null || $filter['private_filter_user'] === '') ? 0 : 1; + $private_filter_user = $filter['private_filter_user']; $id_name = $filter['id_name']; $event_type = $filter['event_type']; $severity = explode(',', $filter['severity']); @@ -113,6 +116,7 @@ if ($id) { $server_id = ($filter['server_id'] ?? ''); } else { $id_group = ''; + $private_filter = 0; $id_group_filter = ''; $id_name = ''; $event_type = ''; @@ -167,8 +171,8 @@ if ($update || $create) { $id_user_ack = get_parameter('id_user_ack', ''); $owner_user = get_parameter('owner_user', ''); $group_rep = get_parameter('group_rep', ''); - $date_from = get_parameter('date_from', ''); - $date_to = get_parameter('date_to', ''); + $date_from = get_parameter('date_from', '0000-00-00'); + $date_to = get_parameter('date_to', '0000-00-00'); $source = get_parameter('source'); $id_extra = get_parameter('id_extra'); $user_comment = get_parameter('user_comment'); @@ -192,6 +196,16 @@ if ($update || $create) { $server_id = implode(',', $servers_array); } + // Get private filter from user. + $private_filter = get_parameter_switch('private_filter_event', 0); + if ((int) $private_filter === 1 && $create) { + $private_filter_user = $_SESSION['id_usuario']; + } else if ((int) $private_filter === 1 && $update) { + $private_filter_user = ($private_filter_user === $_SESSION['id_usuario']) ? $private_filter_user : $_SESSION['id_usuario']; + } else if ((int) $private_filter === 0) { + $private_filter_user = null; + } + $values = [ 'id_name' => $id_name, 'id_group_filter' => $id_group_filter, @@ -222,6 +236,7 @@ if ($update || $create) { 'custom_data' => $custom_data, 'custom_data_filter_type' => $custom_data_filter_type, 'server_id' => $server_id, + 'private_filter_user' => $private_filter_user, ]; $severity = explode(',', $severity); @@ -293,6 +308,17 @@ $table->data[0][0] = html_print_label_input_block( false, '', 'w100p' + ).html_print_label_input_block( + __('Private'), + html_print_checkbox_switch( + 'private_filter_event', + $private_filter, + $private_filter, + true, + false, + 'checked_slide_events(this);', + true + ) ) ); diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 533bfe1190..c4f1860e6f 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -133,6 +133,18 @@ $filters = db_get_all_rows_sql($sql); if ($filters === false) { $filters = []; +} else { + foreach ($filters as $key => $filter) { + $permission = users_is_admin($config['id_user']); + // Validate permission and private filter user. + if ($permission || $filter['private_filter_user'] === $config['id_user']) { + if ($filter['private_filter_user'] !== null) { + $filters[$key]['id_name'] = $filter['id_name'].' (P)'; + } + } else if ($filter['private_filter_user'] !== null) { + unset($filters[$key]); + } + } } $table = new stdClass(); diff --git a/pandora_console/godmode/events/event_responses.list.php b/pandora_console/godmode/events/event_responses.list.php index 0cf83a4eed..0e39683c7e 100644 --- a/pandora_console/godmode/events/event_responses.list.php +++ b/pandora_console/godmode/events/event_responses.list.php @@ -75,6 +75,12 @@ foreach ($event_responses as $response) { continue; } + if ((isset($config['ITSM_enabled']) === false || (bool) $config['ITSM_enabled'] === false) + && $response['name'] === 'Create ticket in Pandora ITSM from event' + ) { + continue; + } + $data = []; $data[0] = ''.$response['name'].''; $data[1] = $response['description']; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 7cd504c8ac..e949eeaa83 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -477,8 +477,8 @@ if ($access_console_node === true) { $sub2['godmode/setup/setup§ion=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup§ion=ehorus']['refr'] = 0; - $sub2['godmode/setup/setup§ion=integria']['text'] = __('Integria IMS'); - $sub2['godmode/setup/setup§ion=integria']['refr'] = 0; + $sub2['godmode/setup/setup§ion=ITSM']['text'] = __('ITSM'); + $sub2['godmode/setup/setup§ion=ITSM']['refr'] = 0; enterprise_hook('module_library_submenu'); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 6343fabe1d..786ad13d0e 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -200,6 +200,16 @@ $text_agent_module = ''; $only_data = false; +if (enterprise_installed() === true) { + $categories_security_hardening = categories_of_cis(); + foreach ($categories_security_hardening as $key => $cat) { + $categories_security_hardening[$key] = implode(' ', $cat); + } +} else { + $categories_security_hardening = []; +} + + // Users. $id_users = []; $users_groups = []; @@ -1019,6 +1029,51 @@ switch ($action) { $idAgent = $item['id_agent']; break; + case 'top_n_agents_sh': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + + case 'top_n_checks_failed': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + + case 'top_n_categories_checks': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + + case 'vul_by_cat': + $group = $item['id_group']; + $recursion = $item['recursion']; + $cat_selected = $item['cat_security_hardening']; + $ignore_skipped = $item['ignore_skipped']; + break; + + case 'list_checks': + $group = $item['id_group']; + $recursion = $item['recursion']; + $cat_selected = $item['cat_security_hardening']; + $status_of_check = $item['status_of_check']; + $idAgent = $item['id_agent']; + break; + + case 'scoring': + $group = $item['id_group']; + $recursion = $item['recursion']; + $period = $item['period']; + break; + + case 'evolution': + $group = $item['id_group']; + $recursion = $item['recursion']; + $period = $item['period']; + break; + default: // It's not possible. break; @@ -3757,6 +3812,64 @@ if (is_metaconsole() === true) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + __('All'), + 'PASS' => __('Passed'), + 'FAIL' => __('Failed'), + 'INVALID' => __('Skipped'), + ], + 'status_of_check', + $status_of_check, + ); + ?> + + + @@ -5085,6 +5198,10 @@ echo "
".__('Please select a group.').'

'; echo '
'; +echo "'; + ui_require_javascript_file( 'pandora_inventory', ENTERPRISE_DIR.'/include/javascript/' @@ -5418,7 +5535,7 @@ $(document).ready (function () { return false; } break; - case 'permissions_report': + case 'permissions_report': if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) { dialog_message('#message_no_group'); return false; @@ -5428,6 +5545,30 @@ $(document).ready (function () { return false; } break; + case 'list_checks': + if ($("#text-agent").val() == '') { + dialog_message('#message_no_agent'); + return false; + } + break; + case 'top_n_agents_sh': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + case 'top_n_checks_failed': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + case 'top_n_categories_checks': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; default: break; } @@ -5498,13 +5639,14 @@ $(document).ready (function () { }); - $("#submit-edit_item").click(function () { + $("#button-edit_item").click(function () { var type = $('#type').val(); if($('#text-name').val() == ''){ dialog_message('#message_no_name'); return false; } + switch (type){ case 'agent_module': case 'agent_module_status': @@ -5557,6 +5699,30 @@ $(document).ready (function () { return false; } break; + case 'list_checks': + if ($("#text-agent").val() == '') { + dialog_message('#message_no_agent'); + return false; + } + break; + case 'top_n_agents_sh': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + case 'top_n_checks_failed': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + case 'top_n_categories_checks': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; default: break; @@ -6630,6 +6796,9 @@ function chooseType() { $("#row_group_by").hide(); $("#row_type_show").hide(); $("#row_use_prefix_notation").hide(); + $("#row_cat_security_hardening").hide(); + $("#row_ignore_skipped").hide(); + $("#row_status_check").hide(); // SLA list default state. $("#sla_list").hide(); @@ -7484,7 +7653,44 @@ function chooseType() { case 'ncm': $("#row_agent").show(); break; - + + case 'top_n_agents_sh': + $("#row_group").show(); + $("#row_max_items").show(); + break; + + case 'top_n_checks_failed': + $("#row_group").show(); + $("#row_max_items").show(); + break; + + case 'top_n_categories_checks': + $("#row_group").show(); + $("#row_max_items").show(); + break; + + case 'vul_by_cat': + $("#row_group").show(); + $("#row_cat_security_hardening").show(); + $("#row_ignore_skipped").show(); + break; + + case 'list_checks': + $("#row_group").show(); + $("#row_agent").show(); + $("#row_cat_security_hardening").show(); + $("#row_status_check").show(); + break; + + case 'scoring': + $("#row_group").show(); + $('#row_period').show(); + break; + + case 'evolution': + $("#row_group").show(); + $('#row_period').show(); + break; } switch (type) { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index eeee7aa1b4..a294a7b939 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1990,6 +1990,50 @@ switch ($action) { $good_format = true; break; + case 'top_n_agents_sh': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_checks_failed': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_categories_checks': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'vul_by_cat': + $values['id_group'] = get_parameter('combo_group'); + $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); + $values['ignore_skipped'] = get_parameter('ignore_skipped'); + $good_format = true; + break; + + case 'list_checks': + $values['id_group'] = get_parameter('combo_group'); + $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); + $values['status_of_check'] = get_parameter('status_of_check'); + $good_format = true; + break; + + case 'scoring': + $values['id_group'] = get_parameter('combo_group'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + + case 'evolution': + $values['id_group'] = get_parameter('combo_group'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2019,6 +2063,7 @@ switch ($action) { || ($values['type'] == 'event_report_agent') || ($values['type'] == 'agent_configuration') || ($values['type'] == 'group_configuration') + || ($values['type'] == 'list_checks') ) { $values['id_agent_module'] = ''; } else { @@ -2866,6 +2911,50 @@ switch ($action) { $good_format = true; break; + case 'top_n_agents_sh': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_checks_failed': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_categories_checks': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'vul_by_cat': + $values['id_group'] = get_parameter('combo_group'); + $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); + $values['ignore_skipped'] = get_parameter('ignore_skipped'); + $good_format = true; + break; + + case 'list_checks': + $values['id_group'] = get_parameter('combo_group'); + $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); + $values['status_of_check'] = get_parameter('status_of_check'); + $good_format = true; + break; + + case 'scoring': + $values['id_group'] = get_parameter('combo_group'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + + case 'evolution': + $values['id_group'] = get_parameter('combo_group'); + $values['period'] = get_parameter('period'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 7e17f9fe4c..d7f496c2d6 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -170,13 +170,13 @@ if (check_acl($config['id_user'], 0, 'AW')) { } } -$buttons['integria'] = [ +$buttons['ITSM'] = [ 'active' => false, - 'text' => ''.html_print_image( - 'images/integria.png', + 'text' => ''.html_print_image( + 'images/itsm.png', true, [ - 'title' => __('Integria IMS'), + 'title' => __('ITSM'), 'class' => 'invert_filter', ] ).'', @@ -185,7 +185,7 @@ $buttons['integria'] = [ $buttons['ehorus'] = [ 'active' => false, 'text' => ''.html_print_image( - 'images/ehorus/ehorus.png', + 'images/RC.png', true, [ 'title' => __('eHorus'), @@ -303,10 +303,10 @@ switch ($section) { $help_header = 'setup_ehorus_tab'; break; - case 'integria': - $buttons['integria']['active'] = true; - $subpage = __('Integria IMS'); - $help_header = 'setup_integria_tab'; + case 'ITSM': + $buttons['ITSM']['active'] = true; + $subpage = __('Pandora ITSM'); + $help_header = 'setup_ITSM_tab'; break; case 'module_library': @@ -442,8 +442,8 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; - case 'integria': - include_once $config['homedir'].'/godmode/setup/setup_integria.php'; + case 'ITSM': + include_once $config['homedir'].'/godmode/setup/setup_ITSM.php'; break; case 'gis': diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php new file mode 100644 index 0000000000..3196ef677c --- /dev/null +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -0,0 +1,716 @@ +ping(); + $group_values = $ITSM->getGroups(); + $priority_values = $ITSM->getPriorities(); + $status_values = $ITSM->getStatus(); + $object_types_values = $ITSM->getObjectypes(); + if ((bool) get_parameter('update_config', 0) === true) { + $set_config_inventories = $ITSM->createNode( + [ + 'serverAuth' => $config['server_unique_identifier'], + 'apiPass' => $config['api_password'], + 'agentsForExecution' => $config['ITSM_agents_sync'], + 'path' => $config['ITSM_public_url'], + 'label' => array_keys(servers_get_names())[0], + 'nodeId' => $config['metaconsole_node_id'], + ] + ); + } + + try { + $node = $ITSM->getNode($config['server_unique_identifier']); + } catch (\Throwable $th) { + $node = []; + } +} catch (\Throwable $th) { + $error = $th->getMessage(); + $has_connection = false; +} + +if ($has_connection === false && $config['ITSM_enabled']) { + ui_print_error_message(__('ITSM API is not reachable, %s', $error)); +} + +$table_enable = new StdClass(); +$table_enable->data = []; +$table_enable->width = '100%'; +$table_enable->id = 'itsm-enable-setup'; +$table_enable->class = 'databox filters'; +$table_enable->size['name'] = '30%'; +$table_enable->style['name'] = 'font-weight: bold'; + +// Enable Pandora ITSM. +$row = []; +$row['name'] = __('Enable Pandora ITSM'); +$row['control'] = html_print_checkbox_switch('ITSM_enabled', 1, $config['ITSM_enabled'], true); +$table_enable->data['ITSM_enabled'] = $row; + +// Remote config table. +$table_remote = new StdClass(); +$table_remote->data = []; +$table_remote->width = '100%'; +$table_remote->styleTable = 'margin-bottom: 10px;'; +$table_remote->id = 'ITSM-remote-setup'; +$table_remote->class = 'databox filters filter-table-adv'; +$table_remote->size['hostname'] = '50%'; +$table_remote->size['api_pass'] = '50%'; + +// Enable ITSM user configuration. +$row = []; +$row['user_level'] = html_print_label_input_block( + __('Pandora ITSM configuration at user level'), + html_print_checkbox_switch( + 'ITSM_user_level_conf', + 1, + $config['ITSM_user_level_conf'], + true + ) +); +$table_remote->data['ITSM_user_level_conf'] = $row; + +// ITSM hostname. +$row = []; +$row['hostname'] = html_print_label_input_block( + __('URL to Pandora ITSM setup').ui_print_help_tip( + __('Full URL to your Pandora ITSM setup (e.g., http://192.168.1.20/integria/api/v1).'), + true + ), + html_print_input_text( + 'ITSM_hostname', + $config['ITSM_hostname'], + '', + 30, + 100, + true + ), + ['div_class' => 'ITSM-remote-setup-ITSM_hostname'] +); + +// ITSM token. +$row['password'] = html_print_label_input_block( + __('Token'), + html_print_input_password( + 'ITSM_token', + io_output_password($config['ITSM_token']), + '', + 30, + 100, + true + ), + ['div_class' => 'ITSM-remote-setup-ITSM_token'] +); +$table_remote->data['ITSM_token'] = $row; + +// Test. +$row = []; +$button_test = html_print_button( + __('Test'), + 'ITSM', + false, + '', + [ + 'icon' => 'cog', + 'mode' => 'secondary mini', + ], + true +); +$button_test .= ''; +$button_test .= ''; +$button_test .= ''; +$button_test .= ' '; + +$row['control'] = html_print_label_input_block( + __('Test connection pandora to ITSM'), + $button_test +); +$table_remote->data['ITSM_test'] = $row; + +$row = []; +$itsm_public_url = $config['ITSM_public_url']; +if (empty($itsm_public_url) === true) { + $itsm_public_url = $config['homeurl']; + if (isset($config['public_url']) === true && empty($config['public_url']) === false) { + $itsm_public_url = $config['public_url']; + } +} + +$row['publicUrl'] = html_print_label_input_block( + __('URL conect to API %s', get_product_name()).ui_print_help_tip( + __('Full URL to your Pandora (e.g., http://192.168.1.20).'), + true + ), + html_print_input_text( + 'ITSM_public_url', + $itsm_public_url, + '', + 30, + 100, + true + ) +); + +$row['agentsSync'] = html_print_label_input_block( + __('Number Agents to synchronize').ui_print_help_tip( + __('Number of agents that will synchronize at the same time, minimum 10 max 1000'), + true + ), + html_print_input_number( + [ + 'name' => 'ITSM_agents_sync', + 'min' => 10, + 'max' => 1000, + 'value' => ($config['ITSM_agents_sync'] ?? 20), + ] + ) +); + +$table_remote->data['ITSM_sync_inventory'] = $row; + +// Test. +$row = []; +$button_test_pandora = html_print_button( + __('Test'), + 'ITSM-pandora', + false, + '', + [ + 'icon' => 'cog', + 'mode' => 'secondary mini', + ], + true +); +$button_test_pandora .= ''; +$button_test_pandora .= ''; +$button_test_pandora .= ''; +$button_test_pandora .= ' '; + +$row['control-test'] = html_print_label_input_block( + __('Test conection ITSM to pandora'), + $button_test_pandora +); + +if (empty($node) === false) { + $progressbar = ''; + + $progress = 0; + if (empty($node['total']) === false) { + if (empty($node['accumulate']) === true) { + $node['accumulate'] = 0; + } + + $progress = round(($node['accumulate'] * 100 / $node['total'])); + } + + if (empty($node['error']) === false) { + $progressbar = $node['error']; + } else if (empty($node['total']) === false) { + $progressbar = '
'; + $progressbar .= ui_progress($progress, '150px', '1.3', '#14524f', true, '', false, 'margin-right:5px; color:#c0ccdc'); + $progressbar .= ' ( '.$node['accumulate'].' / '.$node['total'].' ) '.__('Agents'); + $progressbar .= '
'; + } else { + $progressbar = '--'; + } + + // $progressbar .= (empty($node['dateStart']) === false) ? human_time_comparation($node['dateStart']) : __('Never'); + $row['control-test-pandora'] = html_print_label_input_block( + __('Progress agents to synch'), + $progressbar + ); +} + +$table_remote->data['ITSM_test_pandora'] = $row; + +// Alert settings. +$table_alert_settings = new StdClass(); +$table_alert_settings->data = []; +$table_alert_settings->rowspan = []; +$table_alert_settings->width = '100%'; +$table_alert_settings->styleTable = 'margin-bottom: 10px;'; +$table_alert_settings->id = 'ITSM-settings-setup'; +$table_alert_settings->class = 'databox filters filter-table-adv'; +$table_alert_settings->size[0] = '50%'; +$table_alert_settings->size[1] = '50%'; + +// Alert incident title. +$table_alert_settings->data[0][0] = html_print_label_input_block( + __('Title'), + html_print_input_text( + 'incident_title', + $config['incident_title'], + __('Name'), + 50, + 100, + true, + false, + false + ) +); + +// Alert incident description. +$table_alert_settings->rowspan[0][1] = 3; +$table_alert_settings->data[0][1] = html_print_label_input_block( + __('Ticket body'), + html_print_textarea( + 'incident_content', + 9, + 25, + $config['incident_content'], + '', + true + ) +); + +// Alert default group. +$table_alert_settings->data[1][0] = html_print_label_input_block( + __('Group'), + html_print_select( + $group_values, + 'default_group', + $config['default_group'], + '', + '', + 0, + true, + false, + true, + '', + false + ) +); + +// Alert default owner. +$table_alert_settings->data[2][0] = html_print_label_input_block( + __('Owner'), + html_print_autocomplete_users_from_pandora_itsm( + 'default_owner', + $config['default_owner'], + true, + '30', + false, + false, + 'w100p' + ), + ['div_class' => 'inline'] +); + +// Alert default incident status. +$table_alert_settings->data[3][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_values, + 'incident_status', + $config['incident_status'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Alert default criticity. +$table_alert_settings->data[3][1] = html_print_label_input_block( + __('Priority'), + html_print_select( + $priority_values, + 'default_criticity', + $config['default_criticity'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Alert default incident type. +$table_alert_settings->data[4][0] = html_print_label_input_block( + __('Type'), + html_print_select( + $object_types_values, + 'incident_type', + $config['incident_type'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Custom response settings. +$table_cr_settings = new StdClass(); +$table_cr_settings->data = []; +$table_cr_settings->width = '100%'; +$table_cr_settings->styleTable = 'margin-bottom: 10px;'; +$table_cr_settings->id = 'ITSM-cr-settings-setup'; +$table_cr_settings->class = 'databox filters filter-table-adv'; +$table_cr_settings->size[0] = '50%'; +$table_cr_settings->size[1] = '50%'; + +// Custom response incident title. +$table_cr_settings->data[0][0] = html_print_label_input_block( + __('Title'), + html_print_input_text( + 'cr_incident_title', + $config['cr_incident_title'], + __('Name'), + 50, + 100, + true, + false, + false + ) +); + +// Custom response incident description. +$table_cr_settings->rowspan[0][1] = 3; +$table_cr_settings->data[0][1] = html_print_label_input_block( + __('Ticket body'), + html_print_textarea( + 'cr_incident_content', + 9, + 25, + $config['cr_incident_content'], + '', + true + ) +); + +// Custom response default group. +$table_cr_settings->data[1][0] = html_print_label_input_block( + __('Group'), + html_print_select( + $group_values, + 'cr_default_group', + $config['cr_default_group'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Custom response default owner. +$table_cr_settings->data[2][0] = html_print_label_input_block( + __('Owner'), + html_print_autocomplete_users_from_pandora_itsm( + 'cr_default_owner', + $config['cr_default_owner'], + true, + '30', + false, + false, + 'w100p' + ), + ['div_class' => 'inline'] +); + +// Custom response default incident status. +$row = []; +$table_cr_settings->data[3][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_values, + 'cr_incident_status', + $config['cr_incident_status'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Custom response default criticity. +$table_cr_settings->data[3][1] = html_print_label_input_block( + __('Priority'), + html_print_select( + $priority_values, + 'cr_default_criticity', + $config['cr_default_criticity'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Custom response default incident type. +$table_cr_settings->data[4][0] = html_print_label_input_block( + __('Type'), + html_print_select( + $object_types_values, + 'cr_incident_type', + $config['cr_incident_type'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false + ) +); + +// Print. +echo '
'; + +echo ""; +html_print_input_hidden('update_config', 1); + +// Form enable. +echo '
'; +html_print_table($table_enable); +echo '
'; + +// Form remote. +echo '
'; +echo '
'; +echo ''.__('Pandora ITSM API settings').''; + +html_print_table($table_remote); + +echo '
'; +echo '
'; + +if ($has_connection !== false) { + // Form alert default settings. + echo '
'; + echo '
'; + echo ''.__('Alert default values').' '.ui_print_help_icon('alert_macros', true).''; + + html_print_table($table_alert_settings); + + echo '
'; + echo '
'; + + // Form custom response default settings. + echo '
'; + echo '
'; + echo ''.__('Event custom response default values').' '.ui_print_help_icon('alert_macros', true).''; + + html_print_table($table_cr_settings); + + echo '
'; + echo '
'; + + $update_button = html_print_submit_button( + __('Update'), + 'update_button', + false, + ['icon' => 'update'], + true + ); +} else { + $update_button = html_print_submit_button( + __('Update and continue'), + 'update_button', + false, + ['icon' => 'update'], + true + ); +} + +html_print_action_buttons($update_button); + +echo '
'; + +ui_require_javascript_file('ITSM'); + +?> + + diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 6616cd765c..40a816a6fa 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -371,7 +371,7 @@ if (is_ajax() === true) { case 'pandora': case 'ad': case 'saml': - case 'integria': + case 'ITSM': // Add enterprise authentication options. if (enterprise_installed() === true) { add_enterprise_auth_options($table, $type_auth); diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php deleted file mode 100644 index a01927c017..0000000000 --- a/pandora_console/godmode/setup/setup_integria.php +++ /dev/null @@ -1,997 +0,0 @@ - ($login_result !== false) ? 1 : 0]); - - return; -} - -$has_connection = integria_api_call(null, null, null, null, 'get_login', []); - -if ($has_connection === false && $config['integria_enabled']) { - ui_print_error_message(__('Integria IMS API is not reachable')); -} - -if (get_parameter('update_config', 0) == 1) { - // Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists. - $event_response_exists = db_get_row_filter('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]); - - // Try to retrieve command 'Integia IMS Ticket' to check if it exists. - $command_exists = db_get_row_filter('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]); - - if ($config['integria_enabled'] == 1) { - if ($event_response_exists === false) { - // Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database. - db_process_sql_insert( - 'tevent_response', - [ - 'name' => io_safe_input('Create ticket in IntegriaIMS from event'), - 'description' => io_safe_input('Create a ticket in Integria IMS from an event'), - 'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'), - 'type' => 'url', - 'id_group' => '0', - 'modal_width' => '0', - 'modal_height' => '0', - 'new_window' => '1', - 'params' => '', - 'server_to_exec' => '0', - ] - ); - } - - $ticket_types = integria_api_call(null, null, null, null, 'get_types', '', false, 'json'); - - $types_string = ''; - - if ($ticket_types !== '') { - foreach (json_decode($ticket_types, true) as $key => $value) { - $types_string .= $value['id'].','.$value['name'].';'; - } - } - - if ($command_exists === false) { - // Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database. - $id_command_inserted = db_process_sql_insert( - 'talert_commands', - [ - 'name' => io_safe_input('Integria IMS Ticket'), - 'command' => io_safe_input('Internal type'), - 'internal' => 1, - 'description' => io_safe_input('Create a ticket in Integria IMS'), - 'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]', - 'fields_values' => '["", "", "","","'.$types_string.'","","","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]', - ] - ); - - // Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database. - $action_values = [ - 'field1' => io_safe_input($config['incident_title']), - 'field1_recovery' => io_safe_input($config['incident_title']), - 'field2' => io_safe_input($config['default_group']), - 'field2_recovery' => io_safe_input($config['default_group']), - 'field3' => io_safe_input($config['default_criticity']), - 'field3_recovery' => io_safe_input($config['default_criticity']), - 'field4' => io_safe_input($config['default_owner']), - 'field4_recovery' => io_safe_input($config['default_owner']), - 'field5' => io_safe_input($config['incident_type']), - 'field5_recovery' => io_safe_input($config['incident_type']), - 'field6' => io_safe_input($config['incident_status']), - 'field6_recovery' => io_safe_input($config['incident_status']), - 'field7' => io_safe_input($config['incident_content']), - 'field7_recovery' => io_safe_input($config['incident_content']), - 'id_group' => 0, - 'action_threshold' => 0, - ]; - - alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values); - } else { - // Update 'Integria IMS Ticket' command with ticket types retrieved from Integria IMS. - $sql_update_command_values = sprintf( - ' - UPDATE talert_commands - SET fields_values = \'["","","","","%s","","","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_","_integria_type_custom_field_"]\' - WHERE name="%s"', - $types_string, - io_safe_input('Integria IMS Ticket') - ); - - db_process_sql($sql_update_command_values); - - // Update those actions that make use of 'Integria IMS Ticket' command when setup default fields are updated. Empty fields in actions will be filled in with default values. - $update_action_values = [ - $config['incident_title'], - $config['default_group'], - $config['default_criticity'], - $config['default_owner'], - $config['incident_type'], - $config['incident_status'], - $config['incident_content'], - ]; - - foreach ($update_action_values as $key => $value) { - $field_key = ($key + 1); - - $sql_update_action_field = sprintf( - ' - UPDATE talert_actions taa - INNER JOIN talert_commands tac - ON taa.id_alert_command=tac.id - SET field%s= "%s" - WHERE tac.name="Integria IMS Ticket" - AND ( - taa.field%s IS NULL OR taa.field%s="" - )', - $field_key, - $value, - $field_key, - $field_key, - $field_key - ); - - db_process_sql($sql_update_action_field); - } - - foreach ($update_action_values as $key => $value) { - $field_key = ($key + 1); - - $sql_update_action_recovery_field = sprintf( - ' - UPDATE talert_actions taa - INNER JOIN talert_commands tac - ON taa.id_alert_command=tac.id - SET field%s_recovery = "%s" - WHERE tac.name="Integria IMS Ticket" - AND ( - taa.field%s_recovery IS NULL OR taa.field%s_recovery="" - )', - $field_key, - $value, - $field_key, - $field_key, - $field_key - ); - - db_process_sql($sql_update_action_recovery_field); - } - } - } else { - if ($event_response_exists !== false) { - // Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled. - db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create ticket in IntegriaIMS from event')]); - } - } -} - -// Get parameters from Integria IMS API. -$integria_group_values = []; -$integria_criticity_values = []; -$integria_users_values = []; -$integria_types_values = []; -$integria_status_values = []; - -$integria_groups_csv = integria_api_call(null, null, null, null, 'get_groups', []); - -get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values); - -$integria_status_csv = integria_api_call(null, null, null, null, 'get_incidents_status', []); - -get_array_from_csv_data_pair($integria_status_csv, $integria_status_values); - -$integria_criticity_levels_csv = integria_api_call(null, null, null, null, 'get_incident_priorities', []); - -get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values); - -$integria_users_csv = integria_api_call(null, null, null, null, 'get_users', []); - -$csv_array = explode("\n", $integria_users_csv); - -foreach ($csv_array as $csv_line) { - if (empty($csv_line) === false) { - $integria_users_values[$csv_line] = $csv_line; - } -} - -$integria_types_csv = integria_api_call(null, null, null, null, 'get_types', []); - -get_array_from_csv_data_pair($integria_types_csv, $integria_types_values); - -// Enable table. -$table_enable = new StdClass(); -$table_enable->data = []; -$table_enable->width = '100%'; -$table_enable->id = 'integria-enable-setup'; -$table_enable->class = 'databox filters'; -$table_enable->size['name'] = '30%'; -$table_enable->style['name'] = 'font-weight: bold'; - -// Enable Integria. -$row = []; -$row['name'] = __('Enable Integria IMS'); -$row['control'] = html_print_checkbox_switch('integria_enabled', 1, $config['integria_enabled'], true); -$table_enable->data['integria_enabled'] = $row; - -// Remote config table. -$table_remote = new StdClass(); -$table_remote->data = []; -$table_remote->width = '100%'; -$table_remote->styleTable = 'margin-bottom: 10px;'; -$table_remote->id = 'integria-remote-setup'; -$table_remote->class = 'databox filters filter-table-adv'; -$table_remote->size['hostname'] = '50%'; -$table_remote->size['api_pass'] = '50%'; - -// Enable Integria user configuration. -$row = []; -$row['user_level'] = html_print_label_input_block( - __('Integria configuration at user level'), - html_print_checkbox_switch( - 'integria_user_level_conf', - 1, - $config['integria_user_level_conf'], - true - ) -); -$table_remote->data['integria_user_level_conf'] = $row; - -// Integria user. -$row = []; -$row['user'] = html_print_label_input_block( - __('User'), - html_print_input_text( - 'integria_user', - $config['integria_user'], - '', - 30, - 100, - true - ), - ['div_class' => 'integria-remote-setup-integria_user'] -); - -// Integria password. -$row['password'] = html_print_label_input_block( - __('Password'), - html_print_input_password( - 'integria_pass', - io_output_password($config['integria_pass']), - '', - 30, - 100, - true - ), - ['div_class' => 'integria-remote-setup-integria_pass'] -); -$table_remote->data['integria_pass'] = $row; - -// Integria hostname. -$row = []; -$row['hostname'] = html_print_label_input_block( - __('URL to Integria IMS setup').ui_print_help_tip(__('Full URL to your Integria IMS setup (e.g., http://192.168.1.20/integria, https://support.mycompany.com).'), true), - html_print_input_text( - 'integria_hostname', - $config['integria_hostname'], - '', - 30, - 100, - true - ), - ['div_class' => 'integria-remote-setup-integria_hostname'] -); - -// API password. -$row['api_pass'] = html_print_label_input_block( - __('API Password'), - html_print_input_password( - 'integria_api_pass', - io_output_password($config['integria_api_pass']), - '', - 30, - 100, - true - ), - ['div_class' => 'integria-remote-setup-integria_api_pass'] -); -$table_remote->data['integria_api_pass'] = $row; - -// Request timeout. -$row = []; -$row['req_timeout'] = html_print_label_input_block( - __('Request timeout'), - html_print_input_text( - 'integria_req_timeout', - $config['integria_req_timeout'], - '', - 3, - 10, - true - ), - ['div_class' => 'integria-remote-setup-integria_req_timeout'] -); -$table_remote->data['integria_req_timeout'] = $row; - -$row = []; -$row['control'] = __('Inventory'); -$row['control'] .= html_print_button( - __('Sync inventory'), - 'sync-inventory', - false, - '', - [ - 'icon' => 'cog', - 'mode' => 'secondary mini', - ], - true -); -$row['control'] .= ''; -$row['control'] .= ''; -$row['control'] .= ''; -$table_remote->data['integria_sync_inventory'] = $row; - -// Alert settings. -$table_alert_settings = new StdClass(); -$table_alert_settings->data = []; -$table_alert_settings->width = '100%'; -$table_alert_settings->styleTable = 'margin-bottom: 10px;'; -$table_alert_settings->id = 'integria-cr-settings-setup'; -$table_alert_settings->class = 'databox filters filter-table-adv'; -$table_alert_settings->size[0] = '50%'; -$table_alert_settings->size[1] = '50%'; - -// Alert incident title. -$row = []; -$row[0] = html_print_label_input_block( - __('Title'), - html_print_input_text( - 'incident_title', - $config['incident_title'], - __('Name'), - 50, - 100, - true, - false, - false - ) -); - -// Alert incident description. -$row[1] = html_print_label_input_block( - __('Ticket body'), - html_print_textarea( - 'incident_content', - 3, - 25, - $config['incident_content'], - '', - true - ) -); -$table_alert_settings->data[0] = $row; - -// Alert default group. -$row = []; -$row[0] = html_print_label_input_block( - __('Group'), - html_print_select( - $integria_group_values, - 'default_group', - $config['default_group'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); - -// Alert default criticity. -$row[1] = html_print_label_input_block( - __('Priority'), - html_print_select( - $integria_criticity_values, - 'default_criticity', - $config['default_criticity'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_alert_settings->data[1] = $row; - -// Alert default owner. -$row = []; -$row[0] = html_print_label_input_block( - __('Owner'), - html_print_autocomplete_users_from_integria( - 'default_owner', - $config['default_owner'], - true, - '30', - false, - false, - 'w100p' - ), - ['div_class' => 'inline'] -); - -// Alert default incident type. -$row[1] = html_print_label_input_block( - __('Type'), - html_print_select( - $integria_types_values, - 'incident_type', - $config['incident_type'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_alert_settings->data[2] = $row; - -// Alert default incident status. -$row = []; -$row[0] = html_print_label_input_block( - __('Status'), - html_print_select( - $integria_status_values, - 'incident_status', - $config['incident_status'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_alert_settings->data[3] = $row; - -// Custom response settings. -$table_cr_settings = new StdClass(); -$table_cr_settings->data = []; -$table_cr_settings->width = '100%'; -$table_cr_settings->styleTable = 'margin-bottom: 10px;'; -$table_cr_settings->id = 'integria-cr-settings-setup'; -$table_cr_settings->class = 'databox filters filter-table-adv'; -$table_cr_settings->size[0] = '50%'; -$table_cr_settings->size[1] = '50%'; - -// Custom response incident title. -$row = []; -$row[0] = html_print_label_input_block( - __('Title'), - html_print_input_text( - 'cr_incident_title', - $config['cr_incident_title'], - __('Name'), - 50, - 100, - true, - false, - false - ) -); - -// Custom response incident description. -$row[1] = html_print_label_input_block( - __('Ticket body'), - html_print_textarea( - 'cr_incident_content', - 3, - 25, - $config['cr_incident_content'], - '', - true - ) -); - -$table_cr_settings->data[0] = $row; - -// Custom response default group. -$row = []; -$row[0] = html_print_label_input_block( - __('Group'), - html_print_select( - $integria_group_values, - 'cr_default_group', - $config['cr_default_group'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); - -// Custom response default criticity. -$row[1] = html_print_label_input_block( - __('Priority'), - html_print_select( - $integria_criticity_values, - 'cr_default_criticity', - $config['cr_default_criticity'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_cr_settings->data[1] = $row; - -// Custom response default owner. -$row = []; -$row[0] = html_print_label_input_block( - __('Owner'), - html_print_autocomplete_users_from_integria( - 'cr_default_owner', - $config['cr_default_owner'], - true, - '30', - false, - false, - 'w100p' - ), - ['div_class' => 'inline'] -); - -// Custom response default incident type. -$row[1] = html_print_label_input_block( - __('Type'), - html_print_select( - $integria_types_values, - 'cr_incident_type', - $config['cr_incident_type'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_cr_settings->data[2] = $row; - -// Custom response default incident status. -$row = []; -$row[0] = html_print_label_input_block( - __('Status'), - html_print_select( - $integria_status_values, - 'cr_incident_status', - $config['cr_incident_status'], - '', - __('Select'), - 0, - true, - false, - true, - '', - false - ) -); -$table_cr_settings->data[3] = $row; - -// Test. -$row = []; -$row['control'] = __('Test connection'); -$row['control'] .= html_print_button( - __('Test'), - 'test-integria', - false, - '', - [ - 'icon' => 'cog', - 'mode' => 'secondary mini', - ], - true -); -$row['control'] .= ''; -$row['control'] .= ''; -$row['control'] .= ''; -$row['control'] .= ' '; -$table_remote->data['integria_test'] = $row; - -// Print. -echo ''; - -echo "
"; -html_print_input_hidden('update_config', 1); - -// Form enable. -echo '
'; -html_print_table($table_enable); -echo '
'; - -// Form remote. -echo '
'; -echo '
'; -echo ''.__('Integria API settings').''; - -html_print_table($table_remote); - -echo '
'; -echo '
'; - -if ($has_connection != false) { - // Form alert default settings. - echo '
'; - echo '
'; - echo ''.__('Alert default values').' '.ui_print_help_icon('alert_macros', true).''; - - html_print_table($table_alert_settings); - - echo '
'; - echo '
'; - - // Form custom response default settings. - echo '
'; - echo '
'; - echo ''.__('Event custom response default values').' '.ui_print_help_icon('alert_macros', true).''; - - html_print_table($table_cr_settings); - - echo '
'; - echo '
'; - - $update_button = html_print_submit_button( - __('Update'), - 'update_button', - false, - ['icon' => 'update'], - true - ); -} else { - $update_button = html_print_submit_button( - __('Update and continue'), - 'update_button', - false, - ['icon' => 'update'], - true - ); -} - -html_print_action_buttons($update_button); - -echo '
'; - -?> - - diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index df90f49315..08040f839c 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -333,6 +333,7 @@ if ($create_user === true) { $values['default_custom_view'] = (int) get_parameter('default_custom_view'); $values['time_autorefresh'] = (int) get_parameter('time_autorefresh', 0); $values['show_tips_startup'] = (int) get_parameter_switch('show_tips_startup'); + $values['integria_user_level_pass'] = (string) get_parameter('integria_user_level_pass'); $dashboard = get_parameter('dashboard', ''); $visual_console = get_parameter('visual_console', ''); @@ -624,6 +625,7 @@ if ($update_user) { $values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false); $values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user'); $values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass'); + $values['integria_user_level_pass'] = (string) get_parameter('integria_user_level_pass'); $values['middlename'] = get_parameter('middlename', 0); diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 39995d52c2..9991736583 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -607,16 +607,20 @@ if (is_metaconsole() === true) { } } +$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control'])); + $userManagementTable->rowclass['captions_blocksize_eventfilter'] = 'field_half_width'; $userManagementTable->rowclass['fields_blocksize_eventfilter'] = 'field_half_width'; $userManagementTable->data['captions_blocksize_eventfilter'][0] = __('Block size for pagination'); -$userManagementTable->data['fields_blocksize_eventfilter'][0] = html_print_input_text( - 'block_size', - $user_info['block_size'], - '', - 5, - 5, - true +$userManagementTable->data['fields_blocksize_eventfilter'][0] = html_print_input( + [ + 'type' => 'number', + 'size' => 5, + 'max' => $performance_variables_control['block_size']->max, + 'name' => 'block_size', + 'value' => $user_info['block_size'], + 'return' => true, + ] ); if (is_metaconsole() === true && empty($user_info['metaconsole_default_event_filter']) !== true) { @@ -785,6 +789,62 @@ $userManagementTable->data['fields_addSettings'][1] .= html_print_div( true ); + +if ($config['ITSM_enabled'] && $config['ITSM_user_level_conf']) { + // Pandora ITSM user remote login. + $table_ITSM = new StdClass(); + $table_ITSM->data = []; + $table_ITSM->width = '100%'; + $table_ITSM->id = 'ITSM-remote-setup'; + $table_ITSM->class = 'white_box'; + $table_ITSM->size['name'] = '30%'; + $table_ITSM->style['name'] = 'font-weight: bold'; + + // Pandora ITSM user level authentication. + // Title. + $row = []; + $row['control'] = '

'.__('Pandora ITSM user configuration').':

'; + $table_ITSM->data['ITSM_user_level_conf'] = $row; + + // Pandora ITSM pass. + $row = []; + $row['name'] = __('Token'); + $row['control'] = html_print_input_password( + 'integria_user_level_pass', + io_output_password($user_info['integria_user_level_pass']), + '', + 100, + 100, + true + ); + $table_ITSM->data['integria_user_level_pass'] = $row; + + // Test. + $ITSM_host = db_get_value('value', 'tconfig', 'token', 'ITSM_hostname'); + + $row = []; + $row['name'] = __('Test'); + $row['control'] = html_print_button( + __('Start'), + 'ITSM', + false, + '', + [ + 'icon' => 'cog', + 'mode' => 'secondary mini', + ], + true + ); + $row['control'] .= ' '; + $row['control'] .= ' '; + $row['control'] .= ' '; + $row['control'] .= ''; + $table_ITSM->data['ITSM_test'] = $row; + + $userManagementTable->colspan['pandoraitsm'] = 2; + $userManagementTable->data['pandoraitsm'] = html_print_table($table_ITSM, true); +} + if (isset($CodeQRTable) === true || isset($apiTokenContent) === true) { // QR Code and API Token advice. $titleQr = ''.__('Contact details (QR)').''; @@ -810,16 +870,24 @@ $vcard_data['organization'] = io_safe_output(get_product_name()); $vcard_data['url'] = ui_get_full_url('index.php'); $vcard_json = json_encode($vcard_data); + +ui_require_javascript_file('ITSM'); ?> __('Informative')]).html_print_image('images/dot_green.png', true, ['title' => __('Informative')]).html_print_image('images/dot_yellow.png', true, ['title' => __('Informative')]); - break; - - case 1: - $img = html_print_image('images/dot_green.png', true, ['title' => __('Low')]).html_print_image('images/dot_yellow.png', true, ['title' => __('Low')]).html_print_image('images/dot_yellow.png', true, ['title' => __('Low')]); - break; - - case 2: - $img = html_print_image('images/dot_yellow.png', true, ['title' => __('Medium')]).html_print_image('images/dot_yellow.png', true, ['title' => __('Medium')]).html_print_image('images/dot_red.png', true, ['title' => __('Medium')]); - break; - - case 3: - $img = html_print_image('images/dot_yellow.png', true, ['title' => __('Serious')]).html_print_image('images/dot_red.png', true, ['title' => __('Serious')]).html_print_image('images/dot_red.png', true, ['title' => __('Serious')]); - break; - - case 4: - $img = html_print_image('images/dot_red.png', true, ['title' => __('Very serious')]).html_print_image('images/dot_red.png', true, ['title' => __('Very serious')]).html_print_image('images/dot_red.png', true, ['title' => __('Very serious')]); - break; - - case 10: - $img = html_print_image('images/dot_green.png', true, ['title' => __('Maintenance')]).html_print_image('images/dot_green.png', true, ['title' => __('Maintenance')]).html_print_image('images/dot_green.png', true, ['title' => __('Maintenance')]); - break; - } - - if ($return === false) { - echo $img; - } - - return $img; -} - - -/** - * Gets all the possible status for incidents in an array - * - * @return array The several status with their values - */ -function incidents_get_status() -{ - $fields = []; - $fields[0] = __('Active incidents'); - $fields[1] = __('Active incidents, with comments'); - $fields[2] = __('Rejected incidents'); - $fields[3] = __('Expired incidents'); - $fields[13] = __('Closed incidents'); - - return $fields; -} - - -/** - * Prints the image tag for passed status - * - * @param integer $id_status: Which status to return the image to - * - * @return string The string with the image tag - */ -function incidents_print_status_img($id_status, $return=false) -{ - switch ($id_status) { - case 0: - $img = html_print_image('images/dot_red.png', true, ['title' => __('Active incidents')]); - break; - - case 1: - $img = html_print_image('images/dot_yellow.png', true, ['title' => __('Active incidents, with comments')]); - break; - - case 2: - $img = html_print_image('images/dot_blue.png', true, ['title' => __('Rejected incidents')]); - break; - - case 3: - $img = html_print_image('images/dot_green.png', true, ['title' => __('Expired incidents')]); - break; - - case 13: - $img = html_print_image('images/dot_white.png', true, ['title' => __('Closed incidents')]); - break; - } - - if ($return === false) { - echo $img; - } - - return $img; -} - - -/** - * Updates the last user (either by adding an attachment, note or the incident itself) - * Named after the UNIX touch utility - * - * @param integer $id_incident: A single incident or an array of incidents - * - * @return boolean True if it was done, false if it wasn't - */ -function incidents_process_touch($id_incident) -{ - global $config; - - $id_incident = (array) safe_int($id_incident, 1); - // Make sure we have all positive int's - if (empty($id_incident)) { - return false; - } - - if (empty($id_incident)) { - return false; - } - - return db_process_sql_update('tincidencia', ['id_lastupdate' => $config['id_user']], ['id_incidencia' => $id_incident]); -} - - -/** - * Updates the owner (named after the UNIX utility chown) - * - * @param integer $id_incident: A single incident or an array of incidents - * - * @return boolean True if it was done, false if it wasn't - */ -function incidents_process_chown($id_incident, $owner=false) -{ - if ($owner === false) { - global $config; - $owner = $config['id_user']; - } - - $id_incident = (array) safe_int($id_incident, 1); - // Make sure we have all positive int's - if (empty($id_incident)) { - return false; - } - - $id_incident = implode(',', $id_incident); - $sql = sprintf("UPDATE tincidencia SET id_usuario = '%s' WHERE id_incidencia IN (%s)", $owner, $id_incident); - - return db_process_sql($sql); -} - - -/** - * Get the author of an incident. - * - * @param integer $id_incident Incident id. - * - * @return string The author of an incident - */ -function incidents_get_author($id_incident) -{ - if ($id_incident < 1) { - return ''; - } - - return (string) db_get_value('id_creator', 'tincidencia', 'id_incidencia', (int) $id_incident); -} - - -/** - * Get the owner of an incident. - * - * @param integer $id_incident Incident id. - * - * @return string The last updater of an incident - */ -function incidents_get_owner($id_incident) -{ - if ($id_incident < 1) { - return ''; - } - - return (string) db_get_value('id_usuario', 'tincidencia', 'id_incidencia', (int) $id_incident); -} - - -/** - * Get the last updater of an incident. - * - * @param integer $id_incident Incident id. - * - * @return string The last updater of an incident - */ -function incidents_get_lastupdate($id_incident) -{ - if ($id_incident < 1) { - return ''; - } - - return (string) db_get_value('id_lastupdate', 'tincidencia', 'id_incidencia', (int) $id_incident); -} - - -/** - * Get the group id of an incident. - * - * @param integer $id_incident Incident id. - * - * @return integer The group id of an incident - */ -function incidents_get_group($id_incident) -{ - if ($id_incident < 1) { - return 0; - } - - return (int) db_get_value('id_grupo', 'tincidencia', 'id_incidencia', (int) $id_incident); -} - - -/** - * Delete an incident out the database. - * - * @param mixed $id_inc An int or an array of ints to be deleted - * - * @return boolean True if incident was succesfully deleted, false if not - */ -function incidents_delete_incident($id_incident) -{ - global $config; - $ids = (array) safe_int($id_incident, 1); - // Make the input an array - $notes = []; - $attachments = []; - $errors = 0; - - foreach ($ids as $id_inc) { - // Delete incident - $ret = db_process_sql_delete('tincidencia', ['id_incidencia' => $id_inc]); - if ($ret === false) { - $errors++; - } - - // We only need the ID's - $notes = array_merge($notes, array_keys(incidents_get_notes($id_inc))); - $attachments = array_merge($attachments, array_keys(incidents_get_attach($id_inc))); - - db_pandora_audit( - AUDIT_LOG_INCIDENT_MANAGEMENT, - $config['id_user'].' deleted incident #'.$id_inc - ); - } - - // Delete notes - $note_err = incidents_delete_note($notes, false); - $attach_err = incidents_delete_attach($attachments, false); - - if ($note_err === false || $attach_err === false) { - $errors++; - } - - if ($errors > 0) { - return false; - } - - return true; -} - - -/** - * Delete notes out the database. - * - * @param mixed $id_note An int or an array of ints to be deleted - * @param boolean $transact true if a transaction should be started, false if not - * - * @return boolean True if note was succesfully deleted, false if not - */ -function incidents_delete_note($id_note, $transact=true) -{ - $id_note = (array) safe_int($id_note, 1); - // cast as array - $errors = 0; - - // Delete notes - foreach ($id_note as $id) { - $ret = db_process_sql_delete('tnota', ['id_nota' => $id]); - if ($ret === false) { - $errors++; - } - } - - if ($errors > 0) { - return false; - } else { - return true; - } -} - - -/** - * Delete attachments out the database and from the machine. - * - * @param mixed $id_attach An int or an array of ints to be deleted - * @param boolean $transact true if a transaction should be started, false if not - * - * @return boolean True if attachment was succesfully deleted, false if not - */ -function incidents_delete_attach($id_attach, $transact=true) -{ - global $config; - - $id_attach = (array) safe_int($id_attach, 1); - // cast as array - $errors = 0; - - // Delete attachment - foreach ($id_attach as $id) { - $filename = db_get_value('filename', 'tattachment', 'id_attachment', $id); - - $ret = db_process_sql_delete('tattachment', ['id_attachment' => $id]); - if ($ret === false) { - $errors++; - } - - unlink($config['attachment_store'].'/pand'.$id.'_'.$filename); - } - - if ($errors > 0) { - return false; - } else { - return true; - } -} - - -/** - * Get notes based on the incident id. - * - * @param integer $id_incident An int with the incident id - * - * @return array An array of all the notes for that incident - */ -function incidents_get_notes($id_incident) -{ - $return = db_get_all_rows_field_filter('tnota', 'id_incident', (int) $id_incident); - - if ($return === false) { - $return = []; - } - - $notes = []; - foreach ($return as $row) { - $notes[$row['id_nota']] = $row; - } - - return $notes; -} - - -/** - * Get attachments based on the incident id. - * - * @param integer $id_incident An int with the incident id - * - * @return array An array of all the notes for that incident - */ -function incidents_get_attach($id_incident) -{ - $return = db_get_all_rows_field_filter('tattachment', 'id_incidencia', (int) $id_incident); - - if ($return === false) { - $return = []; - } - - $attach = []; - foreach ($return as $row) { - $attach[$row['id_attachment']] = $row; - } - - return $attach; -} - - -/** - * Get user id of a note. - * - * @param integer $id_note Note id. - * - * @return string User id of the given note. - */ -function incidents_get_notes_author($id_note) -{ - return (string) db_get_value('id_usuario', 'tnota', 'id_nota', (int) $id_note); -} - - -/** - * Interface to Integria API functionality. - * - * @param string $url Url to Integria API with user, password and option (function to use). - * @param string $postparameters Additional parameters to pass. - * - * @return variant The function result called in the API. - */ -function incidents_call_api($url, $postparameters=false) -{ - $curlObj = curl_init(); - curl_setopt($curlObj, CURLOPT_URL, $url); - curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); - if ($postparameters !== false) { - curl_setopt($curlObj, CURLOPT_POSTFIELDS, $postparameters); - } - - $result = curl_exec($curlObj); - curl_close($curlObj); - - return $result; -} - - -/** - * Converts Xml format file to an array datatype. - * - * @param string $xml Xml file to convert. - * - * @return array A Json encoded array with xml content. - */ -function incidents_xml_to_array($xml) -{ - $xmlObj = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); - - return json_decode(json_encode($xmlObj), true); -} diff --git a/pandora_console/include/functions_integriaims.php b/pandora_console/include/functions_integriaims.php deleted file mode 100644 index 8fec23e210..0000000000 --- a/pandora_console/include/functions_integriaims.php +++ /dev/null @@ -1,564 +0,0 @@ -'.html_print_image('images/configuration@svg.svg', true, ['title' => __('Configure Integria IMS'), 'class' => 'main_menu_icon invert_filter']).''; - $list_tab['text'] = ''.html_print_image('images/logs@svg.svg', true, ['title' => __('Ticket list'), 'class' => 'main_menu_icon invert_filter']).''; - $create_tab['text'] = ''.html_print_image('images/edit.svg', true, ['title' => __('New ticket'), 'class' => 'main_menu_icon invert_filter']).''; - - switch ($active_tab) { - case 'setup_tab': - $setup_tab['active'] = true; - $list_tab['active'] = false; - $create_tab['active'] = false; - break; - - case 'list_tab': - $setup_tab['active'] = false; - $list_tab['active'] = true; - $create_tab['active'] = false; - break; - - case 'create_tab': - $setup_tab['active'] = false; - $list_tab['active'] = false; - $create_tab['active'] = true; - break; - - default: - $setup_tab['active'] = false; - $list_tab['active'] = false; - $create_tab['active'] = false; - break; - } - - if ($view) { - $create_tab['text'] = ''.html_print_image('images/edit.svg', true, ['title' => __('Edit ticket'), 'class' => 'main_menu_icon invert_filter']).''; - $view_tab['text'] = ''.html_print_image('images/details.svg', true, ['title' => __('View ticket'), 'class' => 'main_menu_icon invert_filter']).''; - // When the current page is the View page. - if (!$active_tab) { - $view_tab['active'] = true; - } - } - - $onheader = []; - $onheader['view'] = $view_tab; - $onheader['configure'] = $setup_tab; - $onheader['list'] = $list_tab; - $onheader['create'] = $create_tab; - - return $onheader; -} - - -/** - * Gets all the details of Integria IMS API - * - * @param string $details Type of API call. - * @param number $detail_index Send index if you want return the text. - * - * @return string or array with result of API call. - */ -function integriaims_get_details($details, $detail_index=false) -{ - global $config; - - switch ($details) { - case 'status': - $operation = 'get_incidents_status'; - break; - - case 'group': - $operation = 'get_groups'; - break; - - case 'priority': - $operation = 'get_incident_priorities'; - break; - - case 'resolution': - $operation = 'get_incidents_resolutions'; - break; - - case 'type': - $operation = 'get_types'; - break; - - default: - // code... - break; - } - - $api_call = integria_api_call(null, null, null, null, $operation); - $result = []; - get_array_from_csv_data_pair($api_call, $result); - - if ($detail_index !== false) { - if ($result[$detail_index] == '' || $result[$detail_index] === null) { - return __('None'); - } else { - return $result[$detail_index]; - } - } else { - return $result; - } -} - - -/** - * Perform an API call to Integria IMS. - * - * @param string|null $api_hostname API host URL. - * @param string|null $user User name. - * @param string|null $user_pass User password. - * @param string|null $api_pass API password. - * @param string|null $operation API Operation. - * @param mixed $params String or array with parameters required by the API function. - * @param mixed $show_credentials_error_msg Show_credentials_error_msg. - * @param mixed $return_type Return_type. - * @param mixed $token Token. - * @param mixed $user_level_conf User_level_conf. - * - * @return boolean True if API request succeeded, false if API request failed. - */ -function integria_api_call( - $api_hostname=null, - $user=null, - $user_pass=null, - $api_pass=null, - $operation=null, - $params='', - $show_credentials_error_msg=false, - $return_type='', - $token='', - $user_level_conf=null -) { - global $config; - - if (is_metaconsole()) { - $servers = metaconsole_get_connection_names(); - foreach ($servers as $key => $server) { - $connection = metaconsole_get_connection($server); - if (metaconsole_connect($connection) != NOERR) { - continue; - } - - $integria_enabled = db_get_sql( - 'SELECT `value` FROM tconfig WHERE `token` = "integria_enabled"' - ); - - if (!$integria_enabled) { - metaconsole_restore_db(); - continue; - } - - // integria_user_level_conf, integria_hostname, integria_api_pass, integria_user, integria_user_level_user, integria_pass, integria_user_level_pass - $config_aux = db_get_all_rows_sql('SELECT `token`, `value` FROM `tconfig` WHERE `token` IN ("integria_user_level_conf", "integria_hostname", "integria_api_pass", "integria_user", "integria_user_level_user", "integria_pass", "integria_user_level_pass")'); - $user_info = users_get_user_by_id($config['id_user']); - foreach ($config_aux as $key => $conf) { - if ($conf['token'] === 'integria_user_level_conf') { - $user_level_conf = $conf['value']; - } - - if ($conf['token'] === 'integria_hostname') { - $api_hostname = $conf['value']; - } - - if ($conf['token'] === 'integria_api_pass') { - $api_pass = $conf['value']; - } - - if ($conf['token'] === 'integria_user') { - $user = $conf['value']; - } - - if ($conf['token'] === 'integria_pass') { - $user_pass = $conf['value']; - } - } - - if ($user_level_conf == true) { - $user = $user_info['integria_user_level_user']; - $user_pass = $user_info['integria_user_level_pass']; - } - - metaconsole_restore_db(); - } - } else { - if ($user_level_conf === null) { - $user_level_conf = (bool) $config['integria_user_level_conf']; - } - - $user_info = users_get_user_by_id($config['id_user']); - - // API access data. - if ($api_hostname === null) { - $api_hostname = $config['integria_hostname']; - } - - if ($api_pass === null) { - $api_pass = $config['integria_api_pass']; - } - - // Integria user and password. - if ($user === null || $user_level_conf === true) { - $user = $config['integria_user']; - - if ($user_level_conf === true) { - $user = $user_info['integria_user_level_user']; - } - } - - if ($user_pass === null || $user_level_conf === true) { - $user_pass = $config['integria_pass']; - - if ($user_level_conf === true) { - $user_pass = $user_info['integria_user_level_pass']; - } - } - } - - if (is_array($params)) { - $params = implode($token, $params); - } - - $url_data = [ - 'user' => $user, - 'user_pass' => $user_pass, - 'pass' => $api_pass, - 'op' => $operation, - 'params' => io_safe_output($params), - ]; - - if ($return_type !== '') { - $url_data['return_type'] = $return_type; - } - - if ($token !== '') { - $url_data['token'] = $token; - } - - // Build URL for API request. - $url = $api_hostname.'/include/api.php'; - - // ob_start(); - // $out = fopen('php://output', 'w'); - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $url_data); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_STDERR, $out); - $result = curl_exec($ch); - - // fclose($out); - // $debug = ob_get_clean(); - $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - $error = false; - - if ($result === false) { - $error = curl_error($ch); - } - - curl_close($ch); - - if ($error === true || $http_status !== 200) { - if ($show_credentials_error_msg === true) { - ui_print_error_message(__('API request failed. Please check Integria IMS\' access credentials in Pandora setup.')); - } - - return false; - } else { - return $result; - } -} - - -// Parse CSV consisting of one or more lines of the form key-value pair into an array. -function get_array_from_csv_data_pair($csv_data, &$array_values) -{ - $csv_array = explode("\n", $csv_data); - - foreach ($csv_array as $csv_value) { - if (empty($csv_value)) { - continue; - } - - $new_csv_value = str_getcsv($csv_value); - - $array_values[$new_csv_value[0]] = $new_csv_value[1]; - } -} - - -/** - * Parse CSV consisting of all lines into an array. - * - * @param string $csv_data Data returned of csv api call. - * @param string $array_values Returned array. - * @param array $index Array to create an associative index (opcional). - */ -function get_array_from_csv_data_all($csv_data, &$array_values, $index=false) -{ - $csv_array = explode("\n", $csv_data); - - foreach ($csv_array as $csv_value) { - if (empty($csv_value)) { - continue; - } - - $new_csv_value = str_getcsv($csv_value); - - if ($index !== false) { - foreach ($new_csv_value as $key => $value) { - $new_csv_value_index[$index[$key]] = str_replace(':::', ',', $value); - ; - } - - $array_values[$new_csv_value[0]] = $new_csv_value_index; - } else { - $new_csv_value_comma = array_map( - function ($item) { - return str_replace(':::', ',', $item); - }, - $new_csv_value - ); - $array_values[$new_csv_value[0]] = $new_csv_value_comma; - } - } -} - - -/** - * Print priority for Integria IMS with colors. - * - * @param string $priority value of priority in Integria IMS. - * @param string $priority_label text shown in color box. - * - * @return string HTML code. code to print the color box. - */ -function ui_print_integria_incident_priority($priority, $priority_label) -{ - global $config; - - $output = ''; - switch ($priority) { - case 0: - $color = COL_UNKNOWN; - break; - - case 1: - $color = COL_NORMAL; - break; - - case 10: - $color = COL_NOTINIT; - break; - - case 2: - $color = COL_WARNING; - break; - - case 3: - $color = COL_ALERTFIRED; - break; - - case 4: - $color = COL_CRITICAL; - break; - } - - $output = '
'; - $output .= $priority_label; - $output .= '
'; - - return $output; -} - - -/** - * Get tickets from Integria IMS. - * - * @param array $tickets_filters Filters to send to API. - * - * @return array Tickets returned by API call. - */ -function get_tickets_integriaims($tickets_filters) -{ - global $config; - - // Filters. - $incident_text = $tickets_filters['incident_text']; - $incident_status = $tickets_filters['incident_status']; - $incident_group = $tickets_filters['incident_group']; - $incident_owner = $tickets_filters['incident_owner']; - $incident_creator = $tickets_filters['incident_creator']; - $incident_priority = $tickets_filters['incident_priority']; - $incident_resolution = $tickets_filters['incident_resolution']; - $created_from = $tickets_filters['created_from']; - $created_to = $tickets_filters['created_to']; - - // API call. - $result_api_call_list = integria_api_call( - null, - null, - null, - null, - 'get_incidents', - [ - $incident_text, - $incident_status, - $incident_group, - $incident_priority, - '0', - $incident_owner, - $incident_creator, - ], - false, - '', - ',' - ); - - // Return array of api call 'get_incidents'. - $array_get_incidents = []; - get_array_from_csv_data_all($result_api_call_list, $array_get_incidents); - - // Modify $array_get_incidents if filter for resolution exists. - $filter_resolution = []; - foreach ($array_get_incidents as $key => $value) { - if ($incident_resolution !== '' && ($array_get_incidents[$key][12] == $incident_resolution)) { - $filter_resolution[$key] = $array_get_incidents[$key]; - continue; - } - } - - if ($incident_resolution !== '') { - $array_get_incidents = $filter_resolution; - } - - // Modify $array_get_incidents if filter for date is selected. - if ($created_from !== '' && $created_to !== '') { - $date = []; - $date_utimestamp = []; - foreach ($array_get_incidents as $key => $value) { - // Change format date / to -. - $date[$key] = date('Y-m-d', strtotime($array_get_incidents[$key][9])); - // Covert date to utimestamp. - $date_utimestamp[$key] = strtotime($date[$key]); - } - - // Change format date / to -. - $created_from_date = date('Y-m-d', strtotime($created_from)); - $created_to_date = date('Y-m-d', strtotime($created_to)); - - // Covert date to utimestamp. - $created_from_timestamp = strtotime($created_from_date); - $created_to_timestamp = strtotime($created_to_date); - - // Dates within the selected period. - $selected_period = array_filter( - $date_utimestamp, - function ($value) use ($created_from_timestamp, $created_to_timestamp) { - return ($value >= $created_from_timestamp && $value <= $created_to_timestamp); - } - ); - - // Return incidents with the correct dates. - $filter_date = []; - foreach ($array_get_incidents as $key => $value) { - foreach ($selected_period as $index => $value) { - if ($array_get_incidents[$key][0] == $index) { - $filter_date[$key] = $array_get_incidents[$key]; - continue; - } - } - } - - $array_get_incidents = $filter_date; - } - - return $array_get_incidents; -} - - -function integriaims_upload_file($filename, $incident_id, $file_description) -{ - if ($_FILES[$filename]['name'] != '') { - $filename = io_safe_input($_FILES[$filename]['name']); - $filesize = io_safe_input($_FILES[$filename]['size']); - - $extension = pathinfo($filename, PATHINFO_EXTENSION); - $invalid_extensions = '/^(bat|exe|cmd|sh|php|php1|php2|php3|php4|php5|pl|cgi|386|dll|com|torrent|js|app|jar|iso| - pif|vb|vbscript|wsf|asp|cer|csr|jsp|drv|sys|ade|adp|bas|chm|cpl|crt|csh|fxp|hlp|hta|inf|ins|isp|jse|htaccess| - htpasswd|ksh|lnk|mdb|mde|mdt|mdw|msc|msi|msp|mst|ops|pcd|prg|reg|scr|sct|shb|shs|url|vbe|vbs|wsc|wsf|wsh)$/i'; - - if (!preg_match($invalid_extensions, $extension)) { - // The following is if you have clamavlib installed. - // (php5-clamavlib) and enabled in php.ini - // http://www.howtoforge.com/scan_viruses_with_php_clamavlib - if (extension_loaded('clamav')) { - cl_setlimits(5, 1000, 200, 0, 10485760); - $malware = cl_scanfile($_FILES['file']['tmp_name']); - if ($malware) { - $error = 'Malware detected: '.$malware.'
ClamAV version: '.clam_get_version(); - die($error); - } - } - - $filecontent = base64_encode(file_get_contents($_FILES[$filename]['tmp_name'])); - - $result_api_call = integria_api_call(null, null, null, null, 'attach_file', [$incident_id, $filename, $filesize, $file_description, $filecontent], false, '', '|;|'); - - // API method returns '0' string if success. - $file_added = ($result_api_call === '0') ? true : false; - - ui_print_result_message( - $file_added, - __('File successfully added'), - __('File could not be added') - ); - } else { - ui_print_error_message(__('File has an invalid extension')); - } - } -} diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index a1927bb60a..346dee04b5 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -147,6 +147,12 @@ function menu_print_menu(&$menu) || $sec2 === 'enterprise/godmode/servers/manage_credential_boxes' ) { $sec2 = 'enterprise/godmode/servers/list_satellite'; + } else if ($sec2 === 'operation/ITSM/itsm') { + $sec2 = (string) get_parameter('sec2'); + $operation = (string) get_parameter('operation', ''); + if (empty($operation) === false) { + $sec2 = $sec2.'&operation='.$operation; + } } else { $sec2 = (string) get_parameter('sec2'); } @@ -287,7 +293,7 @@ function menu_print_menu(&$menu) } } - // Set class. + // Set class.; if (($sec2 == $subsec2 || $allsec2 == $subsec2 || $selected_submenu2) && isset($sub[$subsec2]['options']) && (get_parameter_get($sub[$subsec2]['options']['name']) == $sub[$subsec2]['options']['value']) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ee1f04b952..eab4e761d3 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -940,6 +940,57 @@ function reporting_make_reporting_data( ); break; + case 'top_n_agents_sh': + $report['contents'][] = reporting_top_n_agents_sh( + $report, + $content + ); + break; + + case 'top_n_checks_failed': + $report['contents'][] = reporting_top_n_checks_failed( + $report, + $content + ); + break; + + case 'top_n_categories_checks': + $report['contents'][] = reporting_top_n_categories_checks( + $report, + $content + ); + break; + + case 'vul_by_cat': + $report['contents'][] = reporting_vul_by_categories( + $report, + $content, + $type + ); + break; + + case 'list_checks': + $report['contents'][] = reporting_list_checks( + $report, + $content + ); + break; + + case 'scoring': + $report['contents'][] = reporting_scoring( + $report, + $content + ); + break; + + case 'evolution': + $report['contents'][] = reporting_evolution_hardening( + $report, + $content, + $type + ); + break; + default: // Default. break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 719ddfd7a3..0715b2f3f2 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -475,6 +475,34 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust case 'ncm': reporting_html_ncm_config($table, $item); break; + + case 'top_n_agents_sh': + reporting_html_top_n_agents_sh($table, $item); + break; + + case 'top_n_checks_failed': + reporting_html_top_n_checks_failed($table, $item); + break; + + case 'top_n_categories_checks': + reporting_html_top_n_categories_checks($table, $item); + break; + + case 'vul_by_cat': + reporting_vul_by_cat_graph($table, $item); + break; + + case 'list_checks': + reporting_html_list_checks($table, $item); + break; + + case 'scoring': + reporting_html_scoring($table, $item); + break; + + case 'evolution': + reporting_evolution_graph($table, $item); + break; } if ($item['type'] == 'agent_module') { @@ -490,6 +518,280 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } +/** + * Function to print the security hardening evolution. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ +function reporting_evolution_graph($table, $item) +{ + $table->rowclass[0] = ''; + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = $item['chart']; +} + + +/** + * Function to print the agents scoring. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return string + */ +function reporting_html_scoring($table, $item, $pdf=0) +{ + global $config; + + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = ''.__('Date').''; + $table1->head[1] = ''.__('Agent').''; + $table1->head[2] = ''.__('Score').''; + + $row = 1; + foreach ($item['data'] as $key => $check) { + $table1->data[$row][1] = date($config['date_format'], $check['date']); + $table1->data[$row][2] = $check['agent']; + $table1->data[$row][3] = $check['scoring'].' %'; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + +/** + * Function to print HTML checks filtered by agent and category. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return string + */ +function reporting_html_list_checks($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 4; + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = ''.__('Id').''; + $table1->head[1] = ''.__('Title').''; + $table1->head[2] = ''.__('Category').''; + $table1->head[3] = ''.__('Status').''; + + $row = 2; + foreach ($item['data'] as $key => $check) { + $table1->data[$row][0] = $check['id']; + $table1->data[$row][1] = $check['title']; + $table1->data[$row][2] = $check['category']; + $table1->data[$row][3] = $check['status']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + +/** + * Function to print HTML top checks failed by category + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return string + */ +function reporting_html_top_n_categories_checks($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = ''.__('Id').''; + $table1->head[1] = ''.__('Category').''; + $table1->head[2] = ''.__('Total Failed').''; + + $row = 2; + foreach ($item['data'] as $key => $check) { + $table1->data[$row][0] = $check['id']; + $table1->data[$row][1] = $check['category']; + $table1->data[$row][2] = $check['total']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + +/** + * Function to print HTML top checks failed. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return string + */ +function reporting_html_top_n_checks_failed($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->headstyle[1] = 'width: 10%; text-align: center;'; + $table1->style[2] = 'text-align: center;'; + $table1->rowclass[0] = ''; + $table1->head[0] = ''.__('Title').''; + $table1->head[1] = ''.__('Total Failed').''; + $table1->head[2] = ''.__('Description').''; + + $row = 2; + foreach ($item['data'] as $key => $check) { + $table1->data[$row][1] = $check['title']; + $table1->data[$row][2] = $check['total']; + $table1->data[$row][3] = $check['description']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + +/** + * Function to print HTML top categories in graph. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ +function reporting_vul_by_cat_graph($table, $item) +{ + $table->rowclass[0] = ''; + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = $item['chart']; +} + + +/** + * Function to print HTML top n agents from security hardening. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return string + */ +function reporting_html_top_n_agents_sh($table, $item, $pdf=0) +{ + global $config; + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle = []; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = ''.__('Agent').''; + $table1->head[1] = ''.__('Last audit scan').''; + $table1->head[2] = ''.__('Score').''; + + $row = 2; + foreach ($item['data'] as $key => $agent) { + $table1->data[$row][0] = $agent['alias']; + $table1->data[$row][1] = date($config['date_format'], $agent['utimestamp']); + $table1->data[$row][2] = $agent['datos'].' %'; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + /** * Function to print to HTML SLA report. * diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index f13e935b6a..1fe85aa92b 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -963,6 +963,43 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Network configuration changes'), ]; + if (enterprise_installed() === true) { + $types['top_n_agents_sh'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Top-N agents with the worst score'), + ]; + + $types['top_n_checks_failed'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Top-N most frequent failed checks'), + ]; + + $types['top_n_categories_checks'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Top-N checks failed by category'), + ]; + + $types['vul_by_cat'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Vulnerabilities by category'), + ]; + + $types['list_checks'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('List of checks'), + ]; + + $types['scoring'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Scoring by date'), + ]; + + $types['evolution'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Evolution'), + ]; + } + return $types; } diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index e4d1f655b0..3a4273efa4 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -283,6 +283,10 @@ function servers_get_performance($filter=[]) } foreach ($counts as $c) { + if (empty($c['modules']) === true) { + continue; + } + switch ($c['server_type']) { case SERVER_TYPE_DATA: $data['total_local_modules'] = $c['modules']; @@ -292,7 +296,7 @@ function servers_get_performance($filter=[]) case SERVER_TYPE_SNMP: case SERVER_TYPE_ENTERPRISE_ICMP: case SERVER_TYPE_ENTERPRISE_SNMP: - $data['total_network_modules'] = $c['modules']; + $data['total_network_modules'] += $c['modules']; break; case SERVER_TYPE_PLUGIN: diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 025276ecef..47f861314a 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -708,6 +708,13 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) $row['data'] = human_time_description_raw($agent['intervalo']); $table->data['interval'] = $row; + if (isset($agent['quiet']) && $agent['quiet']) { + $row = []; + $row['title'] = __('Quiet mode enabled'); + $row['data'] = ui_print_help_tip(__('This agent would not raise events or alerts'), true); + $table->data['quiet'] = $row; + } + // Comments. $row = []; $row['title'] = __('Description'); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 2431fb526d..51a2fd5336 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -609,12 +609,20 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) $tag = 'span'; } - if (empty($option['style']) === true) { - $style = 'class="'.($option['class'] ?? 'nowrap').'"'; + if (empty($option['class']) === false) { + $class = 'class="nowrap '.$option['class'].'"'; } else { - $style = 'style="'.$option['style'].'"'; + $class = 'class="nowrap"'; } + if (empty($option['style']) === false) { + $style = 'style="'.$option['style'].'"'; + } else { + $style = 'style=""'; + } + + $style .= ' '.$class; + if (empty($option['prominent']) === false) { $prominent = $option['prominent']; } else { @@ -1486,32 +1494,34 @@ function ui_format_alert_row( $actionText .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true); // Is possible manage actions if have LW permissions in the agent group of the alert module. - if (check_acl($config['id_user'], $id_group, 'LM')) { - $actionText .= ''.html_print_image( - 'images/delete.svg', - true, - [ - 'alt' => __('Delete action'), - 'title' => __('Delete action'), - 'class' => 'main_menu_icon invert_filter vertical_baseline', - ] - ).''; - } + if (is_metaconsole() === true) { + if (check_acl($config['id_user'], $id_group, 'LM')) { + $actionText .= ''.html_print_image( + 'images/delete.svg', + true, + [ + 'alt' => __('Delete action'), + 'title' => __('Delete action'), + 'class' => 'main_menu_icon invert_filter vertical_baseline', + ] + ).''; + } - if (check_acl($config['id_user'], $id_group, 'LW')) { - $actionText .= html_print_input_image( - 'update_action', - '/images/edit.svg', - 1, - 'padding:0px;', - true, - [ - 'title' => __('Update action'), - 'class' => 'main_menu_icon invert_filter', - 'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')', - ] - ); - $actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); + if (check_acl($config['id_user'], $id_group, 'LW')) { + $actionText .= html_print_input_image( + 'update_action', + '/images/edit.svg', + 1, + 'padding:0px;', + true, + [ + 'title' => __('Update action'), + 'class' => 'main_menu_icon invert_filter', + 'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')', + ] + ); + $actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); + } } $actionText .= '