Merge remote-tracking branch 'origin/develop' into ent-7074-Command-Center

This commit is contained in:
fbsanchez 2021-07-09 14:40:44 +02:00
commit 554a32b567
30 changed files with 166 additions and 30 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.755-210705 Version: 7.0NG.755-210709
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.755-210705" pandora_version="7.0NG.755-210709"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.755'; use constant AGENT_VERSION => '7.0NG.755';
use constant AGENT_BUILD => '210705'; use constant AGENT_BUILD => '210709';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.755" PI_VERSION="7.0NG.755"
PI_BUILD="210705" PI_BUILD="210709"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{210705} {210709}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.755 Build 210705") #define PANDORA_VERSION ("7.0NG.755 Build 210709")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.755(Build 210705))" VALUE "ProductVersion", "(7.0NG.755(Build 210709))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.755-210705 Version: 7.0NG.755-210709
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.755-210705" pandora_version="7.0NG.755-210709"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -37,4 +37,6 @@ UPDATE `tuser_task_scheduled` SET
UPDATE `tconfig` SET `centralized_management` = 0; UPDATE `tconfig` SET `centralized_management` = 0;
DELETE ta FROM `tagente` ta LEFT JOIN `tgrupo` tg on ta.`id_grupo` = tg.`id_grupo` WHERE tg.`id_grupo` IS NULL;
COMMIT; COMMIT;

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC210705'; $build_version = 'PC210709';
$pandora_version = 'v7.0NG.755'; $pandora_version = 'v7.0NG.755';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -251,6 +251,13 @@ function agents_create_agent(
return false; return false;
} }
if (has_metaconsole() === true
&& (bool) $config['metaconsole_agent_cache'] === true
) {
// Force an update of the agent cache.
$values['update_module_count'] = 1;
}
$id_agent = db_process_sql_insert('tagente', $values); $id_agent = db_process_sql_insert('tagente', $values);
if ($id_agent === false) { if ($id_agent === false) {
return false; return false;

View File

@ -3984,7 +3984,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
'plugin_pass' => $other['data'][24], 'plugin_pass' => $other['data'][24],
'plugin_parameter' => $other['data'][25], 'plugin_parameter' => $other['data'][25],
'disabled_types_event' => $disabled_types_event, 'disabled_types_event' => $disabled_types_event,
'macros' => base64_decode($other['data'][27]), 'macros' => base64_decode(str_replace('&#x20', '+', $other['data'][27])),
'module_macros' => $other['data'][28], 'module_macros' => $other['data'][28],
'each_ff' => $other['data'][29], 'each_ff' => $other['data'][29],
'min_ff_event_normal' => $other['data'][30], 'min_ff_event_normal' => $other['data'][30],
@ -3995,6 +3995,22 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
'ff_type' => $other['data'][35], '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']) { if (! $values['descripcion']) {
$values['descripcion'] = ''; $values['descripcion'] = '';
// Column 'descripcion' cannot be null. // Column 'descripcion' cannot be null.
@ -4145,13 +4161,29 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
$values[$field] = $other['data'][$cont]; $values[$field] = $other['data'][$cont];
if ($field === 'macros') { if ($field === 'macros') {
$values[$field] = base64_decode($values[$field]); $values[$field] = base64_decode(str_replace('&#x20', '+', $values[$field]));
} }
} }
$cont++; $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; $values['policy_linked'] = 0;
$result_update = modules_update_agent_module($id_module, $values); $result_update = modules_update_agent_module($id_module, $values);
@ -8317,7 +8349,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
return; return;
} }
if ($other['data'][22] == '') { if ($other['data'][21] == '') {
returnError('The plugin module could not be added. Id_plugin cannot be left blank.'); returnError('The plugin module could not be added. Id_plugin cannot be left blank.');
return; return;
} }
@ -8360,7 +8392,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
$values['plugin_pass'] = $other['data'][23]; $values['plugin_pass'] = $other['data'][23];
$values['plugin_parameter'] = $other['data'][24]; $values['plugin_parameter'] = $other['data'][24];
$values['disabled_types_event'] = $disabled_types_event; $values['disabled_types_event'] = $disabled_types_event;
$values['macros'] = base64_decode($other['data'][26]); $values['macros'] = base64_decode(str_replace('&#x20', '+', $other['data'][26]));
$values['module_macros'] = $other['data'][27]; $values['module_macros'] = $other['data'][27];
$values['each_ff'] = $other['data'][28]; $values['each_ff'] = $other['data'][28];
$values['min_ff_event_normal'] = $other['data'][29]; $values['min_ff_event_normal'] = $other['data'][29];
@ -8375,6 +8407,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]); $success = enterprise_hook('policies_create_module', [$other['data'][0], $id, 4, $values, false]);
if ($success) { if ($success) {

View File

@ -622,3 +622,82 @@ function io_safe_html_tags(string $string)
return $output; 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;
}

View File

@ -351,7 +351,7 @@ ul.tree-group
/* login.css */ /* login.css */
div.login_nick input, div.login_nick input,
div.login_pass input { div.login_pass input {
background-color: #fff !important; background-color: #111 !important;
} }
/* user edit */ /* user edit */

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.755'; $version = '7.0NG.755';
$build = '210705'; $build = '210709';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.755-210705 Version: 7.0NG.755-210709
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.755-210705" pandora_version="7.0NG.755-210709"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.755"; my $pandora_version = "7.0NG.755";
my $pandora_build = "210705"; my $pandora_build = "210709";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.755"; my $pandora_version = "7.0NG.755";
my $pandora_build = "210705"; my $pandora_build = "210709";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.755 %define version 7.0NG.755
%define release 210705 %define release 210709
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.755" PI_VERSION="7.0NG.755"
PI_BUILD="210705" PI_BUILD="210709"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.755 Build 210705"; my $version = "7.0NG.755 Build 210709";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.755 Build 210705"; my $version = "7.0NG.755 Build 210709";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);