mirror of https://github.com/fail2ban/fail2ban
ENH: Warn when multiline regex used when maxlines not greater than 1
parent
fceac53776
commit
df3e4a2742
|
@ -61,7 +61,9 @@ class FilterReader(DefinitionInitConfigReader):
|
||||||
stream.append(["set", self._jailName, "addignoreregex", regex])
|
stream.append(["set", self._jailName, "addignoreregex", regex])
|
||||||
if self._initOpts:
|
if self._initOpts:
|
||||||
if 'maxlines' in self._initOpts:
|
if 'maxlines' in self._initOpts:
|
||||||
stream.append(["set", self._jailName, "maxlines", self._initOpts["maxlines"]])
|
# We warn when multiline regex is used without maxlines > 1
|
||||||
|
# therefore keep sure we set this option first.
|
||||||
|
stream.insert(0, ["set", self._jailName, "maxlines", self._initOpts["maxlines"]])
|
||||||
if 'datepattern' in self._initOpts:
|
if 'datepattern' in self._initOpts:
|
||||||
stream.append(["set", self._jailName, "datepattern", self._initOpts["datepattern"]])
|
stream.append(["set", self._jailName, "datepattern", self._initOpts["datepattern"]])
|
||||||
# Do not send a command if the match is empty.
|
# Do not send a command if the match is empty.
|
||||||
|
|
|
@ -95,6 +95,10 @@ class Filter(JailThread):
|
||||||
try:
|
try:
|
||||||
regex = FailRegex(value)
|
regex = FailRegex(value)
|
||||||
self.__failRegex.append(regex)
|
self.__failRegex.append(regex)
|
||||||
|
if "\n" in regex.getRegex() and not self.getMaxLines() > 1:
|
||||||
|
logSys.warning(
|
||||||
|
"Mutliline regex set for jail '%s' "
|
||||||
|
"but maxlines not greater than 1")
|
||||||
except RegexException, e:
|
except RegexException, e:
|
||||||
logSys.error(e)
|
logSys.error(e)
|
||||||
raise e
|
raise e
|
||||||
|
|
Loading…
Reference in New Issue