mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
- 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
This commit is contained in:
parent
d4c122a5aa
commit
5dba68b2cb
3 changed files with 11 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
@ -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":
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue