From 8fad28d9468980efa8af8105904a748387466325 Mon Sep 17 00:00:00 2001 From: guruevi Date: Mon, 20 Oct 2008 17:25:37 +0000 Subject: [PATCH] 2008-10-20 Evi Vanoost * pandoradb_data.sql, pandora_db.sql: id_npc was rendered unnecessary with the last rewrite of the profiles page and id_np should really be the key since that what we're selecting/sorting on. * operation/events/events.php: Fixed Bug #2174790 and fixed the brackets being in all the wrong places. Also added checks so that only admins can retrieve system events * include/functions_db.php: Added an option to get_user_groups so that other privileges than AR can be retrieved. * operation/visual_console/index.php: Added ACL check. Security issue reported in bug #2174790 * operation/menu.php: Added ACL check. Security issue reported in bug #2174790 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1177 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 19 ++ pandora_console/include/functions_db.php | 8 +- pandora_console/operation/events/events.php | 168 ++++++++++-------- pandora_console/operation/menu.php | 19 +- .../operation/visual_console/index.php | 48 ++--- .../operation/visual_console/render_view.php | 14 +- pandora_console/pandoradb.sql | 7 +- pandora_console/pandoradb_data.sql | 90 +++++----- 8 files changed, 204 insertions(+), 169 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7226d678ef..57e9a0f8f1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2008-10-20 Evi Vanoost + + * pandoradb_data.sql, pandora_db.sql: id_npc was rendered unnecessary + with the last rewrite of the profiles page and id_np should really be + the key since that what we're selecting/sorting on. + + * operation/events/events.php: Fixed Bug #2174790 and fixed the + brackets being in all the wrong places. Also added checks so that only + admins can retrieve system events + + * include/functions_db.php: Added an option to get_user_groups so that + other privileges than AR can be retrieved. + + * operation/visual_console/index.php: Added ACL check. Security issue + reported in bug #2174790 + + * operation/menu.php: Added ACL check. Security issue reported in bug + #2174790 + 2008-10-20 Esteban Sanchez * operation/agentes/estado_agente.php: Checking if there are monitors diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 7bc4718d62..3dffdd34b9 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1078,10 +1078,10 @@ function list_users ($order = "nombre_real") { * Get all the groups a user has reading privileges. * * @param id_user User id - * - * @return A list of the groups the user has reading privileges. + * @param privilege The privilege to evaluate + * @return A list of the groups the user has certain privileges. */ -function get_user_groups ($id_user = 0) { +function get_user_groups ($id_user = 0, $privilege = "AR") { if ($id_user == 0) { global $config; $id_user = $config['id_user']; @@ -1094,7 +1094,7 @@ function get_user_groups ($id_user = 0) { return $user_groups; foreach ($groups as $group) { - if (! give_acl ($id_user, $group["id_grupo"], "AR")) + if (! give_acl ($id_user, $group["id_grupo"], $privilege)) continue; $user_groups[$group['id_grupo']] = $group['nombre']; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 30854215c0..e57ff403b5 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -165,23 +165,36 @@ if (isset ($_POST["updatebt"])) { // Get data $offset = (int) get_parameter ( "offset",0); -$ev_group = (int) get_parameter ("ev_group", 0); // group +$ev_group = (int) get_parameter ("ev_group", 1); //1 = all $search = get_parameter ("search", ""); // free search $event_type = get_parameter ("event_type", ''); // 0 all $severity = (int) get_parameter ("severity", -1); // -1 all $status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green -$id_agent = (int) get_parameter ("id_agent", -1); +$id_agent = (int) get_parameter ("id_agent", -1); //-1 all, 0 system $id_event = (int) get_parameter ("id_event", -1); $pagination = (int) get_parameter ("pagination", $config["block_size"]); $config["block_size"] = $pagination; +$groups = get_user_groups ($config["id_user"]); +//Group selection -$sql_post = ""; -if ($ev_group > 1) - $sql_post .= " AND id_grupo = $ev_group"; -if ($status == 1) +if ($ev_group > 1 && in_array ($ev_group, array_keys ($groups))) { + //If a group is selected and it's in the groups allowed + $sql_post = " AND id_grupo = $ev_group"; +} elseif (dame_admin ($config["id_user"])) { + //Do nothing if you're admin, you get full access + $sql_post = ""; + $groups[0] = __('System Events'); +} else { + //Otherwise select all groups the user has rights to. + $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; +} + +if ($status == 1) { $sql_post .= " AND estado = 1"; -if ($status == 0) +} elseif ($status == 0) { $sql_post .= " AND estado = 0"; +} + if ($search != "") $sql_post .= " AND evento LIKE '%$search%'"; if ($event_type != "") @@ -197,16 +210,15 @@ $url = "index.php?sec=eventos&sec2=operation/events/events&search=$search&event_ echo "

".__('Events')." > ".__('Main event view'). " "; -if ($config["pure"] == 1) +if ($config["pure"] == 1) { echo ""; -else { +} else { // Fullscreen echo ""; } echo "

"; - -echo ""; -echo "".__('Event control filter')." ".''; +echo ''; +echo "".__('Event control filter')." ".''; if ($config["pure"] == 1) { echo ""; +echo ""; +echo ''; //Don't rely on browsers to do this correctly +echo ""; -$sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY timestamp DESC LIMIT ".$offset.",".$config["block_size"]; +$sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$config["block_size"]; $result = get_db_all_rows_sql ($sql); $sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post; $total_events = get_db_sql ($sql); // Show pagination header -if ($total_events > 0){ +if ($total_events > 0) { $offset = get_parameter ("offset",0); pagination ($total_events, $url."&pure=".$config["pure"], $offset); @@ -348,7 +361,7 @@ if ($total_events > 0){ // Make query for data (all data, not only distinct). foreach ($result as $row2) { $id_grupo = $row2["id_grupo"]; - if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data ! + if (give_acl($config["id_user"], $id_grupo, "AR") == 1) // Only incident read access to view data ! $id_group = $row2["id_grupo"]; switch ($row2["criticity"]) { @@ -373,14 +386,15 @@ if ($total_events > 0){ $criticity_label = return_priority ($row2["criticity"]); // Colored box echo ""; - if ($row2["estado"] == 0) + if ($row2["estado"] == 0) { echo ""; - else + } else { echo ""; + } // Event type echo ""; - switch ($row2["event_type"]){ + switch ($row2["event_type"]) { case "unknown": echo ""; break; @@ -438,50 +452,48 @@ if ($total_events > 0){ echo ""; // for System or SNMP generated alerts - } else { - if ($row2["event_type"] == "system") { - echo "".__('System'); - } else { - echo "".__('Alert')."SNMP"; - } - } - - // User who validated event - echo ""; - if ($row2["estado"] <> 0) - echo "".substr($row2["id_usuario"],0,8)." ".dame_nombre_real($row2["id_usuario"]).""; - - // Timestamp - echo ""; - echo human_time_comparation ($row2["timestamp"]); - echo ""; - // Several options grouped here - echo ""; - // Validate event - if (($row2["estado"] == 0) and (give_acl ($config["id_user"], $id_group,"IW") ==1)) - echo " - "; - // Delete event - if (give_acl ($config["id_user"], $id_group,"IM") ==1) - echo " - "; - // Create incident from this event - if (give_acl ($config["id_user"], $id_group,"IW") == 1) - echo ""; - echo ""; - // Checbox - echo ""; - echo ""; - echo ""; + } elseif ($row2["event_type"] == "system") { + echo "".__('System'); + } else { + echo "".__('Alert')."SNMP"; } + + // User who validated event + echo ""; + if ($row2["estado"] <> 0) + echo "".substr($row2["id_usuario"],0,8)." ".dame_nombre_real($row2["id_usuario"]).""; + + // Timestamp + echo ""; + echo human_time_comparation ($row2["timestamp"]); + echo ""; + // Several options grouped here + echo ""; + // Validate event + if (($row2["estado"] == 0) and (give_acl ($config["id_user"], $id_group,"IW") ==1)) + echo " + "; + // Delete event + if (give_acl ($config["id_user"], $id_group,"IM") ==1) + echo " + "; + // Create incident from this event + if (give_acl ($config["id_user"], $id_group,"IW") == 1) + echo ""; + echo ""; + // Checbox + echo ""; + echo ""; + echo ""; + $offset_counter++; } echo ""; echo "
"; echo " "; - if (give_acl ($config["id_user"], 0,"IM") ==1){ + if (give_acl ($config["id_user"], 0,"IM") == 1) { echo ""; } echo "
"; diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 450b6138af..128ef5fdcd 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -100,17 +100,18 @@ if (give_acl ($config['id_user'], 0, "AR")) { echo ''.__('Visual console').''; if ($sec == "visualc") { - $sql="SELECT * FROM tlayout ORDER BY name"; + $result = get_db_all_rows_in_table ('tlayout','name'); $id = get_parameter ('id'); - if ($res = mysql_query ($sql)) - while ($layout = mysql_fetch_array ($res)) { - if ($sec2 == "operation/visual_console/render_view" && $id == $layout["id"]) { - echo "