mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
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:
parent
0e19a6eb5f
commit
ace0d45022
@ -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>
|
2012-06-21 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* operation/users/webchat.php: Changed a string to
|
* operation/users/webchat.php: Changed a string to
|
||||||
|
@ -250,14 +250,8 @@ if ($ag_group > 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql_extra = enterprise_hook('policies_get_agents_sql_condition');
|
// CLEAN: sql_extra
|
||||||
|
$sql_extra = '';
|
||||||
if($sql_extra === ENTERPRISE_NOT_HOOK) {
|
|
||||||
$sql_extra = '';
|
|
||||||
}
|
|
||||||
else if($sql_extra != '') {
|
|
||||||
$sql_extra = sprintf('OR %s', $sql_extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Admin user get ANY group, even if they doesnt exist
|
// Admin user get ANY group, even if they doesnt exist
|
||||||
if (check_acl ($config['id_user'], 0, "PM")) {
|
if (check_acl ($config['id_user'], 0, "PM")) {
|
||||||
|
@ -303,14 +303,8 @@ switch ($sortField) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the enterprise acl sql condition
|
// TODO: CLEAN extra_sql
|
||||||
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
|
$extra_sql = '';
|
||||||
|
|
||||||
if($extra_sql == ENTERPRISE_NOT_HOOK) {
|
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the order sql
|
// Build the order sql
|
||||||
if(!empty($order)) {
|
if(!empty($order)) {
|
||||||
@ -337,7 +331,7 @@ $params = implode(',', array ('id_agente_modulo', 'id_tipo_modulo', 'descripcion
|
|||||||
'disabled','max_warning', 'min_warning', 'str_warning',
|
'disabled','max_warning', 'min_warning', 'str_warning',
|
||||||
'max_critical', 'min_critical', 'str_critical'));
|
'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);
|
$search_string_entities = io_safe_input($search_string);
|
||||||
|
|
||||||
|
@ -78,13 +78,12 @@ if ($config['user_can_update_info']) {
|
|||||||
$new_user = (bool) get_parameter ('new_user');
|
$new_user = (bool) get_parameter ('new_user');
|
||||||
$create_user = (bool) get_parameter ('create_user');
|
$create_user = (bool) get_parameter ('create_user');
|
||||||
$add_profile = (bool) get_parameter ('add_profile');
|
$add_profile = (bool) get_parameter ('add_profile');
|
||||||
$add_profile_policy = (bool) get_parameter ('add_profile_policy');
|
|
||||||
$delete_profile = (bool) get_parameter ('delete_profile');
|
$delete_profile = (bool) get_parameter ('delete_profile');
|
||||||
$update_user = (bool) get_parameter ('update_user');
|
$update_user = (bool) get_parameter ('update_user');
|
||||||
$status = get_parameter ('status', -1);
|
$status = get_parameter ('status', -1);
|
||||||
|
|
||||||
// Reset status var if current action is not update_user
|
// 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;
|
$status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,32 +291,6 @@ if ($add_profile) {
|
|||||||
__('Profile cannot be added'));
|
__('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) {
|
if ($delete_profile) {
|
||||||
$id2 = (string) get_parameter ('id_user');
|
$id2 = (string) get_parameter ('id_user');
|
||||||
$id_up = (int) get_parameter ('id_user_profile');
|
$id_up = (int) get_parameter ('id_user_profile');
|
||||||
|
@ -192,18 +192,8 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||||||
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($id_agent)) {
|
// TODO: Clean extra_sql
|
||||||
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array(reset($id_agent), 't3.', false));
|
$extra_sql = '';
|
||||||
}
|
|
||||||
else {
|
|
||||||
$extra_sql = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = sprintf ("SELECT %s
|
$sql = sprintf ("SELECT %s
|
||||||
FROM talert_template_modules
|
FROM talert_template_modules
|
||||||
@ -479,17 +469,10 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||||||
|
|
||||||
$extra = false;
|
$extra = false;
|
||||||
|
|
||||||
|
// TODO: CLEAN extra_sql
|
||||||
$sql_extra = '';
|
$sql_extra = '';
|
||||||
if ($all_groups){
|
if ($all_groups){
|
||||||
$where_nogroup = '1 = 1';
|
$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) {
|
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');
|
enterprise_include_once ('include/functions_policies.php');
|
||||||
|
|
||||||
if ($extra_access && $all_groups) { //if you have all group, search extra policies.
|
// TODO: CLEAN extra_sql
|
||||||
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
|
$extra_sql = '';
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$extra_sql = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
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) {
|
function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// TODO: Clean extra_sql
|
||||||
$policy_sql = '';
|
$policy_sql = '';
|
||||||
|
|
||||||
if ($id_agent === null) {
|
if ($id_agent === null) {
|
||||||
@ -1109,17 +1084,6 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||||||
$temp[] = $item['id_agente'];
|
$temp[] = $item['id_agente'];
|
||||||
}
|
}
|
||||||
$id_agent = $temp;
|
$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)) {
|
if (!is_array($id_agent)) {
|
||||||
|
@ -152,15 +152,8 @@ switch ($config["dbtype"]) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the enterprise acl sql condition
|
// TODO: Clean extra_sql
|
||||||
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
|
$extra_sql = '';
|
||||||
|
|
||||||
if ($extra_sql == ENTERPRISE_NOT_HOOK) {
|
|
||||||
$extra_sql = '';
|
|
||||||
}
|
|
||||||
else if ($extra_sql != '') {
|
|
||||||
$extra_sql = "(($extra_sql) OR id_policy_module = 0) AND";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all module from agent
|
// Get all module from agent
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
|
@ -175,15 +175,8 @@ switch ($sortField) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the enterprise acl sql condition
|
// TODO: clean extra_sql
|
||||||
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente));
|
$extra_sql = '';
|
||||||
|
|
||||||
if($extra_sql == ENTERPRISE_NOT_HOOK) {
|
|
||||||
$extra_sql = '';
|
|
||||||
}
|
|
||||||
else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Build the order sql
|
// Build the order sql
|
||||||
|
@ -33,12 +33,8 @@ require_once($config['homedir'] . '/include/functions_modules.php');
|
|||||||
require_once($config['homedir'] . '/include/functions_users.php');
|
require_once($config['homedir'] . '/include/functions_users.php');
|
||||||
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
|
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
|
||||||
|
|
||||||
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
|
// TODO: CLEAN extra_sql
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
$extra_sql = '';
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_print_page_header ("Monitor detail", "images/brick.png", false);
|
ui_print_page_header ("Monitor detail", "images/brick.png", false);
|
||||||
|
|
||||||
|
@ -19,12 +19,8 @@ global $config;
|
|||||||
enterprise_include_once('include/functions_policies.php');
|
enterprise_include_once('include/functions_policies.php');
|
||||||
require_once ($config['homedir'].'/include/functions_users.php');
|
require_once ($config['homedir'].'/include/functions_users.php');
|
||||||
|
|
||||||
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
|
// TODO: CLEAN extra_sql
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
$extra_sql = '';
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$searchAgents = check_acl($config['id_user'], 0, "AR");
|
$searchAgents = check_acl($config['id_user'], 0, "AR");
|
||||||
|
|
||||||
|
@ -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_agents.php");
|
||||||
include_once($config['homedir'] . "/include/functions_modules.php");
|
include_once($config['homedir'] . "/include/functions_modules.php");
|
||||||
|
|
||||||
$extra_sql = enterprise_hook('policies_get_agents_sql_condition');
|
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
// TODO: CLEAN extra_sql
|
||||||
$extra_sql = '';
|
$extra_sql = '';
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
//$extra_sql .= ' OR ';
|
|
||||||
$extra_sql = ' OR '.$extra_sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
$searchAlerts = check_acl($config['id_user'], 0, "AR");
|
$searchAlerts = check_acl($config['id_user'], 0, "AR");
|
||||||
|
|
||||||
|
@ -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_modules.php");
|
||||||
include_once($config['homedir'] . '/include/functions_users.php');
|
include_once($config['homedir'] . '/include/functions_users.php');
|
||||||
|
|
||||||
$extra_sql = enterprise_hook('policies_get_agents_sql_condition', array('t2.'));
|
// TODO: CLEAN extra_sql
|
||||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
$extra_sql = '';
|
||||||
$extra_sql = '';
|
|
||||||
}else if ($extra_sql != '') {
|
|
||||||
$extra_sql .= ' OR ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$searchModules = check_acl($config['id_user'], 0, "AR");
|
$searchModules = check_acl($config['id_user'], 0, "AR");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user