2012-06-21 Sergio Martin <sergio.martin@artica.es>

* include/functions_agents.php
	operation/search_modules.php
	operation/agentes/status_monitor.php
	operation/agentes/estado_ultimopaquete.php
	operation/agentes/estado_monitores.php
	operation/search_agents.php
	operation/search_alerts.php
	godmode/agentes/module_manager.php
	godmode/agentes/modificar_agente.php
	godmode/users/configure_user.php: Cleaned some old
	code of policy ACL to fix and prevent important bugs

	Merged from 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6660 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-06-21 13:27:37 +00:00
parent 94335b1e8c
commit 5f71495486
11 changed files with 41 additions and 130 deletions

View File

@ -1,3 +1,19 @@
2012-06-21 Sergio Martin <sergio.martin@artica.es>
* include/functions_agents.php
operation/search_modules.php
operation/agentes/status_monitor.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/estado_monitores.php
operation/search_agents.php
operation/search_alerts.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/users/configure_user.php: Cleaned some old
code of policy ACL to fix and prevent important bugs
Merged from 4.0.2
2012-06-21 Sergio Martin <sergio.martin@artica.es>
* operation/users/webchat.php: Changed a string to

View File

@ -250,14 +250,8 @@ if ($ag_group > 0) {
}
}
else {
$sql_extra = enterprise_hook('policies_get_agents_sql_condition');
if($sql_extra === ENTERPRISE_NOT_HOOK) {
$sql_extra = '';
}
else if($sql_extra != '') {
$sql_extra = sprintf('OR %s', $sql_extra);
}
// CLEAN: sql_extra
$sql_extra = '';
// Admin user get ANY group, even if they doesnt exist
if (check_acl ($config['id_user'], 0, "PM")) {

View File

@ -303,14 +303,8 @@ switch ($sortField) {
break;
}
// Get the enterprise acl sql condition
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
if($extra_sql == ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: CLEAN extra_sql
$extra_sql = '';
// Build the order sql
if(!empty($order)) {
@ -337,7 +331,7 @@ $params = implode(',', array ('id_agente_modulo', 'id_tipo_modulo', 'descripcion
'disabled','max_warning', 'min_warning', 'str_warning',
'max_critical', 'min_critical', 'str_critical'));
$where = sprintf("id_policy_module = 0 AND delete_pending = 0 AND id_agente = %s", $id_agente);
$where = sprintf("delete_pending = 0 AND id_agente = %s", $id_agente);
$search_string_entities = io_safe_input($search_string);

View File

@ -78,13 +78,12 @@ if ($config['user_can_update_info']) {
$new_user = (bool) get_parameter ('new_user');
$create_user = (bool) get_parameter ('create_user');
$add_profile = (bool) get_parameter ('add_profile');
$add_profile_policy = (bool) get_parameter ('add_profile_policy');
$delete_profile = (bool) get_parameter ('delete_profile');
$update_user = (bool) get_parameter ('update_user');
$status = get_parameter ('status', -1);
// Reset status var if current action is not update_user
if ($new_user || $create_user || $add_profile || $add_profile_policy || $delete_profile || $update_user){
if ($new_user || $create_user || $add_profile || $delete_profile || $update_user){
$status = -1;
}
@ -292,32 +291,6 @@ if ($add_profile) {
__('Profile cannot be added'));
}
if ($add_profile_policy && $enterprise_include) {
$id2 = (string) get_parameter ('id');
$profile2 = (int) get_parameter ('assign_profile');
$id_policy = (int) get_parameter ('policy');
if($id_policy != 0) {
$return = policies_create_user_policy_profile($id2, $profile2, $id_policy);
}
else {
$return = false;
}
if($return === false) {
db_pandora_audit("User management",
"Added extra policy profile for user ".io_safe_input($id2), false, false, ' Policy: ' . $id_policy);
}
else {
db_pandora_audit("User management",
"Problem adding extra policy profile for user ".io_safe_input($id2), false, false, ' Policy: ' . $id_policy);
}
ui_print_result_message ($return,
__('Extra policy profile added successfully'),
__('Extra policy profile cannot be added'));
}
if ($delete_profile) {
$id2 = (string) get_parameter ('id_user');
$id_up = (int) get_parameter ('id_user_profile');

View File

@ -192,18 +192,8 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$selectText = 'COUNT(talert_template_modules.id) AS count';
}
if(is_array($id_agent)) {
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array(reset($id_agent), 't3.', false));
}
else {
$extra_sql = '';
}
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: Clean extra_sql
$extra_sql = '';
$sql = sprintf ("SELECT %s
FROM talert_template_modules
@ -479,17 +469,10 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$extra = false;
// TODO: CLEAN extra_sql
$sql_extra = '';
if ($all_groups){
$where_nogroup = '1 = 1';
$sql_extra = enterprise_hook('policies_get_agents_sql_condition');
if($sql_extra != ENTERPRISE_NOT_HOOK) {
if (!empty($sql_extra)) {
$extra = true;
}
}
}
if($extra) {
@ -1012,17 +995,8 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
enterprise_include_once ('include/functions_policies.php');
if ($extra_access && $all_groups) { //if you have all group, search extra policies.
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
}
else{
$extra_sql = '';
}
// TODO: CLEAN extra_sql
$extra_sql = '';
switch ($config["dbtype"]) {
case "mysql":
@ -1086,6 +1060,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) {
global $config;
// TODO: Clean extra_sql
$policy_sql = '';
if ($id_agent === null) {
@ -1109,17 +1084,6 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
$temp[] = $item['id_agente'];
}
$id_agent = $temp;
if (!empty($id_agent)) {
$extra_policy_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agent));
if ($policy_sql === ENTERPRISE_NOT_HOOK) {
$policy_sql = '';
}
else if ($policy_sql != '') {
//It is AND instead OR, because It is necesary apply the filter.
$policy_sql = ' OR ' . $policy_sql;
}
}
}
if (!is_array($id_agent)) {

View File

@ -152,15 +152,8 @@ switch ($config["dbtype"]) {
break;
}
// Get the enterprise acl sql condition
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
if ($extra_sql == ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}
else if ($extra_sql != '') {
$extra_sql = "(($extra_sql) OR id_policy_module = 0) AND";
}
// TODO: Clean extra_sql
$extra_sql = '';
// Get all module from agent
switch ($config["dbtype"]) {

View File

@ -175,15 +175,8 @@ switch ($sortField) {
break;
}
// Get the enterprise acl sql condition
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
if($extra_sql == ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}
else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: clean extra_sql
$extra_sql = '';
// Build the order sql

View File

@ -33,12 +33,8 @@ require_once($config['homedir'] . '/include/functions_modules.php');
require_once($config['homedir'] . '/include/functions_users.php');
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: CLEAN extra_sql
$extra_sql = '';
ui_print_page_header ("Monitor detail", "images/brick.png", false);

View File

@ -19,12 +19,8 @@ global $config;
enterprise_include_once('include/functions_policies.php');
require_once ($config['homedir'].'/include/functions_users.php');
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: CLEAN extra_sql
$extra_sql = '';
$searchAgents = check_acl($config['id_user'], 0, "AR");

View File

@ -21,13 +21,9 @@ enterprise_include_once('include/functions_policies.php');
include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
//$extra_sql .= ' OR ';
$extra_sql = ' OR '.$extra_sql;
}
// TODO: CLEAN extra_sql
$extra_sql = '';
$searchAlerts = check_acl($config['id_user'], 0, "AR");

View File

@ -20,12 +20,8 @@ enterprise_include_once('include/functions_policies.php');
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . '/include/functions_users.php');
$extra_sql = enterprise_hook('policies_get_agents_sql_condition', array('t2.'));
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
$extra_sql = '';
}else if ($extra_sql != '') {
$extra_sql .= ' OR ';
}
// TODO: CLEAN extra_sql
$extra_sql = '';
$searchModules = check_acl($config['id_user'], 0, "AR");