Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Commit

Permalink
Fix longstanding bug with enable/disable SID code
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeeks8 committed Apr 11, 2013
1 parent 231e4a6 commit f98ad28
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions config/snort/snort.inc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1457,9 +1457,17 @@ function snort_load_sid_mods($sids, $value) {
/* This function parses the string of */ /* This function parses the string of */
/* SID values in $sids and returns an */ /* SID values in $sids and returns an */
/* array with the SID as the key and */ /* array with the SID as the key and */
/* passed $value as the value. The SID */ /* value. The SID values in $sids are */
/* values in $sids are assumed to be */ /* assumed to be delimited by "||". */
/* delimited by "||". */ /* */
/* $sids ==> string of SID values from */
/* saved config file. */
/* */
/* $value ==> type of mod (enable or */
/* disable). Not currently */
/* utilized, but maintained */
/* so as not to break legacy */
/* code elsewhere. */
/*****************************************/ /*****************************************/


$result = array(); $result = array();
Expand All @@ -1468,7 +1476,7 @@ function snort_load_sid_mods($sids, $value) {
$tmp = explode("||", $sids); $tmp = explode("||", $sids);
foreach ($tmp as $v) { foreach ($tmp as $v) {
if (preg_match('/\s\d+/', $v, $match)) if (preg_match('/\s\d+/', $v, $match))
$result[trim($match[0])] = $value; $result[trim($match[0])] = trim($match[0]);
} }
unset($tmp); unset($tmp);


Expand Down Expand Up @@ -1513,14 +1521,13 @@ function snort_modify_sids(&$rule_map, $snortcfg) {
if (!empty($disablesid)) { if (!empty($disablesid)) {
foreach ($rule_map as $k1 => $rulem) { foreach ($rule_map as $k1 => $rulem) {
foreach ($rulem as $k2 => $v) { foreach ($rulem as $k2 => $v) {
if (in_array($k2, $disablesid) && $v['disabled'] == 0) { if (in_array($k2, $disablesid) && $v['disabled'] == 0) {
$rule_map[$k1][$k2]['rule'] = "# " . $v['rule']; $rule_map[$k1][$k2]['rule'] = "# " . $v['rule'];
$rule_map[$k1][$k2]['disabled'] = 1; $rule_map[$k1][$k2]['disabled'] = 1;
} }
} }
} }
} }

unset($enablesid, $disablesid); unset($enablesid, $disablesid);
} }


Expand Down

0 comments on commit f98ad28

Please sign in to comment.