From bc11908d0a6ce9762e6a31acbb156b05a372f50e Mon Sep 17 00:00:00 2001 From: vgilc Date: Wed, 11 Jan 2012 15:02:27 +0000 Subject: [PATCH] 2012-01-11 Vanessa Gil * pandoradb.sql godmode/netflow/nf_edit_form.php godmode/netflow/nf_edit.php godmode/netflow/nf_report.php godmode/netflow/nf_report_form.php godmode/netflow/nf_report_item.php godmode/netflow/nf_reporting.php operation/netflow/nf_view.php: netflow acls. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5344 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++++++++ pandora_console/godmode/netflow/nf_edit.php | 14 ++++++++------ .../godmode/netflow/nf_edit_form.php | 19 ++++++++----------- pandora_console/godmode/netflow/nf_report.php | 14 ++++++++++++++ .../godmode/netflow/nf_report_form.php | 14 +++++++------- .../godmode/netflow/nf_report_item.php | 19 ++++++++++++++----- .../operation/netflow/nf_reporting.php | 16 ++++++++++++++-- pandora_console/operation/netflow/nf_view.php | 2 +- pandora_console/pandoradb.sql | 4 ++-- 9 files changed, 78 insertions(+), 34 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 47b3f1dfa6..6b8a115fd3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2012-01-11 Vanessa Gil + * pandoradb.sql + godmode/netflow/nf_edit_form.php + godmode/netflow/nf_edit.php + godmode/netflow/nf_report.php + godmode/netflow/nf_report_form.php + godmode/netflow/nf_report_item.php + godmode/netflow/nf_reporting.php + operation/netflow/nf_view.php: netflow acls. + 2012-01-11 Juan Manuel Ramon * include/functions_api.php: Added new functions diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index c34e577f8d..682d3dd977 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -61,7 +61,6 @@ if ($delete) { __('Not deleted. Error deleting data')); } - if ($multiple_delete) { $ids = (array)get_parameter('delete_multiple', array()); @@ -93,13 +92,16 @@ if ($multiple_delete) { __('Not deleted. Error deleting data')); } -$filter = array (); +// Get group list that user has access +$groups_user = users_get_groups ($config['id_user'], "AW", false, true); -$filter['offset'] = (int) get_parameter ('offset'); -$filter['limit'] = (int) $config['block_size']; - -$filters = db_get_all_rows_filter ('tnetflow_filter', $filter); +$groups_id = array(); +foreach($groups_user as $key => $groups){ + $groups_id[] = $groups['id_grupo']; +} +$sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',',$groups_id).")"; +$filters = db_get_all_rows_sql($sql); if ($filters === false) $filters = array (); diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index 0ae024217b..6c19b775df 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -24,7 +24,7 @@ include_once ("include/functions_groups.php"); check_login (); -if (! check_acl ($config["id_user"], 0, "AW")) { +if (! check_acl ($config["id_user"], 0, "IW")) { db_pandora_audit("ACL Violation", "Trying to access event viewer"); require ("general/noaccess.php"); @@ -49,7 +49,7 @@ ui_print_page_header (__('Netflow Filter'), "images/networkmap/so_cisco_new.png" if ($id) { $filter = netflow_filter_get_filter ($id); - $assign_group = $filter['group']; + $assign_group = $filter['id_group']; $name = $filter['id_name']; $ip_dst = $filter['ip_dst']; $ip_src = $filter['ip_src']; @@ -60,7 +60,7 @@ if ($id) { } else { $name = ''; - $assign_group = 'none'; + $assign_group = ''; $ip_dst = ''; $ip_src = ''; $dst_port = ''; @@ -85,16 +85,13 @@ if ($update) { $result = db_process_sql_update ('tnetflow_filter', array ('id_sg' => $id, 'id_name' => $name, - 'group' => $assign_group, + 'id_group' => $assign_group, 'aggregate' => $aggregate, 'ip_dst' => $ip_dst, 'ip_src' => $ip_src, 'dst_port' => $dst_port, 'src_port' => $src_port, - 'show_packets' => $show_packets, - 'show_bytes' => $show_bytes, - 'show_bps' => $show_bps, - 'show_bpp' => $show_bpp, ), + 'output' => $output), array ('id_sg' => $id)); ui_print_result_message ($result, @@ -118,7 +115,7 @@ if ($create){ } else { $values = array ( 'id_name'=>$name, - 'group' => $assign_group, + 'id_group' => $assign_group, 'ip_dst'=>$ip_dst, 'ip_src'=>$ip_src, 'dst_port'=>$dst_port, @@ -148,8 +145,8 @@ $table->data[0][1] = html_print_input_text ('name', $name, false, 20, 80, true); $own_info = get_user_info ($config['id_user']); $table->data[1][0] = ''.__('Group').''; -$table->data[1][1] = html_print_select_groups($config['id_user'], "AW", - $own_info['is_admin'], 'assign_group', $assign_group, '', __('None'), -1, true, +$table->data[1][1] = html_print_select_groups($config['id_user'], "IW", + $own_info['is_admin'], 'assign_group', $assign_group, '', '', -1, true, false, false); $table->data[2][0] = ''.__('Filter:').''; diff --git a/pandora_console/godmode/netflow/nf_report.php b/pandora_console/godmode/netflow/nf_report.php index fbf61acf5d..be4698ee7b 100644 --- a/pandora_console/godmode/netflow/nf_report.php +++ b/pandora_console/godmode/netflow/nf_report.php @@ -78,13 +78,27 @@ if ($multiple_delete) { __('Not deleted. Error deleting data')); } +/* $filter = array (); $filter['offset'] = (int) get_parameter ('offset'); $filter['limit'] = (int) $config['block_size']; $reports = db_get_all_rows_filter ('tnetflow_report', $filter); +*/ +// Get group list that user has access +$groups_user = users_get_groups ($config['id_user'], "IW", false, true); +html_debug_print($groups_user); + +$groups_id = array(); +foreach($groups_user as $key => $groups){ + $groups_id[] = $groups['id_grupo']; +} +html_debug_print($groups_id); +$sql = "SELECT * FROM tnetflow_report WHERE id_group IN (".implode(',',$groups_id).")"; +html_debug_print($sql); +$reports = db_get_all_rows_sql($sql); if ($reports === false) $reports = array(); diff --git a/pandora_console/godmode/netflow/nf_report_form.php b/pandora_console/godmode/netflow/nf_report_form.php index a94cef947c..e99f5a59bc 100644 --- a/pandora_console/godmode/netflow/nf_report_form.php +++ b/pandora_console/godmode/netflow/nf_report_form.php @@ -38,11 +38,11 @@ if ($id) { $report = netflow_reports_get_reports ($id); $name = $report['id_name']; $description = $report['description']; - $group = $report['group']; + $group = $report['id_group']; } else { $name = ''; - $group = 'none'; + $group = ''; $description = ''; } @@ -50,7 +50,7 @@ if ($update) { $id = get_parameter('id'); $name = (string) get_parameter ('name'); $description = get_parameter ('description'); - $group = get_parameter('group','none'); + $group = get_parameter('id_group'); if ($name == '') { ui_print_error_message (__('Not updated. Blank name')); @@ -58,7 +58,7 @@ if ($update) { $result = db_process_sql_update ('tnetflow_report', array ( 'id_name' => $name, - 'group' => $group, + 'id_group' => $group, 'description' => $description, ), array ('id_report' => $id)); @@ -67,7 +67,7 @@ if ($update) { if ($create){ $name = (string) get_parameter ('name'); - $group = (int) get_parameter ('group'); + $group = (int) get_parameter ('id_group'); $description = get_parameter('description',''); if($name == db_get_value('id_name', 'tnetflow_report', 'id_name', $name)){ @@ -75,7 +75,7 @@ if ($create){ } else { $values = array ( 'id_name' => $name, - 'group' => $group, + 'id_group' => $group, 'description' => $description, ); $result = db_process_sql_insert('tnetflow_report', $values); @@ -124,7 +124,7 @@ $table->data[0][1] = html_print_input_text ('name', $name, false, 30, 80, true); $own_info = get_user_info ($config['id_user']); $table->data[1][0] = ''.__('Group').''; $table->data[1][1] = html_print_select_groups($config['id_user'], "IW", - $own_info['is_admin'], 'group', $group, '', __('None'), -1, true, + $own_info['is_admin'], 'id_group', $group, '','', -1, true, false, false); $table->data[2][0] = ''.__('Description').''; diff --git a/pandora_console/godmode/netflow/nf_report_item.php b/pandora_console/godmode/netflow/nf_report_item.php index 5da1a43cd6..614c24957e 100644 --- a/pandora_console/godmode/netflow/nf_report_item.php +++ b/pandora_console/godmode/netflow/nf_report_item.php @@ -59,8 +59,8 @@ if ($id_rc) { } if ($update) { - $name_filter = get_parameter('id_filter'); - $id_filter = db_get_value('id_sg', 'tnetflow_filter', 'id_name', $name_filter); + $id_filter = get_parameter('id_filter'); + $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter); $max_val = get_parameter('max','2'); $show_graph = get_parameter('show_graph',''); @@ -79,8 +79,9 @@ if ($update) { } if ($create){ - $name_filter = get_parameter('id_filter'); - $id_filter = db_get_value('id_sg', 'tnetflow_filter', 'id_name', $name_filter); + + $id_filter = get_parameter('id_filter'); + $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter); $max_val = get_parameter('max','2'); $show_graph = get_parameter('show_graph',''); @@ -111,8 +112,16 @@ $filters = netflow_get_filters (); if ($filters === false) { $filters = array (); } +html_debug_print($filters); +// Get group list that user has access +$groups_user = users_get_groups ($config['id_user'], "IW", false, true); +$groups_id = array(); +foreach($groups_user as $key => $groups){ + $groups_id[] = $groups['id_grupo']; +} +$sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',',$groups_id).")"; $table->data[0][0] = ''.__('Filters').''; -$table->data[0][1] = html_print_select($filters, 'id_filter', $name_filter, '', '', 0, true); +$table->data[0][1] = html_print_select_from_sql($sql, 'id_filter', $name_filter, '', '', 0, true); $table->data[1][0] = ''.__('Max values aggregated').''; $max_values = array ('2' => '2', diff --git a/pandora_console/operation/netflow/nf_reporting.php b/pandora_console/operation/netflow/nf_reporting.php index 389af6be1a..b1989f0e32 100644 --- a/pandora_console/operation/netflow/nf_reporting.php +++ b/pandora_console/operation/netflow/nf_reporting.php @@ -23,7 +23,7 @@ include_once("include/functions_html.php"); check_login (); -if (! check_acl ($config["id_user"], 0, "IR")) { +if (! check_acl ($config["id_user"], 0, "AR")) { db_pandora_audit("ACL Violation", "Trying to access event viewer"); require ("general/noaccess.php"); @@ -33,12 +33,24 @@ if (! check_acl ($config["id_user"], 0, "IR")) { //Header ui_print_page_header (__('Netflow Reporting'), "images/networkmap/so_cisco_new.png", false, "", false); +/* $filter = array (); $filter['offset'] = (int) get_parameter ('offset'); $filter['limit'] = (int) $config['block_size']; +*/ + +// Get group list that user has access +$groups_user = users_get_groups ($config['id_user'], "AR", false, true); + +$groups_id = array(); +foreach($groups_user as $key => $groups){ + $groups_id[] = $groups['id_grupo']; +} +//$sql = "SELECT * FROM tnetflow_report WHERE 'group' IN (\"".implode('","',$groups_id)."\")"; +$sql = "SELECT * FROM tnetflow_report WHERE id_group IN (".implode(',',$groups_id).")"; +$reports = db_get_all_rows_sql($sql); -$reports = db_get_all_rows_filter ('tnetflow_report', $filter); if ($reports == false){ $reports = array(); } diff --git a/pandora_console/operation/netflow/nf_view.php b/pandora_console/operation/netflow/nf_view.php index a62e43dbf1..1313f3bfe1 100644 --- a/pandora_console/operation/netflow/nf_view.php +++ b/pandora_console/operation/netflow/nf_view.php @@ -279,7 +279,7 @@ if ($id!=''){ $sql = "SELECT * FROM tnetflow_filter WHERE id_sg = '".$id_filter."'"; $result = db_get_row_sql($sql,false,true); - $assign_group = $result['group']; + $assign_group = $result['id_group']; $ip_dst = $result['ip_dst']; $ip_src = $result['ip_src']; $dst_port = $result['dst_port']; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 51086b4958..b4a96d65b5 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1287,7 +1287,7 @@ CREATE TABLE IF NOT EXISTS `ttag_event` ( CREATE TABLE IF NOT EXISTS `tnetflow_filter` ( `id_sg` int(10) unsigned NOT NULL auto_increment, `id_name` varchar(60) NOT NULL default '0', - `group` varchar(60), + `id_group` int(10), `ip_dst` varchar(100), `ip_src` varchar(100), `dst_port` varchar(100), @@ -1305,7 +1305,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report` ( `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `id_name` varchar(150) NOT NULL default '', `description` TEXT NOT NULL, - `group` varchar(60), + `id_group` int(10), PRIMARY KEY(`id_report`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;