Merge remote-tracking branch 'origin/ent-3431-discovery-host-devices' into ent-1798-monitorizacion-aws-amazon

Former-commit-id: d609bc3171cb75d89b641f6dd100e593ae5d1ebd
This commit is contained in:
fermin831 2019-02-19 11:01:11 +01:00
commit c9cc744e07
16 changed files with 306 additions and 308 deletions

View File

@ -1408,6 +1408,7 @@ ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
ALTER TABLE trecon_task ADD `auth_strings` text;
ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0';
-- ---------------------------------------------------------------------
-- Table `twidget` AND Table `twidget_dashboard`

View File

@ -32,12 +32,6 @@ require_once $config['homedir'].'/include/functions_notifications.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
include 'general/noaccess.php';
return;
}
// AJAX actions.
$source = get_parameter('source', '');
$users = get_parameter('users', '');
@ -102,6 +96,10 @@ if (get_parameter('check_new_notifications', 0)) {
return;
}
if (messages_get_count() == 0) {
return;
}
$messages = messages_get_overview(
'timestamp',
'ASC',

View File

@ -92,27 +92,24 @@ class HostDevices extends Wizard
$mode = get_parameter('mode', null);
if ($mode === null) {
$this->setBreadcrum(['<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>']);
$this->setBreadcrum(['<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd" class="text_color">Host & devices</a></div>']);
$this->printHeader();
echo '<div id="contenedor_principal">';
echo '<div id="contenedor_imagen_texto">';
echo '<div id="imagen">';
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv"><img src="images/wizard/csv_image.svg" alt="importcsv"></a>';
echo '</div>';
echo '<div class="texto">';
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv" id="text_wizard">'.__('Import CSV').'</a>';
echo '</div>';
echo '</div>';
echo '<div id="contenedor_imagen_texto">';
echo '<div id="imagen">';
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan"><img src="images/wizard/csv_image.svg" alt="importcsv"></a>';
echo '</div>';
echo '<div class="texto">';
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan" id="text_wizard">'.__('Escanear red').'</a>';
echo '</div>';
echo '</div>';
echo '</div>';
$this->printBigButtonsList(
[
[
'url' => $this->url.'&mode=importcsv',
'icon' => 'images/wizard/csv_image.svg',
'label' => __('Import CSV'),
],
[
'url' => $this->url.'&mode=netscan',
'icon' => 'images/wizard/csv_image.svg',
'label' => __('Net Scan'),
],
]
);
$this->printGoBackButton();
return;
}
@ -120,8 +117,8 @@ class HostDevices extends Wizard
if ($mode == 'importcsv') {
$this->setBreadcrum(
[
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=importcsv">Import CSV</a>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd" class="text_color">Host & devices</a></div>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=importcsv" class="text_color">Import CSV</a></div>',
]
);
$this->printHeader();
@ -135,10 +132,20 @@ class HostDevices extends Wizard
// Do not paint breadcrum in last page. Redirected.
$this->setBreadcrum(
[
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd"class="text_color">Host & devices</a></div>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan" class="text_color">Net scan definition</a></div>',
]
);
if ($this->page == 1) {
$this->setBreadcrum(
[
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd"class="text_color">Host & devices</a></div>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan" class="text_color">Net scan definition</a></div>',
'<div class="arrow_box"><a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page=1" class="text_color">Net scan features</a></div>',
]
);
}
$this->printHeader();
}
@ -206,6 +213,7 @@ class HostDevices extends Wizard
$server_id = get_parameter('id_recon_server', '');
$network = get_parameter('network', '');
$id_group = get_parameter('id_group', '');
$interval = get_parameter('interval', 0);
if (isset($task_id) === true) {
// We're updating this task.
@ -269,6 +277,7 @@ class HostDevices extends Wizard
$this->task['subnet'] = $network;
$this->task['id_recon_server'] = $server_id;
$this->task['id_group'] = $id_group;
$this->task['interval_sweep'] = $interval;
if (isset($this->task['id_rt']) === false) {
// Create.
@ -306,6 +315,9 @@ class HostDevices extends Wizard
}
$id_network_profile = get_parameter('id_network_profile', null);
$autoconf_enabled = get_parameter_switch(
'autoconfiguration_enabled'
);
$snmp_enabled = get_parameter_switch('snmp_enabled');
$os_detect = get_parameter_switch('os_detect');
$parent_detection = get_parameter_switch('parent_detection');
@ -330,6 +342,7 @@ class HostDevices extends Wizard
$this->task['snmp_community'] = $community;
}
$this->task['autoconfiguration_enabled'] = $autoconf_enabled;
$this->task['id_network_profile'] = $id_network_profile;
$this->task['snmp_enabled'] = $snmp_enabled;
$this->task['os_detect'] = $os_detect;
@ -347,42 +360,6 @@ class HostDevices extends Wizard
$this->task['snmp_security_level'] = $snmp_security_level;
$this->task['auth_strings'] = $auth_strings;
// Update.
$res = db_process_sql_update(
'trecon_task',
$this->task,
['id_rt' => $this->task['id_rt']]
);
return true;
}
if ($this->page == 3) {
// Interval and schedules.
// By default manual if not defined.
$id_rt = get_parameter('task', -1);
$task = db_get_row(
'trecon_task',
'id_rt',
$id_rt
);
if ($task !== false) {
$this->task = $task;
} else {
$this->msg = __('Failed to find network scan task.');
return false;
}
$interval = get_parameter('interval', 0);
$id_os = get_parameter('id_os', 0);
$recon_ports = get_parameter('recon_ports', '');
$this->task['id_os'] = $id_os;
$this->task['interval_sweep'] = $interval;
$this->task['recon_ports'] = $recon_ports;
if ($this->task['disabled'] == 2) {
// Wizard finished.
$this->task['disabled'] = 0;
@ -398,7 +375,7 @@ class HostDevices extends Wizard
return true;
}
if ($this->page == 4) {
if ($this->page == 3) {
// Wizard ended. Load data and return control to Discovery.
$id_rt = get_parameter('task', -1);
@ -443,9 +420,6 @@ class HostDevices extends Wizard
return;
}
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
$user_groups = array_keys($user_groups);
if ($this->parseNetScan() === false) {
// Error.
ui_print_error_message(
@ -477,11 +451,22 @@ class HostDevices extends Wizard
],
];
// Check ACL. If user is not able to manage target task,
// redirect him to main page.
if (users_is_admin() !== true && check_acl(
$config['id_usuario'],
$this->task['id_group'],
'PM'
) !== true
) {
$form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1);
}
$this->printForm($form);
return null;
}
if (isset($this->page)
if (isset($this->page) === true
&& $this->page != 0
&& isset($this->task['id_rt']) === false
) {
@ -522,7 +507,7 @@ class HostDevices extends Wizard
// -------------------------------.
// Page 0. wizard starts HERE.
// -------------------------------.
if (!isset($this->page) || $this->page == 0) {
if (isset($this->page) === true || $this->page == 0) {
if (isset($this->page) === false
|| $this->page == 0
) {
@ -610,6 +595,44 @@ class HostDevices extends Wizard
],
];
// Interval and schedules.
$interv_manual = 0;
if ((int) $this->task['interval_sweep'] == 0) {
$interv_manual = 1;
}
// Schedule.
$form['inputs'][] = [
'label' => '<b>'.__('Interval').'</b>'.ui_print_help_tip(
__('Manual interval means that it will be executed only On-demand'),
true
),
'arguments' => [
'type' => 'select',
'selected' => $interv_manual,
'fields' => [
0 => __('Defined'),
1 => __('Manual'),
],
'name' => 'interval_manual_defined',
'return' => true,
],
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
'interval',
$this->task['interval_sweep'],
'',
'',
'0',
false,
true,
false,
false
).ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
).'</span>',
];
$str = __('Next');
if (isset($this->task['id_rt']) === true) {
@ -637,6 +660,21 @@ class HostDevices extends Wizard
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
];
$form['js'] = '
$("select#interval_manual_defined").change(function() {
if ($("#interval_manual_defined").val() == 1) {
$("#interval_manual_container").hide();
$("#text-interval_text").val(0);
$("#hidden-interval").val(0);
}
else {
$("#interval_manual_container").show();
$("#text-interval_text").val(10);
$("#hidden-interval").val(600);
$("#interval_units").val(60);
}
}).change();';
// XXX: Could be improved validating inputs before continue (JS)
// Print NetScan page 0.
$this->printForm($form);
@ -675,17 +713,38 @@ class HostDevices extends Wizard
$form['inputs'][] = [
'label' => __('Module template'),
'arguments' => [
'name' => 'id_network_profile',
'type' => 'select_from_sql',
'sql' => 'SELECT id_np, name
'name' => 'id_network_profile',
'type' => 'select_from_sql',
'sql' => 'SELECT id_np, name
FROM tnetwork_profile
ORDER BY name',
'return' => true,
'selected' => $this->task['id_network_profile'],
'return' => true,
'selected' => $this->task['id_network_profile'],
'nothing_value' => 0,
'nothing' => __('None'),
],
];
if (enterprise_installed() === true) {
// Input: Enable auto configuration.
$form['inputs'][] = [
'label' => __('Apply autoconfiguration rules').ui_print_help_tip(
__(
'System is able to auto configure detected host & devices by applying your defined configuration rules.'
),
true
),
'arguments' => [
'name' => 'autoconfiguration_enabled',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['autoconfiguration_enabled'])) ? $this->task['autoconfiguration_enabled'] : 0,
],
];
}
// Feature configuration.
// Input: SNMP enabled.
$form['inputs'][] = [
@ -875,7 +934,12 @@ class HostDevices extends Wizard
'hidden' => 1,
'block_content' => [
[
'label' => __('WMI Auth. strings'),
'label' => '<b>'.__('WMI Auth. strings').'</b>'.ui_print_help_tip(
__(
'Auth strings must be defined as user%pass, comma separated as many you need.'
),
true
),
'arguments' => [
'name' => 'auth_strings',
'type' => 'text',
@ -946,7 +1010,7 @@ class HostDevices extends Wizard
$form['inputs'][] = [
'arguments' => [
'name' => 'submit',
'label' => __('Next'),
'label' => __('Finish'),
'type' => 'submit',
'attributes' => 'class="sub next"',
'return' => true,
@ -958,6 +1022,7 @@ function SNMPExtraShow(target) {
$("#snmp_options_basic").hide();
$("#snmp_options_v3").hide();
if (document.getElementsByName("snmp_enabled")[0].checked) {
$("#snmp_extra").show();
if (target == 3) {
$("#snmp_options_v3").show();
} else {
@ -1012,129 +1077,6 @@ $(function() {
}
if ($this->page == 2) {
// Interval and schedules.
$interv_manual = 0;
if ((int) $this->task['interval_sweep'] == 0) {
$interv_manual = 1;
}
// Filter: OS.
$form['inputs'][] = [
'label' => '<b>'.__('Filter by OS').'</b>',
'arguments' => [
'type' => 'select_from_sql',
'sql' => 'SELECT id_os, name
FROM tconfig_os
ORDER BY name',
'name' => 'id_os',
'return' => 'true',
'nothing' => __('Any'),
'selected' => $this->task['id_os'],
],
];
// Filter: Ports.
$form['inputs'][] = [
'label' => '<b>'.__('Filter by ports').'</b>'.ui_print_help_tip(
__('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'),
true
),
'arguments' => [
'type' => 'text',
'name' => 'recon_ports',
'return' => 'true',
'recon_ports' => $this->task['recon_ports'],
],
];
// Schedule.
$form['inputs'][] = [
'label' => '<b>'.__('Interval').'</b>'.ui_print_help_tip(
__('Manual interval means that it will be executed only On-demand'),
true
),
'arguments' => [
'type' => 'select',
'selected' => $interv_manual,
'fields' => [
0 => __('Defined'),
1 => __('Manual'),
],
'name' => 'interval_manual_defined',
'return' => true,
],
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
'interval',
$this->task['interval_sweep'],
'',
'',
'0',
false,
true,
false,
false
).ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
).'</span>',
];
// Hidden, id_rt.
$form['inputs'][] = [
'arguments' => [
'name' => 'task',
'value' => $this->task['id_rt'],
'type' => 'hidden',
'return' => true,
],
];
// Hidden, page.
$form['inputs'][] = [
'arguments' => [
'name' => 'page',
'value' => ($this->page + 1),
'type' => 'hidden',
'return' => true,
],
];
// Submit button.
$form['inputs'][] = [
'arguments' => [
'name' => 'submit',
'label' => __('Next'),
'type' => 'submit',
'attributes' => 'class="sub next"',
'return' => true,
],
];
$form['form'] = [
'method' => 'POST',
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'],
];
$form['js'] = '
$("select#interval_manual_defined").change(function() {
if ($("#interval_manual_defined").val() == 1) {
$("#interval_manual_container").hide();
$("#text-interval_text").val(0);
$("#hidden-interval").val(0);
}
else {
$("#interval_manual_container").show();
$("#text-interval_text").val(10);
$("#hidden-interval").val(600);
$("#interval_units").val(60);
}
}).change();';
$this->printForm($form);
return null;
}
if ($this->page == 3) {
if ($this->task['id_rt']) {
// 0 - Is OK.
$this->result = 0;

View File

@ -124,7 +124,7 @@ class Wizard
*/
public function printBreadcrum()
{
return '<h1>'.implode(' > ', $this->breadcrum).'</h1>';
return '<h1>'.implode('', $this->breadcrum).'</h1>';
}
@ -518,7 +518,8 @@ class Wizard
*
* @return void Print the full list.
*/
public static function printBigButtonsList($list_data) {
public static function printBigButtonsList($list_data)
{
echo '<ul>';
array_map('self::printBigButtonElement', $list_data);
echo '</ul>';

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path d="M 17.660156 4 C 16.320156 4 15.059141 4.5209375 14.119141 5.4609375 L 5.4609375 14.119141 C 4.5209375 15.069141 4 16.320156 4 17.660156 L 4 57 C 4 58.65 5.35 60 7 60 L 47 60 C 48.65 60 50 58.65 50 57 L 50 46 L 58 46 C 59.1 46 60 45.1 60 44 L 60 24 C 60 22.9 59.1 22 58 22 L 50 22 L 50 7 C 50 5.35 48.65 4 47 4 L 17.660156 4 z M 18 6 L 47 6 C 47.55 6 48 6.45 48 7 L 48 22 L 16 22 C 14.9 22 14 22.9 14 24 L 14 44 C 14 45.1 14.9 46 16 46 L 48 46 L 48 57 C 48 57.55 47.55 58 47 58 L 7 58 C 6.45 58 6 57.55 6 57 L 6 18 L 15 18 C 16.654 18 18 16.654 18 15 L 18 6 z M 16 6.4980469 L 16 15 C 16 15.552 15.552 16 15 16 L 6.5019531 16 C 6.6119531 15.834 6.7388594 15.679063 6.8808594 15.539062 L 15.539062 6.8808594 C 15.681062 6.7368594 15.836 6.6080469 16 6.4980469 z M 16 24 L 48 24 L 50 24 L 58 24 L 58 44 L 50 44 L 48 44 L 16 44 L 16 24 z M 27 28 C 25.346 28 24 29.346 24 31 L 24 37 C 24 38.654 25.346 40 27 40 L 29 40 C 30.654 40 32 38.654 32 37 C 32 36.447 31.553 36 31 36 C 30.447 36 30 36.447 30 37 C 30 37.552 29.552 38 29 38 L 27 38 C 26.448 38 26 37.552 26 37 L 26 31 C 26 30.448 26.448 30 27 30 L 29 30 C 29.552 30 30 30.448 30 31 C 30 31.553 30.447 32 31 32 C 31.553 32 32 31.553 32 31 C 32 29.346 30.654 28 29 28 L 27 28 z M 37 28 C 35.346 28 34 29.346 34 31 L 34 32 C 34 33.654 35.346 35 37 35 L 39 35 C 39.552 35 40 35.448 40 36 L 40 37 C 40 37.552 39.552 38 39 38 L 37 38 C 36.448 38 36 37.552 36 37 C 36 36.447 35.553 36 35 36 C 34.447 36 34 36.447 34 37 C 34 38.654 35.346 40 37 40 L 39 40 C 40.654 40 42 38.654 42 37 L 42 36 C 42 34.346 40.654 33 39 33 L 37 33 C 36.448 33 36 32.552 36 32 L 36 31 C 36 30.448 36.448 30 37 30 L 39 30 C 39.552 30 40 30.448 40 31 C 40 31.553 40.447 32 41 32 C 41.553 32 42 31.553 42 31 C 42 29.346 40.654 28 39 28 L 37 28 z M 45.109375 28.005859 C 44.980234 27.991641 44.845391 28.003719 44.712891 28.042969 C 44.183891 28.201969 43.884969 28.759109 44.042969 29.287109 L 47.042969 39.287109 C 47.169969 39.710109 47.559 40 48 40 C 48.441 40 48.830031 39.710109 48.957031 39.287109 L 51.957031 29.287109 C 52.115031 28.759109 51.816109 28.201969 51.287109 28.042969 C 50.755109 27.885969 50.200969 28.183891 50.042969 28.712891 L 48 35.519531 L 45.957031 28.712891 C 45.837781 28.316141 45.496797 28.048516 45.109375 28.005859 z M 9 52 C 8.447 52 8 52.447 8 53 L 8 55 C 8 55.553 8.447 56 9 56 C 9.553 56 10 55.553 10 55 L 10 53 C 10 52.447 9.553 52 9 52 z M 14 52 C 13.447 52 13 52.447 13 53 L 13 55 C 13 55.553 13.447 56 14 56 C 14.553 56 15 55.553 15 55 L 15 53 C 15 52.447 14.553 52 14 52 z M 19 52 C 18.447 52 18 52.447 18 53 L 18 55 C 18 55.553 18.447 56 19 56 C 19.553 56 20 55.553 20 55 L 20 53 C 20 52.447 19.553 52 19 52 z M 24 52 C 23.447 52 23 52.447 23 53 L 23 55 C 23 55.553 23.447 56 24 56 C 24.553 56 25 55.553 25 55 L 25 53 C 25 52.447 24.553 52 24 52 z M 29 52 C 28.447 52 28 52.447 28 53 L 28 55 C 28 55.553 28.447 56 29 56 C 29.553 56 30 55.553 30 55 L 30 53 C 30 52.447 29.553 52 29 52 z M 34 52 C 33.447 52 33 52.447 33 53 L 33 55 C 33 55.553 33.447 56 34 56 C 34.553 56 35 55.553 35 55 L 35 53 C 35 52.447 34.553 52 34 52 z M 39 52 C 38.447 52 38 52.447 38 53 L 38 55 C 38 55.553 38.447 56 39 56 C 39.553 56 40 55.553 40 55 L 40 53 C 40 52.447 39.553 52 39 52 z M 44 52 C 43.447 52 43 52.447 43 53 L 43 55 C 43 55.553 43.447 56 44 56 C 44.553 56 45 55.553 45 55 L 45 53 C 45 52.447 44.553 52 44 52 z"/>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 4 5 L 4 6 L 4 13 L 28 13 L 28 5 L 4 5 z M 6 7 L 26 7 L 26 11 L 6 11 L 6 7 z M 8 8 A 1 1 0 0 0 7 9 A 1 1 0 0 0 8 10 A 1 1 0 0 0 9 9 A 1 1 0 0 0 8 8 z M 11 8 A 1 1 0 0 0 10 9 A 1 1 0 0 0 11 10 A 1 1 0 0 0 12 9 A 1 1 0 0 0 11 8 z M 14 8 A 1 1 0 0 0 13 9 A 1 1 0 0 0 14 10 A 1 1 0 0 0 15 9 A 1 1 0 0 0 14 8 z M 4 14 L 4 27 L 28 27 L 28 14 L 26 14 L 26 25 L 6 25 L 6 14 L 4 14 z M 8 15 L 8 16 L 8 23 L 16 23 L 16 15 L 8 15 z M 18 15 L 18 17 L 24 17 L 24 15 L 18 15 z M 10 17 L 14 17 L 14 21 L 10 21 L 10 17 z M 18 18 L 18 20 L 24 20 L 24 18 L 18 18 z M 18 21 L 18 23 L 24 23 L 24 21 L 18 21 z"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 913 B

View File

@ -1,4 +1,3 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path d="M 17.660156 4 C 16.320156 4 15.059141 4.5209375 14.119141 5.4609375 L 5.4609375 14.119141 C 4.5209375 15.069141 4 16.320156 4 17.660156 L 4 57 C 4 58.65 5.35 60 7 60 L 47 60 C 48.65 60 50 58.65 50 57 L 50 46 L 58 46 C 59.1 46 60 45.1 60 44 L 60 24 C 60 22.9 59.1 22 58 22 L 50 22 L 50 7 C 50 5.35 48.65 4 47 4 L 17.660156 4 z M 18 6 L 47 6 C 47.55 6 48 6.45 48 7 L 48 22 L 16 22 C 14.9 22 14 22.9 14 24 L 14 44 C 14 45.1 14.9 46 16 46 L 48 46 L 48 57 C 48 57.55 47.55 58 47 58 L 7 58 C 6.45 58 6 57.55 6 57 L 6 18 L 15 18 C 16.654 18 18 16.654 18 15 L 18 6 z M 16 6.4980469 L 16 15 C 16 15.552 15.552 16 15 16 L 6.5019531 16 C 6.6119531 15.834 6.7388594 15.679063 6.8808594 15.539062 L 15.539062 6.8808594 C 15.681062 6.7368594 15.836 6.6080469 16 6.4980469 z M 16 24 L 48 24 L 50 24 L 58 24 L 58 44 L 50 44 L 48 44 L 16 44 L 16 24 z M 27 28 C 25.346 28 24 29.346 24 31 L 24 37 C 24 38.654 25.346 40 27 40 L 29 40 C 30.654 40 32 38.654 32 37 C 32 36.447 31.553 36 31 36 C 30.447 36 30 36.447 30 37 C 30 37.552 29.552 38 29 38 L 27 38 C 26.448 38 26 37.552 26 37 L 26 31 C 26 30.448 26.448 30 27 30 L 29 30 C 29.552 30 30 30.448 30 31 C 30 31.553 30.447 32 31 32 C 31.553 32 32 31.553 32 31 C 32 29.346 30.654 28 29 28 L 27 28 z M 37 28 C 35.346 28 34 29.346 34 31 L 34 32 C 34 33.654 35.346 35 37 35 L 39 35 C 39.552 35 40 35.448 40 36 L 40 37 C 40 37.552 39.552 38 39 38 L 37 38 C 36.448 38 36 37.552 36 37 C 36 36.447 35.553 36 35 36 C 34.447 36 34 36.447 34 37 C 34 38.654 35.346 40 37 40 L 39 40 C 40.654 40 42 38.654 42 37 L 42 36 C 42 34.346 40.654 33 39 33 L 37 33 C 36.448 33 36 32.552 36 32 L 36 31 C 36 30.448 36.448 30 37 30 L 39 30 C 39.552 30 40 30.448 40 31 C 40 31.553 40.447 32 41 32 C 41.553 32 42 31.553 42 31 C 42 29.346 40.654 28 39 28 L 37 28 z M 45.109375 28.005859 C 44.980234 27.991641 44.845391 28.003719 44.712891 28.042969 C 44.183891 28.201969 43.884969 28.759109 44.042969 29.287109 L 47.042969 39.287109 C 47.169969 39.710109 47.559 40 48 40 C 48.441 40 48.830031 39.710109 48.957031 39.287109 L 51.957031 29.287109 C 52.115031 28.759109 51.816109 28.201969 51.287109 28.042969 C 50.755109 27.885969 50.200969 28.183891 50.042969 28.712891 L 48 35.519531 L 45.957031 28.712891 C 45.837781 28.316141 45.496797 28.048516 45.109375 28.005859 z M 9 52 C 8.447 52 8 52.447 8 53 L 8 55 C 8 55.553 8.447 56 9 56 C 9.553 56 10 55.553 10 55 L 10 53 C 10 52.447 9.553 52 9 52 z M 14 52 C 13.447 52 13 52.447 13 53 L 13 55 C 13 55.553 13.447 56 14 56 C 14.553 56 15 55.553 15 55 L 15 53 C 15 52.447 14.553 52 14 52 z M 19 52 C 18.447 52 18 52.447 18 53 L 18 55 C 18 55.553 18.447 56 19 56 C 19.553 56 20 55.553 20 55 L 20 53 C 20 52.447 19.553 52 19 52 z M 24 52 C 23.447 52 23 52.447 23 53 L 23 55 C 23 55.553 23.447 56 24 56 C 24.553 56 25 55.553 25 55 L 25 53 C 25 52.447 24.553 52 24 52 z M 29 52 C 28.447 52 28 52.447 28 53 L 28 55 C 28 55.553 28.447 56 29 56 C 29.553 56 30 55.553 30 55 L 30 53 C 30 52.447 29.553 52 29 52 z M 34 52 C 33.447 52 33 52.447 33 53 L 33 55 C 33 55.553 33.447 56 34 56 C 34.553 56 35 55.553 35 55 L 35 53 C 35 52.447 34.553 52 34 52 z M 39 52 C 38.447 52 38 52.447 38 53 L 38 55 C 38 55.553 38.447 56 39 56 C 39.553 56 40 55.553 40 55 L 40 53 C 40 52.447 39.553 52 39 52 z M 44 52 C 43.447 52 43 52.447 43 53 L 43 55 C 43 55.553 43.447 56 44 56 C 44.553 56 45 55.553 45 55 L 45 53 C 45 52.447 44.553 52 44 52 z"/>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 1.5 3 A 0.50005 0.50005 0 0 0 1 3.5 L 1 5.5 A 0.50005 0.50005 0 0 0 1.5 6 L 3.5 6 A 0.50005 0.50005 0 0 0 4 5.5 L 4 3.5 A 0.50005 0.50005 0 0 0 3.5 3 L 1.5 3 z M 8.5 3 A 0.50005 0.50005 0 0 0 8 3.5 L 8 5.5 A 0.50005 0.50005 0 0 0 8.5 6 L 10.5 6 A 0.50005 0.50005 0 0 0 11 5.5 L 11 3.5 A 0.50005 0.50005 0 0 0 10.5 3 L 8.5 3 z M 2 4 L 3 4 L 3 5 L 2 5 L 2 4 z M 5 4 L 5 5 L 7 5 L 7 4 L 5 4 z M 9 4 L 10 4 L 10 5 L 9 5 L 9 4 z M 12 4 L 12 5 L 14 5 L 14 4 L 12 4 z M 1.5 7 A 0.50005 0.50005 0 0 0 1 7.5 L 1 9.5 A 0.50005 0.50005 0 0 0 1.5 10 L 3.5 10 A 0.50005 0.50005 0 0 0 4 9.5 L 4 7.5 A 0.50005 0.50005 0 0 0 3.5 7 L 1.5 7 z M 8.5 7 A 0.50005 0.50005 0 0 0 8 7.5 L 8 9.5 A 0.50005 0.50005 0 0 0 8.5 10 L 10.5 10 A 0.50005 0.50005 0 0 0 11 9.5 L 11 7.5 A 0.50005 0.50005 0 0 0 10.5 7 L 8.5 7 z M 2 8 L 3 8 L 3 9 L 2 9 L 2 8 z M 5 8 L 5 9 L 7 9 L 7 8 L 5 8 z M 9 8 L 10 8 L 10 9 L 9 9 L 9 8 z M 12 8 L 12 9 L 14 9 L 14 8 L 12 8 z M 1.5 11 A 0.50005 0.50005 0 0 0 1 11.5 L 1 13.5 A 0.50005 0.50005 0 0 0 1.5 14 L 3.5 14 A 0.50005 0.50005 0 0 0 4 13.5 L 4 11.5 A 0.50005 0.50005 0 0 0 3.5 11 L 1.5 11 z M 8.5 11 A 0.50005 0.50005 0 0 0 8 11.5 L 8 13.5 A 0.50005 0.50005 0 0 0 8.5 14 L 10.5 14 A 0.50005 0.50005 0 0 0 11 13.5 L 11 11.5 A 0.50005 0.50005 0 0 0 10.5 11 L 8.5 11 z M 2 12 L 3 12 L 3 13 L 2 13 L 2 12 z M 5 12 L 5 13 L 7 13 L 7 12 L 5 12 z M 9 12 L 10 12 L 10 13 L 9 13 L 9 12 z M 12 12 L 12 13 L 14 13 L 14 12 L 12 12 z"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -706,6 +706,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
$i = 1;
$max = count($values);
foreach ($values as $field => $value) {
$negative = false;
if (is_numeric($field)) {
// User provide the exact operation to do
$query .= $value;
@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
continue;
}
if ($field[0] == '!') {
$negative = true;
$field = substr($field, 1);
}
if ($field[0] != '`') {
// If the field is as <table>.<field>, don't scape.
if (strstr($field, '.') === false) {
@ -732,7 +738,8 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
} else if (is_float($value) || is_double($value)) {
$query .= sprintf('%s = %f', $field, $value);
} else if (is_array($value)) {
$query .= sprintf('%s IN ("%s")', $field, implode('", "', $value));
$not = $negative ? ' NOT ' : '';
$query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value));
} else {
if ($value === '') {
// Search empty string

View File

@ -356,42 +356,59 @@ function messages_get_count(
if (!empty($incl_read)) {
// Do not filter.
$read = '';
$read = ' 1=1 ';
} else {
// Retrieve only unread messages.
$read = 'where t.read is null';
$read = ' t.read is null';
}
if ($ignore_source === true) {
$source_select = '';
$source_sql = '';
$source_extra = '';
} else {
$source_sql = 'INNER JOIN tnotification_source ns
ON tm.id_source = ns.id
AND ns.enabled = 1';
$source_select = ',IF(ns.user_editable,nsu.enabled,ns.enabled) as enabled';
// Row in tnotification_source_user could exist or not.
$source_sql = sprintf(
'INNER JOIN (
tnotification_source ns
LEFT JOIN tnotification_source_user nsu
ON ns.id=nsu.id_source
AND nsu.id_user="test")
ON tm.id_source=ns.id',
$user
);
$source_extra = 'AND (t.enabled=1 OR t.enabled is null)';
}
$sql = sprintf(
'SELECT count(*) FROM (
SELECT DISTINCT tm.*, utimestamp_read > 0 as "read"
FROM tmensajes tm
%s
LEFT JOIN tnotification_user nu
ON tm.id_mensaje=nu.id_mensaje
AND nu.id_user="%s"
LEFT JOIN (tnotification_group ng
INNER JOIN tusuario_perfil up
ON ng.id_group=up.id_grupo
AND up.id_grupo=ng.id_group
) ON tm.id_mensaje=ng.id_mensaje
'SELECT count(*) as "n" FROM (
SELECT
tm.*,
utimestamp_read > 0 as "read"
%s
FROM tmensajes tm
%s
LEFT JOIN tnotification_user nu
ON tm.id_mensaje=nu.id_mensaje
AND nu.id_user="%s"
LEFT JOIN (tnotification_group ng
INNER JOIN tusuario_perfil up
ON ng.id_group=up.id_grupo
AND up.id_grupo=ng.id_group)
ON tm.id_mensaje=ng.id_mensaje
WHERE utimestamp_erased is null
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))
) t
%s',
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
) t
WHERE %s %s',
$source_select,
$source_sql,
$user,
$user,
$user,
$read
$read,
$source_extra
);
return (int) db_get_sql($sql);
@ -478,7 +495,11 @@ function messages_get_overview(
if ($incl_source_info) {
$source_fields = ', tns.*';
$source_join = 'INNER JOIN tnotification_source tns
ON tns.id=tm.id_source';
ON tns.id=tm.id_source
INNER JOIN tnotification_source_user nsu
ON nsu.id_source=tns.id
AND nsu.enabled = 1
OR tns.enabled = 1';
}
// Using distinct because could be double assignment due group/user.
@ -496,7 +517,7 @@ function messages_get_overview(
) ON tm.id_mensaje=ng.id_mensaje
%s
WHERE utimestamp_erased is null
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
) t
%s
%s

View File

@ -145,7 +145,7 @@ function check_notification_readable(int $id_message)
AND up.id_grupo=ng.id_group
) ON tm.id_mensaje=ng.id_mensaje
WHERE utimestamp_erased is null
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))',
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)',
$config['id_user'],
$id_message,
$config['id_user'],
@ -525,7 +525,7 @@ function notifications_build_user_enable_return($status, $enabled)
function notifications_get_user_label_status($source, $user, $label)
{
// If not enabled, it cannot be modificable.
if (!$source['enabled'] || !$source[$label]) {
if (!$source['enabled']) {
return notifications_build_user_enable_return(false, false);
}
@ -551,7 +551,10 @@ function notifications_get_user_label_status($source, $user, $label)
);
// No group found, return no permissions.
$value = empty($common_groups) ? false : $source[$label];
return notifications_build_user_enable_return($value, false);
return notifications_build_user_enable_return(
$value,
false
);
}
@ -570,7 +573,6 @@ function notifications_set_user_label_status($source, $user, $label, $value)
$source_info = notifications_get_all_sources(['id' => $source]);
if (!isset($source_info[0])
|| !$source_info[0]['enabled']
|| !$source_info[0][$label]
|| !$source_info[0]['user_editable']
) {
return false;

View File

@ -41,26 +41,6 @@ div.data_container:hover {
/*
* TODO: This may be at hostdevices.css
*/
#contenedor_principal {
height: auto;
position: relative;
margin: auto;
}
#contenedor_imagen_texto {
width: 11%;
height: auto;
position: relative;
display: inline-block;
vertical-align: top;
overflow: hidden;
margin-right: 5%;
}
#imagen {
width: 15%;
height: auto;
position: relative;
display: inline;
}
.texto {
height: auto;
text-align: center;
@ -70,3 +50,42 @@ div.data_container:hover {
text-decoration: none;
font-size: 24px;
}
.text_color {
color: white;
margin-left: 25px;
}
.text_color:hover {
text-decoration: none;
}
.arrow_box {
display: inline-block;
position: relative;
background: #82b92e;
width: 15%;
padding: 1%;
margin-left: 20px;
margin-bottom: 10px;
}
.arrow_box:after,
.arrow_box:before {
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
left: 0%;
border-left-color: white;
border-width: 20px;
margin-top: -20px;
}
.arrow_box:before {
left: 100%;
border-left-color: #82b92e;
border-width: 20px;
margin-top: -20px;
}

View File

@ -106,7 +106,12 @@ if ($read_message) {
$dst_name = $message['id_usuario_destino'];
}
echo '<h1>Conversation with '.$user_name.'</h1>';
if (isset($user_name) !== true || empty($user_name) === true) {
echo '<h1>Notification</h1>';
} else {
echo '<h1>Conversation with '.$user_name.'</h1>';
}
echo '<h2>Subject: '.$message['subject'].'</h2>';
$conversation = [];

View File

@ -14,51 +14,8 @@
// Load global vars
global $config;
check_login();
enterprise_hook('open_meta_frame');
require_once $config['homedir'].'/include/functions_profile.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_visual_map.php';
$meta = false;
if (enterprise_installed() && defined('METACONSOLE')) {
$meta = true;
}
$id = get_parameter_get('id', $config['id_user']);
// ID given as parameter
$status = get_parameter('status', -1);
// Flag to print action status message
$user_info = get_user_info($id);
$id = $user_info['id_user'];
// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem)
if ((!check_acl($config['id_user'], users_get_groups($id), 'UM'))
and ($id != $config['id_user'])
) {
db_pandora_audit('ACL Violation', 'Trying to view a user without privileges');
include 'general/noaccess.php';
exit;
}
// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
$view_mode = false;
} else {
$view_mode = true;
}
// Header
if ($meta) {
user_meta_print_header();
$url = 'index.php?sec=advanced&amp;sec2=advanced/users_setup&amp;tab=user_edit';
} else {
ui_print_page_header(__('User detail editor'), 'images/op_workspace.png', false, '', false, '');
$url = 'index.php?sec=workspace&amp;sec2=operation/users/user_edit';
}
// Load the header
require $config['homedir'].'/operation/users/user_edit_header.php';
// Update user info
if (isset($_GET['modified']) && !$view_mode) {
@ -535,7 +492,7 @@ $table->rowclass[] = '';
$table->rowstyle[] = '';
$table->data[] = $data;
echo '<form name="user_mod" method="post" action="'.$url.'&amp;modified=1&amp;id='.$id.'&amp;pure='.$config['pure'].'">';
echo '<form name="user_mod" method="post" action="'.$urls['main'].'&amp;modified=1&amp;id='.$id.'&amp;pure='.$config['pure'].'">';
html_print_table($table);

View File

@ -784,6 +784,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`snmp_security_level` varchar(25) NOT NULL default '',
`wmi_enabled` tinyint(1) unsigned DEFAULT '0',
`auth_strings` text,
`autoconfiguration_enabled` tinyint(1) unsigned default '0',
PRIMARY KEY (`id_rt`),
KEY `recon_task_daemon` (`id_recon_server`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -179,6 +179,7 @@ our @EXPORT = qw(
pandora_evaluate_alert
pandora_evaluate_snmp_alerts
pandora_event
pandora_extended_event
pandora_execute_alert
pandora_execute_action
pandora_exec_forced_alerts
@ -3270,11 +3271,11 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
# Create the event
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
db_do ($dbh, 'INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status);
# Do not write to the event file
return if ($pa_config->{'event_file'} eq '');
return $event_id if ($pa_config->{'event_file'} eq '');
# Add a header when the event file is created
my $header = undef;
@ -3285,7 +3286,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
# Open the event file for writing
if (! open (EVENT_FILE, '>>' . $pa_config->{'event_file'})) {
logger($pa_config, "Error opening event file " . $pa_config->{'event_file'} . ": $!", 10);
return;
return $event_id;
}
# Resolve ids
@ -3308,6 +3309,29 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
print EVENT_FILE "$agent_name,".safe_output($group_name)."," . safe_output ($evento) . ",$timestamp,$event_status,$utimestamp,$event_type,".safe_output($module_name).",".safe_output($alert_name).",$severity,".safe_output($comment).",".safe_output($module_tags).",$source,$id_extra,$user_name,".safe_output($critical_instructions).",".safe_output($warning_instructions).",".safe_output($unknown_instructions).",$ack_utimestamp\n";
close (EVENT_FILE);
return $event_id;
}
##########################################################################
=head2 C<< pandora_extended_event (I<$pa_config>, I<$dbh>, I<$event_id>, I<$description>) >>
Creates an extended event linked to an existing main event id.
=cut
##########################################################################
sub pandora_extended_event($$$$) {
my ($pa_config, $dbh, $event_id, $description) = @_;
return unless defined($event_id) && "$event_id" ne "" && $event_id > 0;
return db_do(
$dbh,
'INSERT INTO tevent_extended (id_evento, utimestamp, description) VALUES (?,?,?)',
$event_id,
time(),
safe_input($description)
);
}
##########################################################################

View File

@ -163,6 +163,8 @@ sub data_consumer ($$) {
@auth_strings = split(/,/, safe_output($task->{'auth_strings'}));
}
my $main_event = pandora_event($pa_config, "[Discovery] Execution summary",$task->{'id_group'}, 0, 0, 0, 0, 'system', 0, $dbh);
my $recon = new PandoraFMS::Recon::Base(
communities => \@communities,
dbh => $dbh,
@ -190,6 +192,8 @@ sub data_consumer ($$) {
vlan_cache_enabled => $task->{'vlan_enabled'},
wmi_enabled => $task->{'wmi_enabled'},
auth_strings_array => \@auth_strings,
autoconfiguration_enabled => $task->{'autoconfiguration_enabled'},
main_event_id => $main_event,
%{$pa_config}
);
@ -445,7 +449,23 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
$location->{'longitude'}, $location->{'latitude'}
);
return undef unless defined ($agent_id) and ($agent_id > 0);
pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
# Autoconfigure agent
if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) {
my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id);
# Update agent configuration once, after create agent.
enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, 1]);
}
if (defined($self->{'main_event_id'})) {
my $addresses_str = join(',', safe_output($self->get_addresses($device)));
pandora_extended_event(
$self->{'pa_config'}, $self->{'dbh'}, $self->{'main_event_id'},
"[Discovery] New " . safe_output($self->get_device_type($device)) . " found " . $host_name . " (" . $addresses_str . ") Agent $agent_id."
);
}
$agent_learning = 1;
# Create network profile modules for the agent

View File

@ -166,6 +166,7 @@ sub new {
snmp_timeout => 2,
snmp_version => 1,
subnets => [],
autoconfiguration_enabled => 0,
@_,
};