From 2e9362c5ab08a858759cd65f01409248ea602639 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 11 Nov 2011 13:42:40 +0000 Subject: Use basename to be sure that no full path is used on the files themselves --- config/snort/snort.inc | 2 +- config/snort/snort_rules.php | 2 +- config/snort/snort_rulesets.php | 14 ++++---------- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'config/snort') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index e0f90582..72be9191 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -354,7 +354,7 @@ function snort_file_list($snort_log_dir, $snort_log_file) $dir = opendir ("$snort_log_dir"); while (false !== ($file = readdir($dir))) { if (strpos($file, "$snort_log_file",1) ) - $file_list[] = $file; + $file_list[] = basename($file); } return $file_list; } diff --git a/config/snort/snort_rules.php b/config/snort/snort_rules.php index 2aa49865..871eb39e 100644 --- a/config/snort/snort_rules.php +++ b/config/snort/snort_rules.php @@ -157,7 +157,7 @@ while (false !== ($filename = readdir($dh))) //only populate this array if its a rule file $isrulefile = strstr($filename, ".rules"); if ($isrulefile !== false) - $files[] = $filename; + $files[] = basename($filename); } sort($files); diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php index 9e3853f5..e4577818 100644 --- a/config/snort/snort_rulesets.php +++ b/config/snort/snort_rulesets.php @@ -136,16 +136,10 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$iface_uuid}_{$if_real}.dirty"; if ($_POST["Submit"]) { $enabled_items = ""; $isfirst = true; - if (is_array($_POST['toenable'])) { - foreach($_POST['toenable'] as $toenable) { - if(!$isfirst) - $enabled_items .= "||"; - $enabled_items .= "{$toenable}"; - $isfirst = false; - } - }else{ + if (is_array($_POST['toenable'])) + $enabled_items = implode("||", $_POST['toenable']); + else $enabled_items = $_POST['toenable']; - } $a_nat[$id]['rulesets'] = $enabled_items; write_config(); @@ -256,7 +250,7 @@ if (file_exists($d_snortconfdirty_path)) { $dir = "/usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { - $files[] = $filename; + $files[] = basename($filename); } sort($files); foreach($files as $file) { -- cgit v1.2.3