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

This commit is contained in:
Daniel Barbero Martin 2021-05-20 08:21:31 +02:00
commit 73454dd4ea
30 changed files with 156 additions and 135 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.754-210519
Version: 7.0NG.754-210520
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.754"
PI_BUILD="210519"
PI_BUILD="210520"
OS_NAME=`uname -s`
FORCE=0

View File

@ -3,7 +3,7 @@
########################################################################
# Pandora FMS - Remote Event Tool (via WEB API)
########################################################################
# Copyright (c) 2013 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
@ -12,6 +12,7 @@
# Includes list
use strict;
use LWP::Simple;
use LWP::UserAgent;
use MIME::Base64;
use lib '/usr/lib/perl5';
use PandoraFMS::Tools;
@ -32,40 +33,41 @@ sub help_screen{
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
Where options:\n
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text
-group <id_group> : Group ID (use 0 for 'all')
-agent : Agent ID
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text (surrounded by single-quotes, for security reasons)
-group <id_group> : Group ID (use 0 for 'all')
Optional parameters:
[-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
[-agent <id_agent] : Agent ID
[-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
alert_manual_validation, system, error, new_agent
configuration_change, going_unknown, going_down_critical,
going_down_warning, going_up_normal
[-severity <severity>] : 0 Maintance,
[-severity <severity>] : 0 Maintance,
1 Informative,
2 Normal,
3 Warning,
4 Crit,
5 Minor,
6 Major
[-am <id_agent_module>] : ID Agent Module linked to event
[-alert <id_alert_am>] : ID Alert Module linked to event
[-am <id_agent_module>] : ID Agent Module linked to event
[-alert <id_alert_am>] : ID Alert Module linked to event
[-c_instructions <critical_instructions>]
[-w_instructions <warning_instructions>]
[-u_instructions <unknown_instructions>]
[-user_comment <comment>]
[-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported)
[-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
[-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported)
[-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
[-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1.
[-server_id <server_id>] : The pandora node server_id\n\n";
[-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
[-server_id <server_id>] : The pandora node server_id\n\n";
print "Example of event generation:\n\n";
@ -88,7 +90,7 @@ Optional parameters:
##############################################################################
sub tool_api_init () {
print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2015 Artica ST\n";
print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2021 Artica ST\n";
print "This program is Free Software, licensed under the terms of GPL License v2\n";
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
@ -120,7 +122,7 @@ sub tool_api_main () {
my $db_user;
my $db_pass;
my @db_info;
my $id_agent;
my $id_agent = '0';
my $id_user = '';
my $status = '';
my $id_agent_module = '';
@ -141,6 +143,7 @@ sub tool_api_main () {
my $call_api;
my $custom_data = "";
my $server_id = 0;
my $separator = '|';
#~ help or api path (required)
if ($ARGV[0] eq '-h') {
@ -185,12 +188,18 @@ sub tool_api_main () {
if ($line eq '-agent') {
$id_agent = $ARGV[$i + 1];
# If not defined, send 0 for API.
if ($id_agent eq undef) {
$id_agent = '0';
}
}
if ($line eq '-group') {
$id_group = $ARGV[$i + 1];
}
if ($line eq '-name') {
$event_name = $ARGV[$i + 1];
$event_name =~ s/#/%23/g;
}
if ($line eq '-type') {
$event_type = $ARGV[$i + 1];
@ -250,50 +259,49 @@ sub tool_api_main () {
if ($line eq '-server_id') {
$server_id = $ARGV[$i + 1];
}
if ($line eq '-separator') {
$separator = $ARGV[$i + 1];
}
$i++;
}
if ($event_name eq "") {
print "[ERROR] Missing id agent! Read help info:\n\n";
print "[ERROR] Missing event name! Read help info:\n\n";
help_screen ();
}
if ($id_group eq "") {
print "[ERROR] Missing event group! Read help info:\n\n";
help_screen ();
}
if ($id_agent eq "" && $agent_name eq "") {
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
help_screen ();
}
$data_event = $event_name .
"|" . $id_group .
"|" . $id_agent .
"|" . $status .
"|" . $id_user .
"|" . $event_type .
"|" . $severity .
"|" . $id_agent_module .
"|" . $id_alert_am .
"|" . $critical_instructions .
"|" . $warning_instructions .
"|" . $unknown_instructions .
"|" . $user_comment .
"|" . $owner_user .
"|" . $source .
"|" . $tags .
"|" . $custom_data .
"|" . $server_id .
"|" . $id_extra .
"|" . $agent_name .
"|" . $force_create_agent;
$separator . $id_group .
$separator . $id_agent .
$separator . $status .
$separator . $id_user .
$separator . $event_type .
$separator . $severity .
$separator . $id_agent_module .
$separator . $id_alert_am .
$separator . $critical_instructions .
$separator . $warning_instructions .
$separator . $unknown_instructions .
$separator . $user_comment .
$separator . $owner_user .
$separator . $source .
$separator . $tags .
$separator . $custom_data .
$separator . $server_id .
$separator . $id_extra .
$separator . $agent_name .
$separator . $force_create_agent;
$call_api = $api_path . '?' .
'op=set&' .
'op2=create_event&' .
'other=' . $data_event .'&' .
'other_mode=url_encode_separator_|&' .
'other_mode=url_encode_separator_'.$separator.'&' .
'apipass=' . $api_pass . '&' .
'user=' . $db_user . '&' .
'pass=' . $db_pass;
@ -321,7 +329,8 @@ sub tool_api_main () {
exit;
}
else {
my $content = get($call_api);
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $content = $ua->get($call_api);
if ($option eq '-create_event') {
if ($content eq undef) {
@ -329,7 +338,7 @@ sub tool_api_main () {
help_screen();
}
else {
print "Event ID: $content";
print "Event ID: $content->{'_content'}";
}
}
elsif ($option eq '-validate_event') {

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{210519}
{210520}
ViewReadme
{Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.754-210519
Version: 7.0NG.754-210520
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -867,6 +867,7 @@ class HTML
}
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>';
$output .= '<script>'.$js.'</script>';
if ($rawjs) {
@ -1002,6 +1003,7 @@ class HTML
$output .= '</div>';
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>';
$output .= '<script>'.$js.'</script>';
if ($rawjs) {
@ -1073,6 +1075,7 @@ class HTML
$output .= '</div>';
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>';
$output .= '<script>'.$js.'</script>';
if ($rawjs) {

View File

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

View File

@ -13043,8 +13043,10 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$error_msg = '';
if ($other['data'][2] != '') {
// Id agent assignment. If come from pandora_revent, id_agent can be 0.
$id_agent = $other['data'][2];
if (is_metaconsole()) {
// To the next if is metaconsole and id_agent is not none.
if (is_metaconsole() === true && $id_agent > 0) {
// On metaconsole, connect with the node to check the permissions
if (empty($values['server_id'])) {
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
@ -13067,7 +13069,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['id_agente'] = $id_agent;
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) {
if ((int) $id_agent > 0 && util_api_check_agent_and_print_error($id_agent, 'string', 'AR') === false) {
if (is_metaconsole()) {
metaconsole_restore_db();
}

View File

@ -4306,10 +4306,14 @@ function html_print_sort_arrows($params, $order_tag, $up='up', $down='down')
/**
* Print an input hidden with a new csrf token generated
*
* @param boolean $return If it is true return a string with the output instead to echo the output.
*
* @return void
*/
function html_print_csrf_hidden()
function html_print_csrf_hidden(bool $return=false)
{
html_print_input_hidden('csrf_code', generate_csrf_code());
return html_print_input_hidden('csrf_code', generate_csrf_code(), $return);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.754-210519
Version: 7.0NG.754-210520
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
########################################################################
# Pandora FMS - Remote Event Tool (via WEB API)
########################################################################
# Copyright (c) 2013-2021 Artica Soluciones Tecnologicas S.L
# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
@ -12,6 +12,7 @@
# Includes list
use strict;
use LWP::Simple;
use LWP::UserAgent;
use MIME::Base64;
use lib '/usr/lib/perl5';
use PandoraFMS::Tools;
@ -32,40 +33,41 @@ sub help_screen{
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
Where options:\n
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text
-group <id_group> : Group ID (use 0 for 'all')
-agent : Agent ID
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text (surrounded by single-quotes, for security reasons)
-group <id_group> : Group ID (use 0 for 'all')
Optional parameters:
[-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
[-agent <id_agent] : Agent ID
[-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
alert_manual_validation, system, error, new_agent
configuration_change, going_unknown, going_down_critical,
going_down_warning, going_up_normal
[-severity <severity>] : 0 Maintance,
[-severity <severity>] : 0 Maintance,
1 Informative,
2 Normal,
3 Warning,
4 Crit,
5 Minor,
6 Major
[-am <id_agent_module>] : ID Agent Module linked to event
[-alert <id_alert_am>] : ID Alert Module linked to event
[-am <id_agent_module>] : ID Agent Module linked to event
[-alert <id_alert_am>] : ID Alert Module linked to event
[-c_instructions <critical_instructions>]
[-w_instructions <warning_instructions>]
[-u_instructions <unknown_instructions>]
[-user_comment <comment>]
[-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported)
[-custom_data <custom_data>]: Custom data should be a base 64 encoded JSON document example -custom_data \'{\"test1\" : 1, \"test2\": 2}\'
[-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1.
[-server_id <server_id>] : The pandora node server_id\n\n";
[-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
[-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported)
[-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
[-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
[-server_id <server_id>] : The pandora node server_id\n\n";
print "Example of event generation:\n\n";
@ -120,7 +122,7 @@ sub tool_api_main () {
my $db_user;
my $db_pass;
my @db_info;
my $id_agent;
my $id_agent = '0';
my $id_user = '';
my $status = '';
my $id_agent_module = '';
@ -141,6 +143,7 @@ sub tool_api_main () {
my $call_api;
my $custom_data = "";
my $server_id = 0;
my $separator = '|';
#~ help or api path (required)
if ($ARGV[0] eq '-h') {
@ -185,12 +188,18 @@ sub tool_api_main () {
if ($line eq '-agent') {
$id_agent = $ARGV[$i + 1];
# If not defined, send 0 for API.
if ($id_agent eq undef) {
$id_agent = '0';
}
}
if ($line eq '-group') {
$id_group = $ARGV[$i + 1];
}
if ($line eq '-name') {
$event_name = $ARGV[$i + 1];
$event_name =~ s/#/%23/g;
}
if ($line eq '-type') {
$event_type = $ARGV[$i + 1];
@ -250,50 +259,49 @@ sub tool_api_main () {
if ($line eq '-server_id') {
$server_id = $ARGV[$i + 1];
}
if ($line eq '-separator') {
$separator = $ARGV[$i + 1];
}
$i++;
}
if ($event_name eq "") {
print "[ERROR] Missing id agent! Read help info:\n\n";
print "[ERROR] Missing event name! Read help info:\n\n";
help_screen ();
}
if ($id_group eq "") {
print "[ERROR] Missing event group! Read help info:\n\n";
help_screen ();
}
if ($id_agent eq "" && $agent_name eq "") {
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
help_screen ();
}
$data_event = $event_name .
"|" . $id_group .
"|" . $id_agent .
"|" . $status .
"|" . $id_user .
"|" . $event_type .
"|" . $severity .
"|" . $id_agent_module .
"|" . $id_alert_am .
"|" . $critical_instructions .
"|" . $warning_instructions .
"|" . $unknown_instructions .
"|" . $user_comment .
"|" . $owner_user .
"|" . $source .
"|" . $tags .
"|" . $custom_data .
"|" . $server_id .
"|" . $id_extra .
"|" . $agent_name .
"|" . $force_create_agent;
$separator . $id_group .
$separator . $id_agent .
$separator . $status .
$separator . $id_user .
$separator . $event_type .
$separator . $severity .
$separator . $id_agent_module .
$separator . $id_alert_am .
$separator . $critical_instructions .
$separator . $warning_instructions .
$separator . $unknown_instructions .
$separator . $user_comment .
$separator . $owner_user .
$separator . $source .
$separator . $tags .
$separator . $custom_data .
$separator . $server_id .
$separator . $id_extra .
$separator . $agent_name .
$separator . $force_create_agent;
$call_api = $api_path . '?' .
'op=set&' .
'op2=create_event&' .
'other=' . $data_event .'&' .
'other_mode=url_encode_separator_|&' .
'other_mode=url_encode_separator_'.$separator.'&' .
'apipass=' . $api_pass . '&' .
'user=' . $db_user . '&' .
'pass=' . $db_pass;
@ -321,13 +329,8 @@ sub tool_api_main () {
exit;
}
else {
#-----------DEBUG----------------------------
#print($call_api . "\n\n\n");
my $content = get($call_api);
#-----------DEBUG----------------------------
#print($content . "\n\n\n");
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $content = $ua->get($call_api);
if ($option eq '-create_event') {
if ($content eq undef) {
@ -335,7 +338,7 @@ sub tool_api_main () {
help_screen();
}
else {
print "Event ID: $content";
print "Event ID: $content->{'_content'}";
}
}
elsif ($option eq '-validate_event') {