From 2a964b52f16f00f0824d94e411654594abb597e3 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 1 Jul 2021 16:11:09 +0200 Subject: [PATCH 1/4] remove any agent belonging to a non-existent group --- pandora_console/extras/mr/48.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/extras/mr/48.sql b/pandora_console/extras/mr/48.sql index 52c22ff932..23bef60d4d 100644 --- a/pandora_console/extras/mr/48.sql +++ b/pandora_console/extras/mr/48.sql @@ -13,4 +13,6 @@ UPDATE `tuser_task_scheduled` SET ALTER TABLE `tlayout` ADD COLUMN `auto_adjust` INTEGER UNSIGNED NOT NULL default 0; +DELETE ta FROM `tagente` ta LEFT JOIN `tgrupo` tg on ta.`id_grupo` = tg.`id_grupo` WHERE tg.`id_grupo` IS NULL; + COMMIT; From b74beb76dfef800e9a51fcd21112a0bf2f6cfee1 Mon Sep 17 00:00:00 2001 From: Junichi Satoh Date: Tue, 6 Jul 2021 14:40:40 +0900 Subject: [PATCH 2/4] Fixed that plugin module related APIs did not work properly in some cases. --- pandora_console/include/functions_api.php | 56 ++++++++++++++-- pandora_console/include/functions_io.php | 79 +++++++++++++++++++++++ 2 files changed, 131 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 03fb8b9be2..c3363a8c76 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -3958,7 +3958,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) 'plugin_pass' => $other['data'][24], 'plugin_parameter' => $other['data'][25], 'disabled_types_event' => $disabled_types_event, - 'macros' => base64_decode($other['data'][27]), + 'macros' => base64_decode(str_replace(' ', '+', $other['data'][27])), 'module_macros' => $other['data'][28], 'each_ff' => $other['data'][29], 'min_ff_event_normal' => $other['data'][30], @@ -3969,6 +3969,22 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) 'ff_type' => $other['data'][35], ]; + $plugin = db_get_row('tplugin', 'id', $values['id_plugin']); + if (empty($plugin)) { + returnError('id_not_found'); + return; + } + $plugin_command_macros = $plugin['macros']; + + if (!empty($values['macros'])) { + $macros = io_safe_input_json($values['macros']); + if (empty($macros)) { + returnError('JSON string in macros is invalid.'); + exit; + } + $values['macros'] = io_merge_json_value($plugin_command_macros, $macros); + } + if (! $values['descripcion']) { $values['descripcion'] = ''; // Column 'descripcion' cannot be null. @@ -4119,13 +4135,29 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) $values[$field] = $other['data'][$cont]; if ($field === 'macros') { - $values[$field] = base64_decode($values[$field]); + $values[$field] = base64_decode(str_replace(' ', '+', $values[$field])); } } $cont++; } + $plugin = db_get_row('tplugin', 'id', $values['id_plugin']); + if (empty($plugin)) { + returnError('id_not_found'); + return; + } + $plugin_command_macros = $plugin['macros']; + + if (!empty($values['macros'])) { + $macros = io_safe_input_json($values['macros']); + if (empty($macros)) { + returnError('JSON string in macros is invalid.'); + exit; + } + $values['macros'] = io_merge_json_value($plugin_command_macros, $macros); + } + $values['policy_linked'] = 0; $result_update = modules_update_agent_module($id_module, $values); @@ -8205,7 +8237,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) return; } - if ($other['data'][22] == '') { + if ($other['data'][21] == '') { returnError('The plugin module could not be added. Id_plugin cannot be left blank.'); return; } @@ -8248,7 +8280,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) $values['plugin_pass'] = $other['data'][23]; $values['plugin_parameter'] = $other['data'][24]; $values['disabled_types_event'] = $disabled_types_event; - $values['macros'] = base64_decode($other['data'][26]); + $values['macros'] = base64_decode(str_replace(' ', '+', $other['data'][26])); $values['module_macros'] = $other['data'][27]; $values['each_ff'] = $other['data'][28]; $values['min_ff_event_normal'] = $other['data'][29]; @@ -8263,6 +8295,22 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) } } + $plugin = db_get_row('tplugin', 'id', $values['id_plugin']); + if (empty($plugin)) { + returnError('id_not_found'); + return; + } + $plugin_command_macros = $plugin['macros']; + + if (!empty($values['macros'])) { + $macros = io_safe_input_json($values['macros']); + if (empty($macros)) { + returnError('JSON string in macros is invalid.'); + exit; + } + $values['macros'] = io_merge_json_value($plugin_command_macros, $macros); + } + $success = enterprise_hook('policies_create_module', [$other['data'][0], $id, 4, $values, false]); if ($success) { diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 5edc3e5f49..ec888735f2 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -622,3 +622,82 @@ function io_safe_html_tags(string $string) return $output; } + +/** + * Execute io_safe_input againt each values in JSON. + * + * @param string json + * + * @return string json where each value is encoded + */ +function io_safe_input_json($json) +{ + $output_json = ""; + + if (empty($json)) { + return $output_json; + } + + $array_json = json_decode($json, true); + if (json_last_error() != JSON_ERROR_NONE) { + return $output_json; + } + + foreach ($array_json as $key => $value) { + if (is_array($value)) { + $value_json = json_encode($value, JSON_UNESCAPED_UNICODE); + $array_json[$key] = json_decode(io_safe_input_json($value_json), true); + } else { + $array_json[$key] = io_safe_input($value); + } + } + $output_json = json_encode($array_json, JSON_UNESCAPED_UNICODE); + + return $output_json; +} + +/** + * Merge json value in $json_merge to $json + * + * @param string json to be merged. + * @param string json containing the values to merge. + * @param boolean limit the values to be merged to those with a key of 'value', true by default. + * + * @retrun string merged json + * + * e.g.) + * arg1 json: {"1":{"macro":"_field1_","desc":"DESCRIPTION","help":"HELP","value":"","hide":""}} + * arg2 json: {"1":{"value":"xxxx"}} + * -> return json: {"1":{"macro":"_field1_","desc":"DESCRIPTION","help":"HELP","value":"xxxx","hide":""}} + */ +function io_merge_json_value($json, $json_merge, $value_key_only=true) +{ + $output_json = ""; + + $array_json = json_decode($json, true); + if (json_last_error() != JSON_ERROR_NONE) { + return $output_json; + } + $array_json_merge = json_decode($json_merge, true); + if (json_last_error() != JSON_ERROR_NONE) { + return $output_json; + } + + foreach ($array_json_merge as $key => $value) { + if (is_array($value) && !empty($array_json[$key])) { + $merged_json = io_merge_json_value( + json_encode($array_json[$key], JSON_UNESCAPED_UNICODE), + json_encode($value, JSON_UNESCAPED_UNICODE), + $value_key_only); + $array_json[$key] = json_decode($merged_json, true); + } else { + if (array_key_exists($key, $array_json) && + ($value_key_only == false || $key == 'value')) { + $array_json[$key] = $array_json_merge[$key]; + } + } + } + $output_json = json_encode($array_json, JSON_UNESCAPED_UNICODE); + + return $output_json; +} From 2bf5e16bb1258870d4f0d346f0889115843cdf39 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 6 Jul 2021 10:37:47 +0200 Subject: [PATCH 3/4] visual fix --- pandora_console/include/styles/pandora_black.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index 63a0bb6e85..be38bac7cc 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -351,7 +351,7 @@ ul.tree-group /* login.css */ div.login_nick input, div.login_pass input { - background-color: #fff !important; + background-color: #111 !important; } /* user edit */ From a06989dc117bf970338eb3816324d3e7b95c456c Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 7 Jul 2021 01:00:38 +0200 Subject: [PATCH 4/4] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index da1e45c12b..83b0269279 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.755-210706 +Version: 7.0NG.755-210707 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 23ed789c23..25feedd80c 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.755-210706" +pandora_version="7.0NG.755-210707" 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 bd25e8d1f7..d68daf0145 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.755'; -use constant AGENT_BUILD => '210706'; +use constant AGENT_BUILD => '210707'; # 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 b2cd9262e0..1291553fbf 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.755 -%define release 210706 +%define release 210707 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 87d5e00998..51c8b71634 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.755 -%define release 210706 +%define release 210707 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 e617f6db3e..ab18183459 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.755" -PI_BUILD="210706" +PI_BUILD="210707" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index cbf330ed7d..a8f230a93e 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210706} +{210707} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8f460f3dc0..3f5131338c 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.755 Build 210706") +#define PANDORA_VERSION ("7.0NG.755 Build 210707") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ddf90c7331..b5beee15e3 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.755(Build 210706))" + VALUE "ProductVersion", "(7.0NG.755(Build 210707))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8c533add88..040aa1bef3 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.755-210706 +Version: 7.0NG.755-210707 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 883f51a6c8..35037c9984 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.755-210706" +pandora_version="7.0NG.755-210707" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 3a3f4be4fe..1b9193fcf0 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210706'; +$build_version = 'PC210707'; $pandora_version = 'v7.0NG.755'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index da65920887..11cbf6c69e 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index fabd501aba..83eeb2855f 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.755 -%define release 210706 +%define release 210707 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c209de722d..9cef374e9e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.755 -%define release 210706 +%define release 210707 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 8b064abe85..3fff384ab1 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.755" -PI_BUILD="210706" +PI_BUILD="210707" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index ecae12c67d..7d5ba8e2b6 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.755 Build 210706"; +my $version = "7.0NG.755 Build 210707"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 441908864f..6eaad30bf4 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.755 Build 210706"; +my $version = "7.0NG.755 Build 210707"; # save program name for logging my $progname = basename($0);