2013-01-14 Sergio Martin <sergio.martin@artica.es>

* include/functions_ui.php
	include/functions.php
	operation/agentes/alerts_status.php
	operation/agentes/estado_agente.php
	godmode/agentes/module_manager.php
	godmode/agentes/modificar_agente.php
	godmode/agentes/configurar_agente.php
	godmode/menu.php
	godmode/alerts/alert_list.list.php
	godmode/alerts/alert_list.php: Added checks to new flag AD
	in godmode views for agents, modules and alerts. Clean 
	some old extra_sql (policy acls) code



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7461 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2013-01-14 15:11:07 +00:00
parent 074ce3dae2
commit a8bae96e56
11 changed files with 503 additions and 348 deletions

View File

@ -1,3 +1,18 @@
2013-01-14 Sergio Martin <sergio.martin@artica.es>
* include/functions_ui.php
include/functions.php
operation/agentes/alerts_status.php
operation/agentes/estado_agente.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/menu.php
godmode/alerts/alert_list.list.php
godmode/alerts/alert_list.php: Added checks to new flag AD
in godmode views for agents, modules and alerts. Clean
some old extra_sql (policy acls) code
2013-01-14 Dario Rodriguez <dario.rodriguez@artica.es> 2013-01-14 Dario Rodriguez <dario.rodriguez@artica.es>
* pandoradb_data.sql: Added a missing column name in * pandoradb_data.sql: Added a missing column name in

View File

@ -26,23 +26,34 @@ ui_require_javascript_file('encode_decode_base64');
check_login (); check_login ();
//Get tab parameter to check ACL in each tabs
$tab = get_parameter ('tab', 'main');
//See if id_agente is set (either POST or GET, otherwise -1 //See if id_agente is set (either POST or GET, otherwise -1
$id_agente = (int) get_parameter ("id_agente"); $id_agente = (int) get_parameter ("id_agente");
$group = 0; $group = 0;
if ($id_agente) if ($id_agente)
$group = agents_get_agent_group ($id_agente); $group = agents_get_agent_group ($id_agente);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); if (! check_acl ($config["id_user"], $group, "AW", $id_agente)) {
$access_granted = false;
if($is_extra === ENTERPRISE_NOT_HOOK) { switch($tab) {
$is_extra = false; case 'alert':
} case 'module':
if (check_acl ($config["id_user"], $group, "AD", $id_agente)) {
if (! check_acl ($config["id_user"], $group, "AW", $id_agente) && !$is_extra) { $access_granted = true;
db_pandora_audit("ACL Violation", }
"Trying to access agent manager"); break;
require ("general/noaccess.php"); default:
return; break;
}
if(!$access_granted) {
db_pandora_audit("ACL Violation",
"Trying to access agent manager");
require ("general/noaccess.php");
return;
}
} }
require_once ('include/functions_modules.php'); require_once ('include/functions_modules.php');
@ -50,7 +61,6 @@ require_once ('include/functions_alerts.php');
require_once ('include/functions_reporting.php'); require_once ('include/functions_reporting.php');
// Get passed variables // Get passed variables
$tab = get_parameter ('tab', 'main');
$alerttype = get_parameter ('alerttype'); $alerttype = get_parameter ('alerttype');
$id_agent_module = (int) get_parameter ('id_agent_module'); $id_agent_module = (int) get_parameter ('id_agent_module');
@ -337,25 +347,33 @@ if ($id_agente) {
$incidenttab['active'] = false; $incidenttab['active'] = false;
} }
$onheader = array('view' => $viewtab, if(check_acl ($config["id_user"], $group, "AW", $id_agente)) {
'separator' => "", $onheader = array('view' => $viewtab,
'main' => $maintab, 'separator' => "",
'module' => $moduletab, 'main' => $maintab,
'alert' => $alerttab, 'module' => $moduletab,
'template' => $templatetab, 'alert' => $alerttab,
'inventory' => $inventorytab, 'template' => $templatetab,
'pluginstab' => $pluginstab, 'inventory' => $inventorytab,
'collection'=> $collectiontab, 'pluginstab' => $pluginstab,
'group' => $grouptab, 'collection'=> $collectiontab,
'gis' => $gistab); 'group' => $grouptab,
'gis' => $gistab);
// Only if the agent has incidents associated show incidents tab
if ($total_incidents) { // Only if the agent has incidents associated show incidents tab
$onheader['incident'] = $incidenttab; if ($total_incidents) {
$onheader['incident'] = $incidenttab;
}
}
else {
$onheader = array('view' => $viewtab,
'separator' => "",
'module' => $moduletab,
'alert' => $alerttab);
} }
foreach ($config['extensions'] as $extension) { foreach ($config['extensions'] as $extension) {
if (isset($extension['extension_god_tab'])) { if (isset($extension['extension_god_tab']) && check_acl ($config["id_user"], $group, "AW", $id_agente)) {
$image = $extension['extension_god_tab']['icon']; $image = $extension['extension_god_tab']['icon'];
$name = $extension['extension_god_tab']['name']; $name = $extension['extension_god_tab']['name'];
$id = $extension['extension_god_tab']['id']; $id = $extension['extension_god_tab']['id'];
@ -608,12 +626,7 @@ if ($update_agent) { // if modified some agent paramenter
if ($id_agente) { if ($id_agente) {
//This has been done in the beginning of the page, but if an agent was created, this id might change //This has been done in the beginning of the page, but if an agent was created, this id might change
$id_grupo = agents_get_agent_group ($id_agente); $id_grupo = agents_get_agent_group ($id_agente);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); if (!check_acl ($config["id_user"], $id_grupo, "AW") && !check_acl ($config["id_user"], $id_grupo, "AD")) {
if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
if (!check_acl ($config["id_user"], $id_grupo, "AW") && !$is_extra) {
db_pandora_audit("ACL Violation","Trying to admin an agent without access"); db_pandora_audit("ACL Violation","Trying to admin an agent without access");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;
@ -648,6 +661,8 @@ if ($id_agente) {
$update_module = (bool) get_parameter ('update_module'); $update_module = (bool) get_parameter ('update_module');
$create_module = (bool) get_parameter ('create_module'); $create_module = (bool) get_parameter ('create_module');
$delete_module = (bool) get_parameter ('delete_module'); $delete_module = (bool) get_parameter ('delete_module');
$enable_module = (int) get_parameter ('enable_module');
$disable_module = (int) get_parameter ('disable_module');
//It is the id_agent_module to duplicate //It is the id_agent_module to duplicate
$duplicate_module = (int) get_parameter ('duplicate_module'); $duplicate_module = (int) get_parameter ('duplicate_module');
$edit_module = (bool) get_parameter ('edit_module'); $edit_module = (bool) get_parameter ('edit_module');
@ -656,18 +671,13 @@ $edit_module = (bool) get_parameter ('edit_module');
if ($update_module || $create_module) { if ($update_module || $create_module) {
$id_grupo = agents_get_agent_group ($id_agente); $id_grupo = agents_get_agent_group ($id_agente);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); if (!check_acl ($config["id_user"], $id_grupo, "AW")) {
if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
if (!check_acl ($config["id_user"], $id_grupo, "AW") && !$is_extra) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to create a module without admin rights"); "Trying to create a module without admin rights");
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;
} }
$id_module_type = (int) get_parameter ('id_module_type'); $id_module_type = (int) get_parameter ('id_module_type');
$name = (string) get_parameter ('name'); $name = (string) get_parameter ('name');
$description = (string) get_parameter ('description'); $description = (string) get_parameter ('description');
@ -1195,6 +1205,36 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
} }
} }
// MODULE ENABLE/DISABLE
// =====================
if($enable_module) {
$result = db_process_sql_update('tagente_modulo', array('disabled' => 0), array('id_agente_modulo' => $enable_module));
if ($result) {
db_pandora_audit("Module management", 'Enable ' . $enable_module);
}
else {
db_pandora_audit("Module management", 'Fail to enable ' . $enable_module);
}
ui_print_result_message ($result,
__('Successfully enabled'), __('Could not be enabled'));
}
if($disable_module) {
$result = db_process_sql_update('tagente_modulo', array('disabled' => 1), array('id_agente_modulo' => $disable_module));
if ($result) {
db_pandora_audit("Module management", 'Disable ' . $disable_module);
}
else {
db_pandora_audit("Module management", 'Fail to disable ' . $disable_module);
}
ui_print_result_message ($result,
__('Successfully disabled'), __('Could not be disabled'));
}
// UPDATE GIS // UPDATE GIS
// ========== // ==========
$updateGIS = get_parameter('update_gis', 0); $updateGIS = get_parameter('update_gis', 0);

View File

@ -30,7 +30,7 @@ if ($ag_group == -1 )
if (($ag_group == -1) && ($group_id != 0)) if (($ag_group == -1) && ($group_id != 0))
$ag_group = $group_id; $ag_group = $group_id;
if (! check_acl ($config["id_user"], 0, "AW")) { if (! check_acl ($config["id_user"], 0, "AW") && ! check_acl ($config["id_user"], 0, "AD")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to access agent manager"); "Trying to access agent manager");
require ("general/noaccess.php"); require ("general/noaccess.php");
@ -43,27 +43,6 @@ require_once ('include/functions_users.php');
$search = get_parameter ("search", ""); $search = get_parameter ("search", "");
$agent_to_delete = (int)get_parameter('borrar_agente');
$result = null;
if (!empty($agent_to_delete)) {
$id_agente = $agent_to_delete;
$agent_name = agents_get_name ($id_agente);
$id_grupo = agents_get_agent_group($id_agente);
if (check_acl ($config["id_user"], $id_grupo, "AW")==1) {
$id_agentes[0] = $id_agente;
$result = agents_delete_agent($id_agentes);
}
else {
// NO permissions.
db_pandora_audit("ACL Violation",
"Trying to delete agent \'$agent_name\'");
require ("general/noaccess.php");
exit;
}
}
// Prepare the tab system to the future // Prepare the tab system to the future
$tab = 'view'; $tab = 'view';
@ -82,8 +61,32 @@ $onheader = array('view' => $viewtab);
// Header // Header
ui_print_page_header (__('Agent configuration')." &raquo; ".__('Agents defined in Pandora'), "", false, "", true, $onheader); ui_print_page_header (__('Agent configuration')." &raquo; ".__('Agents defined in Pandora'), "", false, "", true, $onheader);
if (isset($result)) { // Perform actions
$agent_to_delete = (int)get_parameter('borrar_agente');
$enable_agent = (int)get_parameter('enable_agent');
$disable_agent = (int)get_parameter('disable_agent');
$result = null;
if ($agent_to_delete) {
$id_agente = $agent_to_delete;
$agent_name = agents_get_name ($id_agente);
$id_grupo = agents_get_agent_group($id_agente);
if (check_acl ($config["id_user"], $id_grupo, "AW")) {
$id_agentes[0] = $id_agente;
$result = agents_delete_agent($id_agentes);
}
else {
// NO permissions.
db_pandora_audit("ACL Violation",
"Trying to delete agent \'$agent_name\'");
require ("general/noaccess.php");
exit;
}
ui_print_result_message($result, __('Success deleted agent.'), __('Could not be deleted.')); ui_print_result_message($result, __('Success deleted agent.'), __('Could not be deleted.'));
// Check if the remote config file still exist
if (isset ($config["remote_config"])) { if (isset ($config["remote_config"])) {
$agent_md5 = md5 (agents_get_name($id_agente, ""), FALSE); $agent_md5 = md5 (agents_get_name($id_agente, ""), FALSE);
@ -94,6 +97,34 @@ if (isset($result)) {
} }
} }
if($enable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 0), array('id_agente' => $enable_agent));
if ($result) {
db_pandora_audit("Agent management", 'Enable ' . $enable_agent);
}
else {
db_pandora_audit("Agent management", 'Fail to enable ' . $enable_agent);
}
ui_print_result_message ($result,
__('Successfully enabled'), __('Could not be enabled'));
}
if($disable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 1), array('id_agente' => $disable_agent));
if ($result) {
db_pandora_audit("Agent management", 'Disable ' . $disable_agent);
}
else {
db_pandora_audit("Agent management", 'Fail to disable ' . $disable_agent);
}
ui_print_result_message ($result,
__('Successfully disabled'), __('Could not be disabled'));
}
// Show group selector // Show group selector
if (isset($_POST["ag_group"])) { if (isset($_POST["ag_group"])) {
$ag_group = get_parameter_post ("ag_group"); $ag_group = get_parameter_post ("ag_group");
@ -250,24 +281,21 @@ if ($ag_group > 0) {
} }
} }
else { else {
// CLEAN: sql_extra
$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")) {
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE (1=1 %s) %s', $search_sql, $sql_extra); $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql);
$total_agents = db_get_sql ($sql); $total_agents = db_get_sql ($sql);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente WHERE (1=1 %s) %s FROM tagente WHERE 1=1 %s
ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $sql_extra, $order['field'], $order['field2'], ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $offset, $config["block_size"]); $order['order'], $offset, $config["block_size"]);
break; break;
case "postgresql": case "postgresql":
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente WHERE (1=1 %s) %s FROM tagente WHERE 1=1 %s
ORDER BY %s, %s %s LIMIT %d OFFSET %d', $search_sql, $sql_extra, $order['field'], $order['field2'], ORDER BY %s, %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $config["block_size"], $offset); $order['order'], $config["block_size"], $offset);
break; break;
case "oracle": case "oracle":
@ -275,40 +303,46 @@ else {
$set['limit'] = $config["block_size"]; $set['limit'] = $config["block_size"];
$set['offset'] = $offset; $set['offset'] = $offset;
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente WHERE (1=1 %s) %s FROM tagente WHERE 1=1 %s
ORDER BY %s, %s %s', $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order']); ORDER BY %s, %s %s', $search_sql, $order['field'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set); $sql = oracle_recode_query ($sql, $set);
break; break;
} }
} }
else { else {
// Concatenate AW and AD permisions to get all the possible groups where the user can manage
$user_groupsAW = users_get_groups ($config['id_user'], 'AW');
$user_groupsAD = users_get_groups ($config['id_user'], 'AD');
$user_groups = $user_groupsAW + $user_groupsAD;
$sql = sprintf ('SELECT COUNT(*) $sql = sprintf ('SELECT COUNT(*)
FROM tagente FROM tagente
WHERE (id_grupo IN (%s) WHERE id_grupo IN (%s)
%s) %s', %s',
implode (',', array_keys (users_get_groups ())), implode (',', array_keys ($user_groups)),
$search_sql, $sql_extra); $search_sql);
$total_agents = db_get_sql ($sql); $total_agents = db_get_sql ($sql);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente FROM tagente
WHERE (id_grupo IN (%s) WHERE id_grupo IN (%s)
%s) %s %s
ORDER BY %s, %s %s LIMIT %d, %d', ORDER BY %s, %s %s LIMIT %d, %d',
implode (',', array_keys (users_get_groups ())), implode (',', array_keys ($user_groups)),
$search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]); $search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]);
break; break;
case "postgresql": case "postgresql":
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente FROM tagente
WHERE (id_grupo IN (%s) WHERE id_grupo IN (%s)
%s) %s %s
ORDER BY %s, %s %s LIMIT %d OFFSET %d', ORDER BY %s, %s %s LIMIT %d OFFSET %d',
implode (',', array_keys (users_get_groups ())), implode (',', array_keys ($user_groups)),
$search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset); $search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset);
break; break;
case "oracle": case "oracle":
$set = array (); $set = array ();
@ -316,10 +350,10 @@ else {
$set['offset'] = $offset; $set['offset'] = $offset;
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente FROM tagente
WHERE (id_grupo IN (%s) WHERE id_grupo IN (%s)
%s) %s %s
ORDER BY %s, %s %s', ORDER BY %s, %s %s',
implode (',', array_keys (users_get_groups ())), implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order']); $search_sql, $order['field'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set); $sql = oracle_recode_query ($sql, $set);
break; break;
@ -357,19 +391,15 @@ if ($agents !== false) {
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>'; '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>".__('Description')."</th>"; echo "<th>".__('Description')."</th>";
echo "<th>".__('Delete')."</th>"; echo "<th>".__('Actions')."</th>";
$color=1; $color=1;
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
foreach ($agents as $agent) { foreach ($agents as $agent) {
$id_grupo = $agent["id_grupo"]; $id_grupo = $agent["id_grupo"];
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($agent["id_agente"]));
if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente']) && ! check_acl ($config["id_user"], $id_grupo, "AD", $agent['id_agente']))
if($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente']) && !$is_extra)
continue; continue;
if ($color == 1) { if ($color == 1) {
@ -399,8 +429,16 @@ if ($agents !== false) {
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
echo "&nbsp;"; echo "&nbsp;";
} }
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$main_tab = 'main';
}
else {
$main_tab = 'module';
}
echo "<a href='index.php?sec=gagente& echo "<a href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main& sec2=godmode/agentes/configurar_agente&tab=$main_tab&
id_agente=" . $agent["id_agente"] . "'>" . id_agente=" . $agent["id_agente"] . "'>" .
ui_print_truncate_text($agent["nombre"], 'agent_medium', true, true, true, '[&hellip;]', 'font-size: 7pt') . ui_print_truncate_text($agent["nombre"], 'agent_medium', true, true, true, '[&hellip;]', 'font-size: 7pt') .
"</a>"; "</a>";
@ -410,10 +448,12 @@ if ($agents !== false) {
echo "</em>"; echo "</em>";
} }
echo '</span><div class="left actions" style="visibility: hidden; clear: left">'; echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
echo '<a href="index.php?sec=gagente& if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
sec2=godmode/agentes/configurar_agente&tab=main& echo '<a href="index.php?sec=gagente&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>'; sec2=godmode/agentes/configurar_agente&tab=main&
echo ' | '; id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
echo ' | ';
}
echo '<a href="index.php?sec=gagente& echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=module& sec2=godmode/agentes/configurar_agente&tab=module&
id_agente='.$agent["id_agente"].'">'.__('Modules').'</a>'; id_agente='.$agent["id_agente"].'">'.__('Modules').'</a>';
@ -456,10 +496,27 @@ if ($agents !== false) {
else else
$offsetArg = $offset; $offsetArg = $offset;
echo "<td class='$tdcolor' align='center' valign='middle'><a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "<td class='$tdcolor' align='center' valign='middle'>";
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; if ($agent['disabled']) {
echo html_print_image('images/cross.png', true, array("border" => '0')) . "</a></td>"; echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort''>".
html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) ."</a>";
}
else {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'>".
html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
}
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo html_print_image('images/cross.png', true, array("border" => '0')) . "</a>";
}
echo "</td>";
} }
echo "</table>"; echo "</table>";
ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset);
@ -470,12 +527,16 @@ else {
echo "&nbsp;</td></tr><tr><td>"; echo "&nbsp;</td></tr><tr><td>";
} }
// Create agent button if(check_acl ($config["id_user"], 0, "AW")) {
echo '<a name="bottom">'; // Create agent button
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">'; echo '<a name="bottom">';
html_print_input_hidden ('new_agent', 1); echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); html_print_input_hidden ('new_agent', 1);
echo "</form></td></tr></table>"; html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
echo "</form>";
}
echo "</td></tr></table>";
?> ?>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -82,21 +82,24 @@ if (strstr($sec2, "enterprise/godmode/policies/policies") !== false) {
unset($modules['predictionserver']); unset($modules['predictionserver']);
} }
// Create module/type combo if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
echo '<form id="create_module_type" method="post" action="'.$url.'">'; // Create module/type combo
html_print_select ($modules, 'moduletype', '', '', '', '', false, false, false, '', false, 'max-width:300px;' ); echo '<form id="create_module_type" method="post" action="'.$url.'">';
html_print_input_hidden ('edit_module', 1); html_print_select ($modules, 'moduletype', '', '', '', '', false, false, false, '', false, 'max-width:300px;' );
echo '</td>'; html_print_input_hidden ('edit_module', 1);
echo '<td class="datos">'; echo '</td>';
echo '<input align="right" name="updbutton" type="submit" class="sub next" value="'.__('Create').'">'; echo '<td class="datos">';
echo '</td>'; echo '<input align="right" name="updbutton" type="submit" class="sub next" value="'.__('Create').'">';
echo '<td class="datos" style="text-align:center;">'; echo '</td>';
echo "<strong>"; echo '<td class="datos" style="text-align:center;">';
echo "<a style='color: #004A1B;' target='_blank' href='http://pandorafms.com/Library/Library/'>".__("Get more modules in Pandora FMS Library")."</a>"; echo "<strong>";
echo "</strong>"; echo "<a style='color: #004A1B;' target='_blank' href='http://pandorafms.com/Library/Library/'>".__("Get more modules in Pandora FMS Library")."</a>";
echo '</td>'; echo "</strong>";
echo '</tr>'; echo '</td>';
echo "</form>"; echo '</tr>';
echo "</form>";
}
echo "</table>"; echo "</table>";
if (! isset ($id_agente)) if (! isset ($id_agente))
@ -429,8 +432,12 @@ $table->head = array ();
$table->head[0] = __('Name') . ' ' . $table->head[0] = __('Name') . ' ' .
'<a href="' . $url . '&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="' . $url . '&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' .
'<a href="' . $url . '&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>'; '<a href="' . $url . '&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK)
// The access to the policy is granted only with AW permission
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
$table->head[1] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>"; $table->head[1] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
}
$table->head[2] = "<span title='" . __('Server') . "'>" . __('S.') . "</span>" . ' ' . $table->head[2] = "<span title='" . __('Server') . "'>" . __('S.') . "</span>" . ' ' .
'<a href="' . $url . '&sort_field=server&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectServerUp)) . '</a>' . '<a href="' . $url . '&sort_field=server&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectServerUp)) . '</a>' .
'<a href="' . $url . '&sort_field=server&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectServerDown)) . '</a>'; '<a href="' . $url . '&sort_field=server&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectServerDown)) . '</a>';
@ -452,10 +459,9 @@ $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->size = array (); $table->size = array ();
$table->size[2] = '55px'; $table->size[2] = '55px';
$table->size[8] = '120px';
$table->align = array (); $table->align = array ();
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->align[8] = 'left'; $table->align[8] = 'center';
$table->data = array (); $table->data = array ();
$agent_interval = agents_get_interval ($id_agente); $agent_interval = agents_get_interval ($id_agente);
@ -471,16 +477,10 @@ foreach($tempRows as $row) {
} }
foreach ($modules as $module) { foreach ($modules as $module) {
$is_extra = enterprise_hook('policies_is_module_extra_policy', array($module["id_agente_modulo"])); if (! check_acl ($config["id_user"], $group, "AW", $id_agente) && ! check_acl ($config["id_user"], $group, "AD", $id_agente)) {
if($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
if (! check_acl ($config["id_user"], $group, "AW", $id_agente) && !$is_extra) {
continue; continue;
} }
$type = $module["id_tipo_modulo"]; $type = $module["id_tipo_modulo"];
$id_module = $module["id_modulo"]; $id_module = $module["id_modulo"];
$nombre_modulo = $module["nombre"]; $nombre_modulo = $module["nombre"];
@ -509,15 +509,25 @@ foreach ($modules as $module) {
$data[0] .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) $data[0] .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => ""))
. "&nbsp;"; . "&nbsp;";
} }
$data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $id_agente . '&tab=module&edit_module=1&id_agent_module='.$module['id_agente_modulo'].'">';
if ($module["disabled"]) if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
$data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $id_agente . '&tab=module&edit_module=1&id_agent_module='.$module['id_agente_modulo'].'">';
}
if ($module["disabled"]) {
$data[0] .= '<em class="disabled_module">' . $data[0] .= '<em class="disabled_module">' .
ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt').'</em>'; ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt').'</em>';
else }
else {
$data[0] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt'); $data[0] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt');
$data[0] .= '</a>'; }
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
$data[0] .= '</a>';
}
// The access to the policy is granted only with AW permission
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
$policyInfo = policies_info_module_policy($module['id_agente_modulo']); $policyInfo = policies_info_module_policy($module['id_agente_modulo']);
if ($policyInfo === false) if ($policyInfo === false)
$data[1] = ''; $data[1] = '';
@ -591,47 +601,65 @@ foreach ($modules as $module) {
// MAX / MIN values // MAX / MIN values
$data[7] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); $data[7] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]);
// Delete module if ($module['disabled']) {
$data[8] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true); $data[8] = "<a href='index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=".$id_agente."&enable_module=".$module['id_agente_modulo']."'>".
$data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'].'" html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable module'), 'title' => __('Enable module'))) ."</a>";
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; }
$data[8] .= html_print_image ('images/cross.png', true, else {
array ('title' => __('Delete'))); $data[8] = "<a href='index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=".$id_agente."&disable_module=".$module['id_agente_modulo']."'>".
$data[8] .= '</a> '; html_print_image('images/lightbulb.png', true, array('alt' => __('Disable module'), 'title' => __('Disable module'))) ."</a>";
$data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'].'" }
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/copy.png', true,
array ('title' => __('Duplicate')));
$data[8] .= '</a> ';
// Make a data normalization if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
// Delete module
if (isset($numericModules[$type])) { $data[8] .= html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true);
if ($numericModules[$type] === true) { $data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'].'"
$data[8] .= '&nbsp;<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/chart_curve.png', true, $data[8] .= html_print_image ('images/cross.png', true,
array ('title' => __('Normalize'))); array ('title' => __('Delete')));
$data[8] .= '</a>'; $data[8] .= '</a> ';
$data[8] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/copy.png', true,
array ('title' => __('Duplicate')));
$data[8] .= '</a> ';
// Make a data normalization
if (isset($numericModules[$type])) {
if ($numericModules[$type] === true) {
$data[8] .= '&nbsp;<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/chart_curve.png', true,
array ('title' => __('Normalize')));
$data[8] .= '</a>';
}
}
//create network component action
if (is_user_admin($config['id_user'])) {
$data[8] .= '&nbsp;<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/network.png', true,
array ('title' => __('Create network component')));
$data[8] .= '</a> ';
} }
} }
//create network component action
if (is_user_admin($config['id_user'])) {
$data[8] .= '&nbsp;<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image ('images/network.png', true,
array ('title' => __('Create network component')));
$data[8] .= '</a> ';
}
array_push ($table->data, $data); array_push ($table->data, $data);
} }
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module" if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
onsubmit="if (! confirm (\''.__('Are you sure?').'\')) return false">'; echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module"
onsubmit="if (! confirm (\''.__('Are you sure?').'\')) return false">';
}
html_print_table ($table); html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden ('multiple_delete', 1); if(check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
html_print_submit_button (__('Delete'), 'multiple_delete', false, 'class="sub delete"'); echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '</div>'; html_print_input_hidden ('multiple_delete', 1);
echo '</form>' html_print_submit_button (__('Delete'), 'multiple_delete', false, 'class="sub delete"');
echo '</div>';
echo '</form>';
}
?> ?>

View File

@ -20,7 +20,7 @@ check_login ();
/* Check if this page is included from a agent edition */ /* Check if this page is included from a agent edition */
if (! check_acl ($config['id_user'], 0, "LW")) { if (! check_acl ($config['id_user'], 0, "LW") && ! check_acl ($config['id_user'], 0, "AD")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to access Alert Management"); "Trying to access Alert Management");
require ("general/noaccess.php"); require ("general/noaccess.php");
@ -34,14 +34,10 @@ require_once ($config['homedir'].'/include/functions_users.php');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$sec = 'advanced'; $sec = 'advanced';
} }
else { else {
$sec = 'galertas'; $sec = 'galertas';
} }
// Table for filter controls // Table for filter controls
@ -401,27 +397,55 @@ foreach ($simple_alerts as $alert) {
$iterator++; $iterator++;
$data = array (); $data = array ();
if (! $id_agente) { if (! $id_agente) {
$id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']); $id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']);
$data[0] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agent.'">';
$agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent);
$data[0] = '';
if(check_acl ($config['id_user'], $agent_group, "AW")) {
$main_tab = 'main';
}
else {
$main_tab = 'module';
}
$data[0] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab='.$main_tab.'&id_agente='.$id_agent.'">';
if ($alert['disabled']) if ($alert['disabled'])
$data[0] .= '<span style="font-style: italic; color: #aaaaaa;">'; $data[0] .= '<span style="font-style: italic; color: #aaaaaa;">';
$data[0] .= '<span style="font-size: 7.2pt">' . agents_get_name ($id_agent) . '</span>'; $data[0] .= '<span style="font-size: 7.2pt">' . agents_get_name ($id_agent) . '</span>';
if ($alert['disabled']) if ($alert['disabled'])
$data[0] .= '</span>'; $data[0] .= '</span>';
$data[0] .= '</a>'; $data[0] .= '</a>';
} }
else {
$agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agente);
}
$data[1] = ui_print_truncate_text( $data[1] = ui_print_truncate_text(
modules_get_agentmodule_name ($alert['id_agent_module']), 'module_small', false, true, true, '[&hellip;]', 'font-size: 7.2pt'); modules_get_agentmodule_name ($alert['id_agent_module']), 'module_small', false, true, true, '[&hellip;]', 'font-size: 7.2pt');
$data[2] = ' <a class="template_details" $data[2] = ' <a class="template_details"
href="'.ui_get_full_url(false,false,false,false).'ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'">' . href="'.ui_get_full_url(false,false,false,false).'ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'">' .
html_print_image("images/zoom.png", true, array("id" => 'template-details-'.$alert['id_alert_template'], "class" => "img_help")) . '</a> '; html_print_image("images/zoom.png", true, array("id" => 'template-details-'.$alert['id_alert_template'], "class" => "img_help")) . '</a> ';
$data[2] .= "<a href='index.php?sec=".$sec."&sec2=godmode/alerts/configure_alert_template&id=".$alert['id_alert_template']."'>";
$template_group = db_get_value('id_group', 'talert_templates', 'id', $alert['id_alert_template']);
// The access to the template manage page is necessary have LW permissions on template group
if(check_acl ($config['id_user'], $template_group, "LW")) {
$data[2] .= "<a href='index.php?sec=".$sec."&sec2=godmode/alerts/configure_alert_template&id=".$alert['id_alert_template']."'>";
}
$data[2] .= ui_print_truncate_text( $data[2] .= ui_print_truncate_text(
alerts_get_alert_template_name ($alert['id_alert_template']), GENERIC_SIZE_TEXT, false, true, true, '[&hellip;]', 'font-size: 7.1pt'); alerts_get_alert_template_name ($alert['id_alert_template']), GENERIC_SIZE_TEXT, false, true, true, '[&hellip;]', 'font-size: 7.1pt');
$data[2] .= "</a>";
if(check_acl ($config['id_user'], $template_group, "LW")) {
$data[2] .= "</a>";
}
$actions = alerts_get_alert_agent_module_actions ($alert['id']); $actions = alerts_get_alert_agent_module_actions ($alert['id']);
@ -461,50 +485,56 @@ foreach ($simple_alerts as $alert) {
$data[3] .= ')</em>'; $data[3] .= ')</em>';
$data[3] .= '</font>'; $data[3] .= '</font>';
$data[3] .= '<form method="post" class="delete_link" style="display: inline; vertical-align: -50%;">'; // Is possible manage actions if have LW permissions in the agent group of the alert module
$data[3] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete'))); if(check_acl ($config['id_user'], $agent_group, "LW")) {
$data[3] .= html_print_input_hidden ('delete_action', 1, true); $data[3] .= '<form method="post" class="delete_link" style="display: inline; vertical-align: -50%;">';
$data[3] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[3] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete')));
$data[3] .= html_print_input_hidden ('id_action', $action_id, true); $data[3] .= html_print_input_hidden ('delete_action', 1, true);
$data[3] .= '</form>'; $data[3] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[3] .= html_print_input_hidden ('id_action', $action_id, true);
$data[3] .= '</form>';
}
$data[3] .= '</li>'; $data[3] .= '</li>';
} }
$data[3] .= '</ul>'; $data[3] .= '</ul>';
} }
// Is possible manage actions if have LW permissions in the agent group of the alert module
if(check_acl ($config['id_user'], $agent_group, "LW")) {
$data[3] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
$data[3] .= html_print_image ('images/add.png', true);
if ($alert['disabled'])
$data[3] .= ' '. '<span style="font-style: italic; color: #aaaaaa;">' .__('Add action') . '</span>';
else
$data[3] .= ' ' . __('Add action');
$data[3] .= '</a>';
$data[3] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">'; $data[3] .= '<form id="add_action_form-'.$alert['id'].'" method="post" class="invisible">';
$data[3] .= html_print_image ('images/add.png', true); $data[3] .= html_print_input_hidden ('add_action', 1, true);
if ($alert['disabled']) $data[3] .= html_print_input_hidden ('id_alert_module', $alert['id'], true);
$data[3] .= ' '. '<span style="font-style: italic; color: #aaaaaa;">' .__('Add action') . '</span>'; $own_info = get_user_info($config['id_user']);
else $own_groups = users_get_groups($config['id_user'], 'LW', true);
$data[3] .= ' ' . __('Add action'); $filter_groups = '';
$data[3] .= '</a>'; $filter_groups = implode(',', array_keys($own_groups));
$actions = alerts_get_alert_actions_filter(true, 'id_group IN (' . $filter_groups . ')');
$data[3] .= '<form id="add_action_form-'.$alert['id'].'" method="post" class="invisible">'; $data[3] .= html_print_select ($actions, 'action', '', '', __('None'), 0, true);
$data[3] .= html_print_input_hidden ('add_action', 1, true); $data[3] .= '<br />';
$data[3] .= html_print_input_hidden ('id_alert_module', $alert['id'], true); $data[3] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>';
$own_info = get_user_info($config['id_user']); $data[3] .= '<span class="advanced_actions invisible">';
$own_groups = users_get_groups($config['id_user'], 'LW', true); $data[3] .= __('Number of alerts match from').' ';
$filter_groups = ''; $data[3] .= html_print_input_text ('fires_min', -1, '', 4, 10, true);
$filter_groups = implode(',', array_keys($own_groups)); $data[3] .= ' '.__('to').' ';
$actions = alerts_get_alert_actions_filter(true, 'id_group IN (' . $filter_groups . ')'); $data[3] .= html_print_input_text ('fires_max', -1, '', 4, 10, true);
$data[3] .= html_print_select ($actions, 'action', '', '', __('None'), 0, true); $data[3] .= ui_print_help_icon ("alert-matches", true, ui_get_full_url(false, false, false, false));
$data[3] .= '<br />'; $data[3] .= '<br />' . __('Threshold');
$data[3] .= '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>'; $data[3] .= html_print_input_text ('module_action_threshold', '', '', 4, 10, true) . ui_print_help_icon ('action_threshold', true, ui_get_full_url(false, false, false, false));
$data[3] .= '<span class="advanced_actions invisible">'; $data[3] .= '</span>';
$data[3] .= __('Number of alerts match from').' '; $data[3] .= '<div class="right">';
$data[3] .= html_print_input_text ('fires_min', -1, '', 4, 10, true); $data[3] .= html_print_submit_button (__('Add'), 'add_action', false, 'class="sub next"', true);
$data[3] .= ' '.__('to').' '; $data[3] .= '</div>';
$data[3] .= html_print_input_text ('fires_max', -1, '', 4, 10, true); $data[3] .= '</form>';
$data[3] .= ui_print_help_icon ("alert-matches", true, ui_get_full_url(false, false, false, false)); }
$data[3] .= '<br />' . __('Threshold');
$data[3] .= html_print_input_text ('module_action_threshold', '', '', 4, 10, true) . ui_print_help_icon ('action_threshold', true, ui_get_full_url(false, false, false, false));
$data[3] .= '</span>';
$data[3] .= '<div class="right">';
$data[3] .= html_print_submit_button (__('Add'), 'add_action', false, 'class="sub next"', true);
$data[3] .= '</div>';
$data[3] .= '</form>';
$status = STATUS_ALERT_NOT_FIRED; $status = STATUS_ALERT_NOT_FIRED;
$title = ""; $title = "";
@ -536,36 +566,45 @@ foreach ($simple_alerts as $alert) {
$data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= '</form>'; $data[5] .= '</form>';
$data[5] .= '&nbsp;&nbsp;<form class="standby_alert_form" method="post" style="display: inline;">'; // To manage alert is necessary LW permissions in the agent group
if (!$alert['standby']) { if(check_acl ($config['id_user'], $agent_group, "LW")) {
$data[5] .= html_print_input_image ('standby_off', 'images/bell.png', 1, '', true); $data[5] .= '&nbsp;&nbsp;<form class="standby_alert_form" method="post" style="display: inline;">';
$data[5] .= html_print_input_hidden ('standbyon_alert', 1, true); if (!$alert['standby']) {
} $data[5] .= html_print_input_image ('standby_off', 'images/bell.png', 1, '', true);
else { $data[5] .= html_print_input_hidden ('standbyon_alert', 1, true);
$data[5] .= html_print_input_image ('standby_on', 'images/bell_pause.png', 1, '', true); }
$data[5] .= html_print_input_hidden ('standbyoff_alert', 1, true);
}
$data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= '</form>';
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$policyInfo = policies_is_alert_in_policy2($alert['id'], false);
if ($policyInfo === false)
$data[5] .= '';
else { else {
$img = 'images/policies.png'; $data[5] .= html_print_input_image ('standby_on', 'images/bell_pause.png', 1, '', true);
$data[5] .= html_print_input_hidden ('standbyoff_alert', 1, true);
$data[5] .= '&nbsp;&nbsp;<a href="?sec=gpolicies&sec2=enterprise/godmode/policies/policies&pure='.$pure.'&id=' . $policyInfo['id'] . '">' . }
html_print_image($img,true, array('title' => $policyInfo['name'])) . $data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true);
'</a>'; $data[5] .= '</form>';
}
// To access to policy page is necessary have AW permissions in the agent
if(check_acl ($config['id_user'], $agent_group, "AW")) {
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$policyInfo = policies_is_alert_in_policy2($alert['id'], false);
if ($policyInfo === false)
$data[5] .= '';
else {
$img = 'images/policies.png';
$data[5] .= '&nbsp;&nbsp;<a href="?sec=gpolicies&sec2=enterprise/godmode/policies/policies&pure='.$pure.'&id=' . $policyInfo['id'] . '">' .
html_print_image($img,true, array('title' => $policyInfo['name'])) .
'</a>';
}
} }
} }
$data[5] .= '&nbsp;&nbsp;<form class="delete_alert_form" method="post" style="display: inline;">'; // To manage alert is necessary LW permissions in the agent group
$data[5] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete'))); if(check_acl ($config['id_user'], $agent_group, "LW")) {
$data[5] .= html_print_input_hidden ('delete_alert', 1, true); $data[5] .= '&nbsp;&nbsp;<form class="delete_alert_form" method="post" style="display: inline;">';
$data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[5] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete')));
$data[5] .= '</form>'; $data[5] .= html_print_input_hidden ('delete_alert', 1, true);
$data[5] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[5] .= '</form>';
}
array_push ($table->data, $data); array_push ($table->data, $data);
} }
@ -583,7 +622,7 @@ if (isset($dont_display_alert_create_bttn))
if ($dont_display_alert_create_bttn) if ($dont_display_alert_create_bttn)
$display_create = false; $display_create = false;
if ($display_create){ if ($display_create && check_acl ($config['id_user'], 0, "LW")){
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_list&tab=builder&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_list&tab=builder&pure='.$pure.'">';
html_print_submit_button (__('Create'), 'crtbtn', false, 'class="sub next"'); html_print_submit_button (__('Create'), 'crtbtn', false, 'class="sub next"');

View File

@ -18,7 +18,7 @@ global $config;
// Login check // Login check
check_login (); check_login ();
if (! check_acl ($config['id_user'], 0, "LW")) { if (! check_acl ($config['id_user'], 0, "LW") && ! check_acl ($config['id_user'], 0, "AD")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to access Alert Management"); "Trying to access Alert Management");
require ("general/noaccess.php"); require ("general/noaccess.php");
@ -260,22 +260,32 @@ if ($id_agente) {
echo $messageAction; echo $messageAction;
require_once('godmode/alerts/alert_list.list.php'); require_once('godmode/alerts/alert_list.list.php');
require_once('godmode/alerts/alert_list.builder.php');
if(check_acl ($config['id_user'], 0, "LW")) {
require_once('godmode/alerts/alert_list.builder.php');
}
return; return;
} }
else { else {
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$buttons = array( // The tabs will be shown only with manage alerts permissions
'list' => array( if(check_acl ($config['id_user'], 0, "LW")) {
'active' => false, $buttons = array(
'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure='.$pure.'">' . 'list' => array(
html_print_image ("images/god6.png", true, array ("title" => __('List alerts'))) .'</a>'), 'active' => false,
'builder' => array( 'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure='.$pure.'">' .
'active' => false, html_print_image ("images/god6.png", true, array ("title" => __('List alerts'))) .'</a>'),
'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=builder&pure='.$pure.'">' . 'builder' => array(
html_print_image ("images/config.png", true, array ("title" => __('Builder alert'))) .'</a>')); 'active' => false,
'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=builder&pure='.$pure.'">' .
$buttons[$tab]['active'] = true; html_print_image ("images/config.png", true, array ("title" => __('Builder alert'))) .'</a>'));
$buttons[$tab]['active'] = true;
}
else {
$buttons = "";
}
if ($tab == 'list') { if ($tab == 'list') {
ui_print_page_header(__('Alerts') . ' &raquo; ' . __('Manage alerts') . ' &raquo; ' . __('List'), "images/god2.png", false, "manage_alert_list", true, $buttons); ui_print_page_header(__('Alerts') . ' &raquo; ' . __('Manage alerts') . ' &raquo; ' . __('List'), "images/god2.png", false, "manage_alert_list", true, $buttons);
@ -286,9 +296,7 @@ else {
} }
else { else {
alerts_meta_print_header(); alerts_meta_print_header();
} }
echo $messageAction; echo $messageAction;

View File

@ -24,27 +24,29 @@ require_once ('include/functions_menu.php');
$menu_godmode = array (); $menu_godmode = array ();
$menu_godmode['class'] = 'godmode'; $menu_godmode['class'] = 'godmode';
if (check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "AD")) {
$menu_godmode["gagente"]["text"] = __('Manage monitoring'); $menu_godmode["gagente"]["text"] = __('Manage monitoring');
$menu_godmode["gagente"]["sec2"] = "godmode/agentes/modificar_agente"; $menu_godmode["gagente"]["sec2"] = "godmode/agentes/modificar_agente";
$menu_godmode["gagente"]["id"] = "god-agents"; $menu_godmode["gagente"]["id"] = "god-agents";
$sub = array (); if(check_acl ($config['id_user'], 0, "AW")) {
$sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); $sub = array ();
$sub["godmode/agentes/modificar_agente"]["subsecs"] = array( $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents');
"godmode/agentes/configurar_agente"); $sub["godmode/agentes/modificar_agente"]["subsecs"] = array(
"godmode/agentes/configurar_agente");
$sub["godmode/agentes/manage_config_remote"]["text"] = __('Duplicate config');
$sub["godmode/agentes/manage_config_remote"]["text"] = __('Duplicate config'); if (check_acl ($config["id_user"], 0, "PM")) {
$sub["godmode/groups/group_list"]["text"] = __('Manage groups');
if (check_acl ($config["id_user"], 0, "PM")) { $sub["godmode/groups/modu_group_list"]["text"] = __('Module groups');
$sub["godmode/groups/group_list"]["text"] = __('Manage groups'); $sub["godmode/agentes/planned_downtime.list"]["text"] = __('Scheduled downtime');
$sub["godmode/groups/modu_group_list"]["text"] = __('Module groups'); $sub["godmode/agentes/fields_manager"]["text"] = __('Manage custom fields');
$sub["godmode/agentes/planned_downtime.list"]["text"] = __('Scheduled downtime'); }
$sub["godmode/agentes/fields_manager"]["text"] = __('Manage custom fields'); enterprise_hook('agents_submenu');
$menu_godmode["gagente"]["sub"] = $sub;
} }
enterprise_hook('agents_submenu');
$menu_godmode["gagente"]["sub"] = $sub;
} }
if (check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "AW")) {
@ -95,23 +97,25 @@ if (check_acl ($config['id_user'], 0, "PM")) {
$menu_godmode["gmodules"]["sub"] = $sub; $menu_godmode["gmodules"]["sub"] = $sub;
} }
if (check_acl ($config['id_user'], 0, "LM")) { if (check_acl ($config['id_user'], 0, "LM") || check_acl ($config['id_user'], 0, "AD")) {
$menu_godmode["galertas"]["text"] = __('Manage alerts'); $menu_godmode["galertas"]["text"] = __('Manage alerts');
$menu_godmode["galertas"]["sec2"] = "godmode/alerts/alert_list"; $menu_godmode["galertas"]["sec2"] = "godmode/alerts/alert_list";
$menu_godmode["galertas"]["id"] = "god-alerts"; $menu_godmode["galertas"]["id"] = "god-alerts";
$sub = array (); if(check_acl ($config['id_user'], 0, "LM")) {
$sub["godmode/alerts/alert_templates"]["text"] = __('Templates'); $sub = array ();
$sub["godmode/alerts/alert_actions"]["text"] = __('Actions'); $sub["godmode/alerts/alert_templates"]["text"] = __('Templates');
$sub["godmode/alerts/alert_actions"]["text"] = __('Actions');
if (check_acl ($config['id_user'], 0, "PM")) { if (check_acl ($config['id_user'], 0, "PM")) {
$sub["godmode/alerts/alert_commands"]["text"] = __('Commands'); $sub["godmode/alerts/alert_commands"]["text"] = __('Commands');
}
$sub["godmode/alerts/alert_compounds"]["text"] = __('Correlation');
$sub["godmode/alerts/alert_special_days"]["text"] = __('Special days list');
enterprise_hook('eventalerts_submenu');
$menu_godmode["galertas"]["sub"] = $sub;
} }
$sub["godmode/alerts/alert_compounds"]["text"] = __('Correlation');
$sub["godmode/alerts/alert_special_days"]["text"] = __('Special days list');
enterprise_hook('eventalerts_submenu');
$menu_godmode["galertas"]["sub"] = $sub;
} }
if (check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "AW")) {

View File

@ -1485,7 +1485,8 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
tperfil.db_management, tperfil.user_management, tperfil.db_management, tperfil.user_management,
tperfil.report_view, tperfil.report_edit, tperfil.report_view, tperfil.report_edit,
tperfil.report_management, tperfil.event_view, tperfil.report_management, tperfil.event_view,
tperfil.event_edit, tperfil.event_management tperfil.event_edit, tperfil.event_management,
tperfil.agent_disable
FROM tusuario_perfil, tperfil FROM tusuario_perfil, tperfil
WHERE tusuario_perfil.id_perfil = tperfil.id_perfil WHERE tusuario_perfil.id_perfil = tperfil.id_perfil
AND tusuario_perfil.id_usuario = '%s'", $id_user); AND tusuario_perfil.id_usuario = '%s'", $id_user);
@ -1499,7 +1500,8 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
tperfil.db_management, tperfil.user_management, tperfil.db_management, tperfil.user_management,
tperfil.report_view, tperfil.report_edit, tperfil.report_view, tperfil.report_edit,
tperfil.report_management, tperfil.event_view, tperfil.report_management, tperfil.event_view,
tperfil.event_edit, tperfil.event_management tperfil.event_edit, tperfil.event_management,
tperfil.agent_disable
FROM tusuario_perfil, tperfil FROM tusuario_perfil, tperfil
WHERE tusuario_perfil.id_perfil = tperfil.id_perfil WHERE tusuario_perfil.id_perfil = tperfil.id_perfil
AND tusuario_perfil.id_usuario = '%s' AND tusuario_perfil.id_usuario = '%s'

View File

@ -831,17 +831,6 @@ function ui_format_alert_row ($alert, $compound = false, $agent = true, $url = '
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$data[$index['validate']] = ''; $data[$index['validate']] = '';
//~ if (check_acl ($config["id_user"], $id_group, "AD")) {
//~ if ($alert['disabled']) {
//~ $data[$index['validate']] .= html_print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true);
//~ $data[$index['validate']] .= html_print_input_hidden ('enable_alert', 1, true);
//~ }
//~ else {
//~ $data[$index['validate']] .= html_print_input_image ('disable', 'images/lightbulb.png', 1, '', true);
//~ $data[$index['validate']] .= html_print_input_hidden ('disable_alert', 1, true);
//~ }
//~ }
if ($compound) { if ($compound) {
$data[$index['validate']] .= html_print_checkbox ("validate_compound[]", $alert["id"], false, true); $data[$index['validate']] .= html_print_checkbox ("validate_compound[]", $alert["id"], false, true);
} }

View File

@ -284,8 +284,8 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$table->head[6] = __('Action'); $table->head[6] = __('Action');
$table->head[7] = __('Last fired'); $table->head[7] = __('Last fired');
$table->head[8] = __('Status'); $table->head[8] = __('Status');
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM") || check_acl ($config["id_user"], $id_group, "AD")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$table->head[9] = __('Actions'); $table->head[9] = __('Validate');
} }
$table->align[8] = 'center'; $table->align[8] = 'center';
$table->align[9] = 'center'; $table->align[9] = 'center';
@ -304,8 +304,8 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$table->head[5] = __('Action'); $table->head[5] = __('Action');
$table->head[6] = __('Last fired'); $table->head[6] = __('Last fired');
$table->head[7] = __('Status'); $table->head[7] = __('Status');
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM") || check_acl ($config["id_user"], $id_group, "AD")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$table->head[8] = __('Actions'); $table->head[8] = __('Validate');
} }
$table->align[7] = 'center'; $table->align[7] = 'center';
$table->align[8] = 'center'; $table->align[8] = 'center';
@ -329,8 +329,8 @@ else
$table->head[5] = __('Action'); $table->head[5] = __('Action');
$table->head[6] = __('Last fired'); $table->head[6] = __('Last fired');
$table->head[7] = __('Status'); $table->head[7] = __('Status');
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM") || check_acl ($config["id_user"], $id_group, "AD")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$table->head[8] = __('Actions'); $table->head[8] = __('Validate');
} }
$table->align[7] = 'center'; $table->align[7] = 'center';
$table->align[8] = 'center'; $table->align[8] = 'center';
@ -347,8 +347,8 @@ else
$table->head[4] = __('Action'); $table->head[4] = __('Action');
$table->head[5] = __('Last fired'); $table->head[5] = __('Last fired');
$table->head[6] = __('Status'); $table->head[6] = __('Status');
if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM") || check_acl ($config["id_user"], $id_group, "AD")) { if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
$table->head[7] = __('Actions'); $table->head[7] = __('Validate');
} }
$table->align[6] = 'center'; $table->align[6] = 'center';
$table->align[7] = 'center'; $table->align[7] = 'center';
@ -380,7 +380,7 @@ else {
} }
if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "AM")) { if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "AM")) {
if (count($alerts['alerts_simple']) > 0 || count($alerts['alerts_combined']) > 0) { if (count($alerts['alerts_simple']) > 0) {
echo '<div class="action-buttons" style="width: '.$table->width.';">'; echo '<div class="action-buttons" style="width: '.$table->width.';">';
html_print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub upd"', false); html_print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub upd"', false);
echo '</div>'; echo '</div>';

View File

@ -109,31 +109,6 @@ if (is_ajax ()) {
} }
ob_end_clean(); ob_end_clean();
$agent_to_delete = get_parameter("borrar_agente");
if (!empty($agent_to_delete)) {
$id_agente = $agent_to_delete;
$agent_name = agents_get_name ($id_agente);
$id_grupo = agents_get_agent_group($id_agente);
if (check_acl ($config["id_user"], $id_grupo, "AW")==1) {
$id_agentes[0] = $id_agente;
$result = agents_delete_agent($id_agentes);
if ($result != false)
$result_delete = true;
else
$result_delete = false;
db_pandora_audit("Agent management", "Delete Agent " . $agent_name);
}
else {
// NO permissions.
db_pandora_audit("ACL Violation",
"Trying to delete agent \'$agent_name\'");
require ("general/noaccess.php");
exit;
}
}
$first = true; $first = true;
while ($row = db_get_all_row_by_steps_sql($first, $result, "SELECT * FROM tgrupo")) { while ($row = db_get_all_row_by_steps_sql($first, $result, "SELECT * FROM tgrupo")) {
$first = false; $first = false;
@ -415,8 +390,6 @@ $table->align = array ();
if (check_acl ($config["id_user"], $group_id, "AW")) { if (check_acl ($config["id_user"], $group_id, "AW")) {
$table->head[9] = __('R'); $table->head[9] = __('R');
$table->align[9] = "center"; $table->align[9] = "center";
$table->head[10] = __('Delete');
$table->align[10] = "center";
} }
$table->align[2] = "center"; $table->align[2] = "center";
@ -528,10 +501,6 @@ foreach ($agents as $agent) {
$data[9] = "<a href='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$agent["id_agente"]."&disk_conf=1'>". $data[9] = "<a href='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$agent["id_agente"]."&disk_conf=1'>".
html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config')))."</a>"; html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config')))."</a>";
} }
$data[10] = "<a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$group_id&recursion=$recursion&search=$search&offset=$offset&sort_field=$sortField&sort=$sort'".
' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, array("border" => '0')) ."</a></td>";
} }
array_push ($table->data, $data); array_push ($table->data, $data);