From: <los...@us...> - 2006-12-23 23:20:17
|
Revision: 505 http://svn.sourceforge.net/fail2ban/?rev=505&view=rev Author: lostcontrol Date: 2006-12-23 15:20:16 -0800 (Sat, 23 Dec 2006) Log Message: ----------- - Do not accept empty regular expression - Do not send an empty string if the option is not defined Modified Paths: -------------- trunk/client/filterreader.py trunk/client/jailreader.py trunk/server/regex.py Modified: trunk/client/filterreader.py =================================================================== --- trunk/client/filterreader.py 2006-12-23 16:37:17 UTC (rev 504) +++ trunk/client/filterreader.py 2006-12-23 23:20:16 UTC (rev 505) @@ -68,9 +68,13 @@ stream.append(["set", self.__name, "timepattern", self.__opts[opt]]) elif opt == "failregex": for regex in self.__opts[opt].split('\n'): - stream.append(["set", self.__name, "addfailregex", regex]) + # Do not send a command if the rule is empty. + if regex != '': + stream.append(["set", self.__name, "addfailregex", regex]) elif opt == "ignoreregex": for regex in self.__opts[opt].split('\n'): - stream.append(["set", self.__name, "addignoreregex", regex]) + # Do not send a command if the rule is empty. + if regex != '': + stream.append(["set", self.__name, "addignoreregex", regex]) return stream \ No newline at end of file Modified: trunk/client/jailreader.py =================================================================== --- trunk/client/jailreader.py 2006-12-23 16:37:17 UTC (rev 504) +++ trunk/client/jailreader.py 2006-12-23 23:20:16 UTC (rev 505) @@ -112,7 +112,9 @@ stream.append(["set", self.__name, "maxretry", self.__opts[opt]]) elif opt == "ignoreip": for ip in self.__opts[opt].split(): - stream.append(["set", self.__name, "addignoreip", ip]) + # Do not send a command if the rule is empty. + if ip != '': + stream.append(["set", self.__name, "addignoreip", ip]) elif opt == "findtime": stream.append(["set", self.__name, "findtime", self.__opts[opt]]) elif opt == "bantime": Modified: trunk/server/regex.py =================================================================== --- trunk/server/regex.py 2006-12-23 16:37:17 UTC (rev 504) +++ trunk/server/regex.py 2006-12-23 23:20:16 UTC (rev 505) @@ -42,6 +42,8 @@ def __init__(self, regex): self._matchCache = None + if regex.lstrip() == '': + raise RegexException("Cannot add empty regex") try: self._regexObj = re.compile(regex) self._regex = regex This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |