From d25293151743c44ffef9121d10c0568f04066054 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 10 Jul 2012 07:20:09 +0000 Subject: Some validation and whitespace fixes --- config/snort/snort_interfaces_suppress.php | 11 +- config/snort/snort_interfaces_suppress_edit.php | 23 ++-- config/snort/snort_interfaces_whitelist.php | 149 +++++++++++------------ config/snort/snort_interfaces_whitelist_edit.php | 33 ++--- 4 files changed, 92 insertions(+), 124 deletions(-) (limited to 'config/snort') diff --git a/config/snort/snort_interfaces_suppress.php b/config/snort/snort_interfaces_suppress.php index eb66b652..d4fe44ac 100644 --- a/config/snort/snort_interfaces_suppress.php +++ b/config/snort/snort_interfaces_suppress.php @@ -45,8 +45,6 @@ if (!is_array($config['installedpackages']['snortglobal']['suppress']['item'])) $a_suppress = &$config['installedpackages']['snortglobal']['suppress']['item']; $id_gen = count($config['installedpackages']['snortglobal']['suppress']['item']); -$d_suppresslistdirty_path = '/var/run/snort_suppress.dirty'; - if ($_GET['act'] == "del") { if ($a_suppress[$_GET['id']]) { /* make sure rule is not being referenced by any nat or filter rules */ @@ -68,15 +66,10 @@ include_once("head.inc"); ' . $pgtitle . '

';} ?> -' . $pgtitle . '

';}?> -
- -

You must apply the changes in order for them to take effect.");?> - -
- +
diff --git a/config/snort/snort_interfaces_suppress_edit.php b/config/snort/snort_interfaces_suppress_edit.php index 082911b0..6118c33a 100644 --- a/config/snort/snort_interfaces_suppress_edit.php +++ b/config/snort/snort_interfaces_suppress_edit.php @@ -88,6 +88,8 @@ if ($_POST['submit']) { unset($input_errors); $pconfig = $_POST; + $reqdfields = explode(" ", "name"); + $reqdfieldsn = array("Name"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if(strtolower($_POST['name']) == "defaultwhitelist") @@ -129,11 +131,9 @@ if ($_POST['submit']) { write_config(); sync_snort_package_config(); - header("Location: /snort/snort_interfaces_suppress.php"); exit; } - } $pgtitle = "Services: Snort: Suppression: Edit $suppress_uuid"; @@ -145,15 +145,11 @@ include_once("head.inc"); +if($pfsense_stable == 'yes'){echo '

' . $pgtitle . '

';} -' . $pgtitle . '

';}?> - - - @@ -166,7 +162,7 @@ include("fbegin.inc"); @@ -174,7 +170,7 @@ include("fbegin.inc"); @@ -185,7 +181,7 @@ include("fbegin.inc"); @@ -228,7 +224,6 @@ include("fbegin.inc"); diff --git a/config/snort/snort_interfaces_whitelist.php b/config/snort/snort_interfaces_whitelist.php index 805fffe9..56d6cdc2 100644 --- a/config/snort/snort_interfaces_whitelist.php +++ b/config/snort/snort_interfaces_whitelist.php @@ -39,28 +39,23 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); - +if (!is_array($config['installedpackages']['snortglobal']['whitelist'])) + $config['installedpackages']['snortglobal']['whitelist'] = array(); if (!is_array($config['installedpackages']['snortglobal']['whitelist']['item'])) -$config['installedpackages']['snortglobal']['whitelist']['item'] = array(); - -//aliases_sort(); << what ? + $config['installedpackages']['snortglobal']['whitelist']['item'] = array(); $a_whitelist = &$config['installedpackages']['snortglobal']['whitelist']['item']; -if (isset($config['installedpackages']['snortglobal']['whitelist']['item'])) { +if (isset($config['installedpackages']['snortglobal']['whitelist']['item'])) $id_gen = count($config['installedpackages']['snortglobal']['whitelist']['item']); -}else{ +else $id_gen = '0'; -} - -$d_whitelistdirty_path = '/var/run/snort_whitelist.dirty'; if ($_GET['act'] == "del") { if ($a_whitelist[$_GET['id']]) { /* make sure rule is not being referenced by any nat or filter rules */ - unset($a_whitelist[$_GET['id']]); write_config(); - filter_configure(); + sync_snort_package_config(); header("Location: /snort/snort_interfaces_whitelist.php"); exit; } @@ -68,21 +63,17 @@ if ($_GET['act'] == "del") { $pgtitle = "Services: Snort: Whitelist"; include_once("head.inc"); - ?> ' . $pgtitle . '

';} +if ($savemsg) print_info_box($savemsg); ?> -' . $pgtitle . '

';}?> - - -

You must apply the changes in order for them to take effect.");?> - - +

File Name Description
Name
+ class="formfld unkown" size="40" value="" />
The list name may only consist of the characters a-z, A-Z and 0-9. Note: No Spaces.
Description
+ class="formfld unkown" id="descr" size="40" value="" />
You may enter a description here for your reference (not parsed).
    NOTE: -   The threshold keyword +   The threshold keyword is deprecated as of version 2.8.5. Use the event_filter keyword instead.
- - -
-
- - - - - - - - - - - - - - - - - - - - + + +
File NameValuesDescription
- - -   - - - - - - -
-
- - - - - -
 
+
+ + + + + + + + $list): ?> + + + + + + + + + +
File NameValuesDescription
+ + +   + + + + + + +
+
+ + + + + +
 
diff --git a/config/snort/snort_interfaces_whitelist_edit.php b/config/snort/snort_interfaces_whitelist_edit.php index 965dd4be..60bfea14 100644 --- a/config/snort/snort_interfaces_whitelist_edit.php +++ b/config/snort/snort_interfaces_whitelist_edit.php @@ -39,9 +39,10 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); +if (!is_array($config['installedpackages']['snortglobal']['whitelist'])) + $config['installedpackages']['snortglobal']['whitelist'] = array(); if (!is_array($config['installedpackages']['snortglobal']['whitelist']['item'])) $config['installedpackages']['snortglobal']['whitelist']['item'] = array(); - $a_whitelist = &$config['installedpackages']['snortglobal']['whitelist']['item']; $id = $_GET['id']; @@ -52,33 +53,27 @@ if (is_null($id)) { exit; } -/* gen uuid for each iface !inportant */ -if ($config['installedpackages']['snortglobal']['whitelist']['item'][$id]['uuid'] == '') { +if (empty($config['installedpackages']['snortglobal']['whitelist']['item'][$id]['uuid'])) { $whitelist_uuid = 0; while ($whitelist_uuid > 65535 || $whitelist_uuid == 0) { $whitelist_uuid = mt_rand(1, 65535); $pconfig['uuid'] = $whitelist_uuid; } -} else if ($config['installedpackages']['snortglobal']['whitelist']['item'][$id]['uuid'] != '') { +} else $whitelist_uuid = $config['installedpackages']['snortglobal']['whitelist']['item'][$id]['uuid']; -} - -$d_snort_whitelist_dirty_path = '/var/run/snort_whitelist.dirty'; /* returns true if $name is a valid name for a whitelist file name or ip */ function is_validwhitelistname($name) { if (!is_string($name)) - return false; + return false; if (!preg_match("/[^a-zA-Z0-9\.\/]/", $name)) - return true; + return true; return false; } - if (isset($id) && $a_whitelist[$id]) { - /* old settings */ $pconfig = array(); $pconfig['name'] = $a_whitelist[$id]['name']; @@ -97,7 +92,6 @@ if (isset($id) && $a_whitelist[$id]) { } if ($_POST['submit']) { - conf_mount_rw(); unset($input_errors); @@ -106,7 +100,6 @@ if ($_POST['submit']) { /* input validation */ $reqdfields = explode(" ", "name"); $reqdfieldsn = explode(",", "Name"); - do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if(strtolower($_POST['name']) == "defaultwhitelist") @@ -197,7 +190,6 @@ if ($_POST['submit']) { $pgtitle = "Services: Snort: Whitelist: Edit $whitelist_uuid"; include_once("head.inc"); - ?> @@ -218,17 +210,16 @@ include("fbegin.inc"); rowsize[1] = "30"; -' . $pgtitle . '

';}?> - - - ' . $pgtitle . '

';} +if ($input_errors) print_input_errors($input_errors); +if ($savemsg) + print_info_box($savemsg); ?> + +
Add the name and -- cgit v1.2.3