2012-02-10 Miguel de Dios <miguel.dedios@artica.es>
* * extensions/module_groups.php, include/functions_modules.php, godmode/agentes/module_manager_editor_prediction.php: cleaned source code style. * godmode/agentes/configurar_agente.php: cleaned source code style and fixed the duplication of module. * include/functions_agents.php: fixed the get modules into function "agents_get_modules", before the function return ever the policy modules without apply filter. Fixes: #3482260 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5554 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4df70f23d7
commit
0a9f2ccda4
|
@ -1,3 +1,18 @@
|
|||
2012-02-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* * extensions/module_groups.php, include/functions_modules.php,
|
||||
godmode/agentes/module_manager_editor_prediction.php: cleaned
|
||||
source code style.
|
||||
|
||||
* godmode/agentes/configurar_agente.php: cleaned source code style and fixed
|
||||
the duplication of module.
|
||||
|
||||
* include/functions_agents.php: fixed the get modules into function
|
||||
"agents_get_modules", before the function return ever the policy modules
|
||||
without apply filter.
|
||||
|
||||
Fixes: #3482260
|
||||
|
||||
2012-02-10 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||
|
||||
* include/functions_groups.php: Added links to different sections with
|
||||
|
|
|
@ -28,7 +28,7 @@ if (is_ajax ()) {
|
|||
|
||||
$data = false;
|
||||
if ($get_info_alert_module_group) {
|
||||
$agents = agents_get_group_agents($id_agent_group);
|
||||
$agents = agents_get_group_agents($id_agent_group);
|
||||
if (!empty($agents)) {
|
||||
$alerts = agents_get_alerts_simple(array_keys($agents));
|
||||
foreach ($alerts as $alert) {
|
||||
|
@ -128,7 +128,7 @@ function mainModuleGroups() {
|
|||
ui_print_page_header (__("Combined table of agent group and module group"), "images/brick.png", false, "", false, '');
|
||||
|
||||
echo "<p>" . __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") . "</p>";
|
||||
|
||||
|
||||
|
||||
$agentGroups = users_get_groups ($config['id_user'], "AR", false);
|
||||
$modelGroups = users_get_all_model_groups();
|
||||
|
@ -164,17 +164,17 @@ function mainModuleGroups() {
|
|||
|
||||
foreach ($modelGroups as $idModelGroup => $modelGroup) {
|
||||
$query = sprintf($sql,$idAgentGroup, $idModelGroup);
|
||||
|
||||
|
||||
$rowsDB = db_get_all_rows_sql ($query);
|
||||
|
||||
|
||||
$agents = agents_get_group_agents($idAgentGroup);
|
||||
|
||||
|
||||
if (!empty($agents)) {
|
||||
$alerts = agents_get_alerts_simple(array_keys($agents));
|
||||
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
$module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module']));
|
||||
|
||||
|
||||
if ($idModelGroup == $module['id_module_group']) {
|
||||
if ($alert["times_fired"] > 0) {
|
||||
$fired = true;
|
||||
|
@ -182,7 +182,7 @@ function mainModuleGroups() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$states = array();
|
||||
if ($rowsDB !== false) {
|
||||
foreach ($rowsDB as $rowDB) {
|
||||
|
@ -191,7 +191,6 @@ function mainModuleGroups() {
|
|||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($states as $idState => $state) {
|
||||
$count += $state;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ if ($id_agente) {
|
|||
if($tab == 'alert')
|
||||
$alerttab['active'] = true;
|
||||
else
|
||||
$alerttab['active'] = false;
|
||||
$alerttab['active'] = false;
|
||||
|
||||
/* Template tab */
|
||||
$templatetab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'">'
|
||||
|
@ -608,7 +608,8 @@ if ($id_agente) {
|
|||
$update_module = (bool) get_parameter ('update_module');
|
||||
$create_module = (bool) get_parameter ('create_module');
|
||||
$delete_module = (bool) get_parameter ('delete_module');
|
||||
$duplicate_module = (bool) get_parameter ('duplicate_module');
|
||||
//It is the id_agent_module to duplicate
|
||||
$duplicate_module = (int) get_parameter ('duplicate_module');
|
||||
$edit_module = (bool) get_parameter ('edit_module');
|
||||
|
||||
// GET DATA for MODULE UPDATE OR MODULE INSERT
|
||||
|
@ -996,11 +997,26 @@ if ($delete_module) { // DELETE agent module !
|
|||
|
||||
// MODULE DUPLICATION
|
||||
// =================
|
||||
if ($duplicate_module) { // DUPLICATE agent module !
|
||||
$id_duplicate_module = (int) get_parameter_get ("duplicate_module",0);
|
||||
if (!empty($duplicate_module)) { // DUPLICATE agent module !
|
||||
$id_duplicate_module = $duplicate_module;
|
||||
|
||||
$original_name = modules_get_agentmodule_name($id_duplicate_module);
|
||||
$copy_name = __('copy of') . ' ' . $original_name;
|
||||
|
||||
$cont = 0;
|
||||
$exists = true;
|
||||
while($exists) {
|
||||
$exists = (bool)db_get_value ('id_agente_modulo', 'tagente_modulo',
|
||||
'nombre', $copy_name);
|
||||
if ($exists) {
|
||||
$cont++;
|
||||
$copy_name = __('copy of') . ' ' . $original_name
|
||||
. ' (' . $cont . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$result = modules_copy_agent_module_to_agent ($id_duplicate_module,
|
||||
modules_get_agentmodule_agent($id_duplicate_module),
|
||||
io_safe_input(__('copy of').' '.modules_get_agentmodule_name($id_duplicate_module)));
|
||||
modules_get_agentmodule_agent($id_duplicate_module), $copy_name);
|
||||
|
||||
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ $is_synthetic = false;
|
|||
$is_synthetic_avg = false;
|
||||
$is_netflow = false;
|
||||
$ops = false;
|
||||
if ($row !== false && is_array($row)) {
|
||||
if ($row !== false && is_array($row)) {
|
||||
$prediction_module = $row['prediction_module'];
|
||||
$custom_integer_2 = $row ['custom_integer_2'];
|
||||
// Services are an Enterprise feature.
|
||||
|
|
|
@ -170,10 +170,10 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
else {
|
||||
$id_agent = (array) $id_agent;
|
||||
$id_modules = array_keys (agents_get_modules ($id_agent, false, array('delete_pending' => 0)));
|
||||
|
||||
|
||||
if (empty ($id_modules))
|
||||
return array ();
|
||||
|
||||
|
||||
$subQuery = implode (",", $id_modules);
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
$orderbyText = sprintf("ORDER BY %s", $orderby);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.nombre AS agent_name, t4.name AS template_name';
|
||||
if ($count !== false) {
|
||||
$selectText = 'COUNT(talert_template_modules.id) AS count';
|
||||
|
@ -198,7 +198,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
}else if ($extra_sql != '') {
|
||||
$extra_sql .= ' OR ';
|
||||
}
|
||||
|
||||
|
||||
$sql = sprintf ("SELECT %s
|
||||
FROM talert_template_modules
|
||||
INNER JOIN tagente_modulo t2
|
||||
|
@ -209,7 +209,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
ON talert_template_modules.id_alert_template = t4.id
|
||||
WHERE (%s id_agent_module in (%s)) %s %s %s",
|
||||
$selectText, $extra_sql, $subQuery, $where, $filter, $orderbyText);
|
||||
|
||||
|
||||
$alerts = db_get_all_rows_sql ($sql);
|
||||
|
||||
if ($alerts === false)
|
||||
|
@ -510,7 +510,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
$agents = oracle_recode_query ($sql, $set, 'AND', false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $agents;
|
||||
}
|
||||
|
||||
|
@ -969,7 +969,7 @@ 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.
|
||||
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 = '';
|
||||
|
@ -1070,18 +1070,20 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
$id_agent = safe_int ($id_agent, 1);
|
||||
}
|
||||
|
||||
$extra_sql = '';
|
||||
$policy_sql = '';
|
||||
if ($id_agent != 0){
|
||||
$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agent, '', false));
|
||||
if ($extra_sql === ENTERPRISE_NOT_HOOK) {
|
||||
$extra_sql = '';
|
||||
}else if ($extra_sql != '') {
|
||||
$extra_sql .= ' OR ';
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$userGroups = users_get_groups($config['id_user'], 'AR', false);
|
||||
|
||||
|
||||
if(empty($userGroups)) {
|
||||
return array();
|
||||
}
|
||||
|
@ -1111,6 +1113,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
FROM tperfil WHERE agent_view = 1
|
||||
)
|
||||
)
|
||||
" . $policy_sql . "
|
||||
)";
|
||||
|
||||
if (! empty ($id_agent)) {
|
||||
|
@ -1199,15 +1202,15 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
else {
|
||||
if ($config['dbtype'] == 'oracle'){
|
||||
$details_new = array();
|
||||
if (is_array($details)){
|
||||
foreach ($details as $detail){
|
||||
if (is_array($details)) {
|
||||
foreach ($details as $detail) {
|
||||
if ($detail == 'nombre')
|
||||
$details_new[] = 'dbms_lob.substr(nombre,4000,1) as nombre';
|
||||
else
|
||||
$details_new[] = $detail;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
if ($details == 'nombre')
|
||||
$details_new = 'dbms_lob.substr(nombre,4000,1) as nombre';
|
||||
else
|
||||
|
@ -1227,25 +1230,23 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
case "postgresql":
|
||||
$sql = sprintf ('SELECT %s%s
|
||||
FROM tagente_modulo WHERE
|
||||
%s (%s)
|
||||
%s
|
||||
ORDER BY nombre',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
io_safe_output(implode (",", (array) $details)),
|
||||
$extra_sql,
|
||||
$where);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ('SELECT %s%s
|
||||
FROM tagente_modulo WHERE
|
||||
%s (%s)
|
||||
%s
|
||||
ORDER BY dbms_lob.substr(nombre, 4000, 1)',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
io_safe_output(implode (",", (array) $details)),
|
||||
$extra_sql,
|
||||
$where);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
if (empty ($result)) {
|
||||
|
@ -1261,7 +1262,8 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
if (is_array ($details) || $details == '*') {
|
||||
//Just stack the information in array by ID
|
||||
$modules[$module['id_agente_modulo']] = $module;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$modules[$module['id_agente_modulo']] = $module[$details];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
|
|||
|
||||
if (! empty ($modules))
|
||||
return array_pop (array_keys ($modules));
|
||||
|
||||
|
||||
$modulesDisabled = agents_get_modules ($id_destiny_agent, false,
|
||||
array ('nombre' => $module['nombre'], 'disabled' => true));
|
||||
|
||||
|
||||
if (!empty($modulesDisabled)) {
|
||||
//the foreach have only one loop but extract the array index, and it's id_agente_modulo
|
||||
foreach ($modulesDisabled as $id => $garbage) {
|
||||
|
@ -68,7 +68,7 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
|
|||
db_process_sql_update('tagente_modulo', array('disabled' => false, 'delete_pending' => false),
|
||||
array('id_agente_modulo' => $id_module, 'disabled' => true), 'AND', false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$values = array ();
|
||||
|
@ -104,14 +104,16 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
|
|||
unset ($new_module[$i]);
|
||||
/* Unset original agent module id */
|
||||
unset ($new_module['id_agente_modulo']);
|
||||
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$id_new_module = db_process_sql_insert ('tagente_modulo', $new_module);
|
||||
case "postgresql":
|
||||
$id_new_module = db_process_sql_insert ('tagente_modulo',
|
||||
$new_module);
|
||||
break;
|
||||
case "oracle":
|
||||
$id_new_module = db_process_sql_insert ('tagente_modulo', $new_module, false);
|
||||
$id_new_module = db_process_sql_insert ('tagente_modulo',
|
||||
$new_module, false);
|
||||
break;
|
||||
}
|
||||
if ($id_new_module === false) {
|
||||
|
@ -589,7 +591,8 @@ function modules_get_type_icon ($id_type) {
|
|||
* @return int The id of the agent of given agent module
|
||||
*/
|
||||
function modules_get_agentmodule_agent ($id_agentmodule) {
|
||||
return (int) db_get_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
|
||||
return (int) db_get_value ('id_agente', 'tagente_modulo',
|
||||
'id_agente_modulo', (int) $id_agentmodule);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue