- Do not accept empty regular expression

- Do not send an empty string if the option is not defined

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@505 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-12-23 23:20:16 +00:00
parent cd012dda85
commit b8f0ce7155
3 changed files with 11 additions and 3 deletions

View File

@ -68,9 +68,13 @@ class FilterReader(ConfigReader):
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

View File

@ -112,7 +112,9 @@ class JailReader(ConfigReader):
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":

View File

@ -42,6 +42,8 @@ class Regex:
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