mirror of https://github.com/fail2ban/fail2ban
TST+BF: Fix bug in Filter.{get,set}DatePattern and improve tests
parent
9c61adcad7
commit
011ccbc675
|
@ -205,7 +205,7 @@ class Filter(JailThread):
|
||||||
elif pattern.upper() == "EPOCH":
|
elif pattern.upper() == "EPOCH":
|
||||||
template = DateEpoch()
|
template = DateEpoch()
|
||||||
template.setName("Epoch")
|
template.setName("Epoch")
|
||||||
elif patter.upper() == "TAI64N":
|
elif pattern.upper() == "TAI64N":
|
||||||
template = DateTai64n()
|
template = DateTai64n()
|
||||||
template.setName("TAI64N")
|
template.setName("TAI64N")
|
||||||
else:
|
else:
|
||||||
|
@ -233,10 +233,10 @@ class Filter(JailThread):
|
||||||
elif len(templates) == 1:
|
elif len(templates) == 1:
|
||||||
if hasattr(templates[0], "getPattern"):
|
if hasattr(templates[0], "getPattern"):
|
||||||
pattern = templates[0].getPattern()
|
pattern = templates[0].getPattern()
|
||||||
|
if templates[0].getRegex()[0] == "^":
|
||||||
|
pattern = "^" + pattern
|
||||||
else:
|
else:
|
||||||
pattern = None
|
pattern = None
|
||||||
if templates[0].getRegex()[0] == "^":
|
|
||||||
pattern = "^" + pattern
|
|
||||||
return pattern, templates[0].getName()
|
return pattern, templates[0].getName()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -239,6 +239,12 @@ class Transmitter(TransmitterBase):
|
||||||
self.setGetTest("datepattern", "%%%Y%m%d%H%M%S",
|
self.setGetTest("datepattern", "%%%Y%m%d%H%M%S",
|
||||||
("%%%Y%m%d%H%M%S", "%YearMonthDay24hourMinuteSecond"),
|
("%%%Y%m%d%H%M%S", "%YearMonthDay24hourMinuteSecond"),
|
||||||
jail=self.jailName)
|
jail=self.jailName)
|
||||||
|
self.setGetTest(
|
||||||
|
"datepattern", "Epoch", (None, "Epoch"), jail=self.jailName)
|
||||||
|
self.setGetTest(
|
||||||
|
"datepattern", "TAI64N", (None, "TAI64N"), jail=self.jailName)
|
||||||
|
self.setGetTest(
|
||||||
|
"datepattern", "ISO8601", (None, "ISO8601"), jail=self.jailName)
|
||||||
self.setGetTestNOK("datepattern", "%Cat%a%%%g", jail=self.jailName)
|
self.setGetTestNOK("datepattern", "%Cat%a%%%g", jail=self.jailName)
|
||||||
|
|
||||||
def testJailUseDNS(self):
|
def testJailUseDNS(self):
|
||||||
|
|
Loading…
Reference in New Issue