Merge branch 'ent-12341-agent-basic-options' into 'develop'
Ent 12341 agent basic options See merge request artica/pandorafms!6681
This commit is contained in:
commit
38672764a3
|
@ -600,43 +600,176 @@ html_print_div(
|
|||
'content' => html_print_table($tableAgent, true).$CodeQRTable,
|
||||
]
|
||||
);
|
||||
/*
|
||||
TODO REVIEW
|
||||
$table_satellite = '';
|
||||
if ($remote_agent === true) {
|
||||
// Satellite server selector.
|
||||
$satellite_servers = db_get_all_rows_filter(
|
||||
'tserver',
|
||||
['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE],
|
||||
[
|
||||
'id_server',
|
||||
'name',
|
||||
]
|
||||
);
|
||||
|
||||
$satellite_names = [];
|
||||
if (empty($satellite_servers) === false) {
|
||||
foreach ($satellite_servers as $s_server) {
|
||||
$satellite_names[$s_server['id_server']] = $s_server['name'];
|
||||
// Basic Options.
|
||||
$tableBasicAgent = new stdClass();
|
||||
$tableBasicAgent->class = 'filter-table-adv';
|
||||
$tableBasicAgent->data = [];
|
||||
$disabledBasic = false;
|
||||
$tableClassDisabled = '';
|
||||
if ($new_agent === true || $remote_agent === false || $has_remote_conf === false) {
|
||||
$disabledBasic = true;
|
||||
$tableClassDisabled = ' basic-options-disabled';
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
// Get all plugins (BASIC OPTIONS).
|
||||
$agent_plugin = new PandoraFMS\Agent($id_agente);
|
||||
$plugins = $agent_plugin->getPlugins();
|
||||
// Check if some plugin was enabled/disabled in conf.
|
||||
foreach ($plugins as $key => $row) {
|
||||
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$security_hardening = 0;
|
||||
} else {
|
||||
$security_hardening = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$table_satellite = '<div class="label_select"><p class="input_label">'.__('Satellite').'</p>';
|
||||
$table_satellite .= '<div class="label_select_parent">';
|
||||
if ($id_os === '1' || $id_os === '8') {
|
||||
if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$enable_log_collector = 0;
|
||||
} else {
|
||||
$enable_log_collector = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$table_satellite .= html_print_input(
|
||||
if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$enable_inventory = 0;
|
||||
} else {
|
||||
$enable_inventory = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$enable_inventory = 0;
|
||||
} else {
|
||||
$enable_inventory = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_os === '9') {
|
||||
$modules = $agent_plugin->getModules();
|
||||
foreach ($modules as $key => $row) {
|
||||
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$enable_log_collector = 0;
|
||||
} else {
|
||||
$enable_log_collector = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($agent_plugin, $plugins);
|
||||
if (($new_agent === true && $config['current_package'] >= 774) || ($agent_version >= 774 && $new_agent === false)) {
|
||||
if ($disabledBasic === true || $has_remote_conf === false) {
|
||||
$message = __('Remote config disabled, please activate to enable agent basic options');
|
||||
$tableBasicAgent->data[] = '<span>'.$message.'</span>';
|
||||
}
|
||||
|
||||
$tableBasicAgent->data[] = html_print_label_input_block(
|
||||
__('Enable security hardening monitoring'),
|
||||
html_print_input(
|
||||
[
|
||||
'type' => 'select',
|
||||
'fields' => $satellite_names,
|
||||
'name' => 'satellite_server',
|
||||
'selected' => $satellite_server,
|
||||
'nothing' => __('None'),
|
||||
'nothinf_value' => 0,
|
||||
'return' => true,
|
||||
'type' => 'switch',
|
||||
'id' => 'security_hardening',
|
||||
'name' => 'security_hardening',
|
||||
'value' => $security_hardening,
|
||||
'disabled' => $disabledBasic,
|
||||
]
|
||||
).'<div class="label_select_child_icons"></div></div></div>';
|
||||
).html_print_input_hidden('options_package', '1', true)
|
||||
);
|
||||
|
||||
$tableBasicAgent->data[] = html_print_label_input_block(
|
||||
__('Enable log collection'),
|
||||
html_print_input(
|
||||
[
|
||||
'type' => 'switch',
|
||||
'id' => 'enable_log_collector',
|
||||
'name' => 'enable_log_collector',
|
||||
'value' => $enable_log_collector,
|
||||
'disabled' => $disabledBasic,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$tableBasicAgent->data[] = html_print_label_input_block(
|
||||
__('Enable inventory'),
|
||||
html_print_input(
|
||||
[
|
||||
'type' => 'switch',
|
||||
'id' => 'enable_inventory',
|
||||
'name' => 'enable_inventory',
|
||||
'value' => $enable_inventory,
|
||||
'disabled' => $disabledBasic,
|
||||
]
|
||||
).html_print_input_hidden('enable_basic_options', '1', true)
|
||||
);
|
||||
|
||||
if ($config['ehorus_enabled'] === '1') {
|
||||
$pandoraRC_Id = html_print_image(
|
||||
'images/alert_recovered@svg.svg',
|
||||
true,
|
||||
[
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
'title' => __('Pandora RC connected with id ').$config['ehorus_custom_field'],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$pandoraRC_Id = html_print_image(
|
||||
'images/alerts.svg',
|
||||
true,
|
||||
[
|
||||
'class' => 'invert_filter main_menu_icon',
|
||||
'title' => __('This agent do not have a Pandora RC agent installed, install one.'),
|
||||
]
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
$tableBasicAgent->data[] = html_print_label_input_block(
|
||||
__('Enable remote control'),
|
||||
$pandoraRC_Id
|
||||
);
|
||||
|
||||
$WarningPackage = '';
|
||||
if (($new_agent === true && $config['current_package'] < 774) || ($agent_version < 774 && $new_agent === false)) {
|
||||
$WarningPackage = html_print_image(
|
||||
'images/alert-yellow@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Only available for agents 774 or higher'),
|
||||
'alt' => __('Only available for agents 774 or higher'),
|
||||
'class' => 'main_menu_icon mrgn_lft_5px',
|
||||
]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$tableBasicAgent->data[] = '<span>'.__('Remote config is enabled only in the Enteprise version').'</span>';
|
||||
$tableBasicAgent->data[] .= html_print_input_hidden(
|
||||
'enable_basic_options',
|
||||
'0',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
ui_toggle(
|
||||
html_print_table($tableBasicAgent, true),
|
||||
'<span class="subsection_header_title">'.__('Basic options').$WarningPackage.'</span>',
|
||||
'',
|
||||
'basic_options',
|
||||
true,
|
||||
false,
|
||||
'white_box_content',
|
||||
'no-border white_table_graph'.$tableClassDisabled,
|
||||
'box-flat white_table_graph invisible'
|
||||
);
|
||||
|
||||
// Advanced options.
|
||||
$tableAdvancedAgent = new stdClass();
|
||||
|
@ -1256,7 +1389,8 @@ ui_require_jquery_file('bgiframe');
|
|||
});
|
||||
|
||||
$("#checkbox-cascade_protection").change(function () {
|
||||
var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) {
|
||||
var checked = $("#checkbox-cascade_protection").is(":checked");
|
||||
if (checked) {
|
||||
$("#cascade_protection_module").removeAttr("disabled");
|
||||
$("#text-id_parent").attr("required", "required");
|
||||
}
|
||||
|
@ -1266,7 +1400,7 @@ ui_require_jquery_file('bgiframe');
|
|||
$("#text-id_parent").removeAttr("required");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var safe_mode_checked = $("#checkbox-safe_mode").is(":checked");
|
||||
if (safe_mode_checked) {
|
||||
$("#safe_mode_module").removeAttr("disabled");
|
||||
|
@ -1274,10 +1408,10 @@ ui_require_jquery_file('bgiframe');
|
|||
else {
|
||||
$("#safe_mode_module").attr("disabled", 'disabled');
|
||||
}
|
||||
|
||||
|
||||
$("#checkbox-safe_mode").change(function () {
|
||||
var safe_mode_checked = $("#checkbox-safe_mode").is(":checked");
|
||||
|
||||
|
||||
if (safe_mode_checked) {
|
||||
$("#safe_mode_module").removeAttr("disabled");
|
||||
}
|
||||
|
@ -1311,5 +1445,17 @@ ui_require_jquery_file('bgiframe');
|
|||
}
|
||||
});
|
||||
|
||||
check_basic_options();
|
||||
$('#id_os').on('change', function(){
|
||||
check_basic_options();
|
||||
})
|
||||
});
|
||||
|
||||
function check_basic_options(){
|
||||
if ($('#id_os').val() == 1 || $('#id_os').val() == 8 || $('#id_os').val() == 9) {
|
||||
$('#basic_options').removeClass('invisible');
|
||||
} else {
|
||||
$('#basic_options').addClass('invisible');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -232,7 +232,7 @@ if ($create_agent) {
|
|||
$cps = (int) get_parameter_switch('cps', -1);
|
||||
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
|
||||
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
|
||||
|
||||
$agent_version = $config['current_package'];
|
||||
$secondary_groups = (array) get_parameter('secondary_groups_selected', '');
|
||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
|
||||
|
@ -300,6 +300,7 @@ if ($create_agent) {
|
|||
'cps' => $cps,
|
||||
'fixed_ip' => $fixed_ip,
|
||||
'vul_scan_enabled' => $vul_scan_enabled,
|
||||
'agent_version' => $agent_version,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
|
@ -1015,6 +1016,13 @@ if ($update_agent) {
|
|||
$satellite_server = (int) get_parameter('satellite_server', 0);
|
||||
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
|
||||
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
|
||||
$security_vunerability = (int) get_parameter_switch('security_vunerability', 0);
|
||||
$security_hardening = (int) get_parameter_switch('security_hardening', 0);
|
||||
$security_monitoring = (int) get_parameter_switch('security_monitoring', 0);
|
||||
$enable_log_collector = (int) get_parameter_switch('enable_log_collector', 0);
|
||||
$enable_inventory = (int) get_parameter_switch('enable_inventory', 0);
|
||||
$enable_basic_options = get_parameter('enable_basic_options');
|
||||
$options_package = get_parameter('options_package', '0');
|
||||
|
||||
if ($fields === false) {
|
||||
$fields = [];
|
||||
|
@ -1243,6 +1251,81 @@ if ($update_agent) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($enable_basic_options === '1') {
|
||||
// Get all plugins (BASIC OPTIONS).
|
||||
$agent = new PandoraFMS\Agent($id_agente);
|
||||
$plugins = $agent->getPlugins();
|
||||
foreach ($plugins as $key => $row) {
|
||||
// Only check plugins when agent package is bigger than 774.
|
||||
if ($options_package === '1') {
|
||||
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
|
||||
if ($security_hardening === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$agent->enablePlugins($row['raw']);
|
||||
}
|
||||
} else {
|
||||
if ($row['disabled'] !== 1) {
|
||||
$agent->disablePlugins($row['raw']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
|
||||
if ($enable_log_collector === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$agent->enablePlugins($row['raw']);
|
||||
}
|
||||
} else {
|
||||
if ($row['disabled'] !== 1) {
|
||||
$agent->disablePlugins($row['raw']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inventory switch enable when basic options are enabled.
|
||||
if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
|
||||
if ($enable_inventory === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$agent->enablePlugins($row['raw']);
|
||||
}
|
||||
} else {
|
||||
if ($row['disabled'] !== 1) {
|
||||
$agent->disablePlugins($row['raw']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inventory switch enable when basic options are enabled.
|
||||
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
|
||||
if ($enable_inventory === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$agent->enablePlugins($row['raw']);
|
||||
}
|
||||
} else {
|
||||
if ($row['disabled'] !== 1) {
|
||||
$agent->disablePlugins($row['raw']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$modules = $agent->getModules();
|
||||
foreach ($modules as $key => $row) {
|
||||
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
|
||||
if ($enable_log_collector === 1) {
|
||||
if ($row['disabled'] === 1) {
|
||||
$agent->enableModule($row['module_name'], $row);
|
||||
}
|
||||
} else {
|
||||
if ($row['disabled'] !== 1) {
|
||||
$agent->disableModule($row['module_name'], $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read agent data
|
||||
|
@ -1300,6 +1383,19 @@ if ($id_agente) {
|
|||
$satellite_server = (int) $agent['satellite_server'];
|
||||
$fixed_ip = (int) $agent['fixed_ip'];
|
||||
$vul_scan_enabled = (int) $agent['vul_scan_enabled'];
|
||||
if (strpos($agent['agent_version'], '(')) {
|
||||
$agent_version = (int) explode('.', explode('(', $agent['agent_version'])[0])[2];
|
||||
} else {
|
||||
if (strpos($agent['agent_version'], 'build') || strpos($agent['agent_version'], 'Build')) {
|
||||
$agent_version = (int) explode('.', explode('build', $agent['agent_version'])[0])[2];
|
||||
} else {
|
||||
if (strpos($agent['agent_version'], '.')) {
|
||||
$agent_version = (int) explode('.', $agent['agent_version'])[2];
|
||||
} else {
|
||||
$agent_version = $agent['agent_version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$update_module = (bool) get_parameter('update_module');
|
||||
|
|
|
@ -12866,6 +12866,12 @@ tr.shown td.details-control {
|
|||
top: -92px;
|
||||
}
|
||||
|
||||
.basic-options-disabled tr > td,
|
||||
.basic-options-disabled tr > td > div > label {
|
||||
color: gray;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#cluetip-inner > #example {
|
||||
position: absolute;
|
||||
margin-left: 5px;
|
||||
|
|
Loading…
Reference in New Issue