From 2880603c90835020a76270d958b5d4a624a1bd78 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 2 Aug 2011 22:27:53 +0000 Subject: Copy rules/categories if they exists. No need to send user to do updates uselessly. --- config/snort/snort_rules.php | 10 ++-- config/snort/snort_rulesets.php | 121 +++++++++++++++++++++------------------- 2 files changed, 68 insertions(+), 63 deletions(-) (limited to 'config') diff --git a/config/snort/snort_rules.php b/config/snort/snort_rules.php index f4e1dbbd..13ad9f63 100644 --- a/config/snort/snort_rules.php +++ b/config/snort/snort_rules.php @@ -62,8 +62,8 @@ if (!is_dir("/usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules")) $isrulesfolderempty = exec("ls -A /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/*.rules"); if ($isrulesfolderempty == "") { - //$isrulesfolderempty = exec("ls -A /usr/local/etc/snort/rules/*.rules"); - //if ($isrulesfolderempty == "") { + $isrulesfolderempty = exec("ls -A /usr/local/etc/snort/rules/*.rules"); + if ($isrulesfolderempty == "") { include_once("head.inc"); include_once("fbegin.inc"); @@ -119,10 +119,10 @@ if ($isrulesfolderempty == "") { echo ""; exit(0); - //} else { + } else { /* Make sure that we have the rules */ - // mwexec("/bin/cp /usr/local/etc/snort/rules/*.rules /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules", true); - //} + mwexec("/bin/cp /usr/local/etc/snort/rules/*.rules /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules", true); + } } function get_middle($source, $beginning, $ending, $init_pos) { diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php index cbd64845..264603a5 100644 --- a/config/snort/snort_rulesets.php +++ b/config/snort/snort_rulesets.php @@ -68,64 +68,69 @@ $pgtitle = "Snort: Interface $id $iface_uuid $if_real Categories"; /* TODO give the user the option to delete the installed rules rules */ $isrulesfolderempty = exec("ls -A /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/*.rules"); if ($isrulesfolderempty == "") { - - include_once("head.inc"); - include("fbegin.inc"); - - echo "

"; - if($pfsense_stable == 'yes'){echo $pgtitle;} - echo "

\n"; - - echo ""; - - echo " -\n - - \n - \n - \n -
\n"; - - $tab_array = array(); - $tabid = 0; - $tab_array[$tabid] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php"); - $tabid++; - $tab_array[$tabid] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}"); - $tabid++; - $tab_array[$tabid] = array(gettext("Categories"), true, "/snort/snort_rulesets.php?id={$id}"); - $tabid++; - $tab_array[$tabid] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}"); - $tabid++; - $tab_array[$tabid] = array(gettext("Servers"), false, "/snort/snort_define_servers.php?id={$id}"); - $tabid++; - $tab_array[$tabid] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}"); - $tabid++; - $tab_array[$tabid] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}"); - display_top_tabs($tab_array); -echo " -
\n -
\n - \n - \n - \n - \n -
\n -# The rules directory is empty. /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules \n -
\n -
\n -
\n -\n -\n -\n -

\n\n"; - - echo "Please click on the Update Rules tab to install your selected rule sets. $isrulesfolderempty"; - include("fend.inc"); - - echo ""; - echo ""; - - exit(0); + $isrulesfolderempty = exec("ls -A /usr/local/etc/snort/rules/*.rules"); + if ($isrulesfolderempty == "") { + include_once("head.inc"); + include("fbegin.inc"); + + echo "

"; + if($pfsense_stable == 'yes'){echo $pgtitle;} + echo "

\n"; + + echo ""; + + echo " + \n + + \n + \n + \n +
\n"; + + $tab_array = array(); + $tabid = 0; + $tab_array[$tabid] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php"); + $tabid++; + $tab_array[$tabid] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}"); + $tabid++; + $tab_array[$tabid] = array(gettext("Categories"), true, "/snort/snort_rulesets.php?id={$id}"); + $tabid++; + $tab_array[$tabid] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}"); + $tabid++; + $tab_array[$tabid] = array(gettext("Servers"), false, "/snort/snort_define_servers.php?id={$id}"); + $tabid++; + $tab_array[$tabid] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}"); + $tabid++; + $tab_array[$tabid] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}"); + display_top_tabs($tab_array); + echo " +
\n +
\n + \n + \n + \n + \n +
\n + # The rules directory is empty. /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules \n +
\n +
\n +
\n + \n + \n + \n +

\n\n"; + + echo "Please click on the Update Rules tab to install your selected rule sets. $isrulesfolderempty"; + include("fend.inc"); + + echo ""; + echo ""; + + exit(0); + } else { + /* Make sure that we have the rules */ + mwexec("/bin/cp /usr/local/etc/snort/rules/*.rules /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules", true); + } } /* alert file */ -- cgit v1.2.3