From c6bd8fc80749417238280c84310f39fc1c4d103b Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Tue, 16 Apr 2013 21:09:53 +0100 Subject: [PATCH] ENH+TST: Add Apache Tomcat date format --- fail2ban/server/datedetector.py | 6 ++++++ fail2ban/tests/datedetectortestcase.py | 1 + 2 files changed, 7 insertions(+) diff --git a/fail2ban/server/datedetector.py b/fail2ban/server/datedetector.py index f58ab4e0..88f0f228 100644 --- a/fail2ban/server/datedetector.py +++ b/fail2ban/server/datedetector.py @@ -161,6 +161,12 @@ class DateDetector: template.setRegex("^\d{2}\d{2}\d{2} +\d{1,2}:\d{2}:\d{2}") template.setPattern("%y%m%d %H:%M:%S") self._appendTemplate(template) + # Apache Tomcat + template = DateStrptime() + template.setName("MONTH Day, Year 12hour:Minute:Second AM/PM") + template.setRegex("\S{3}\s{1,2}\d{1,2}, \d{4} \d{1,2}:\d{2}:\d{2} [AP]M") + template.setPattern("%b %d, %Y %I:%M:%S %p") + self._appendTemplate(template) finally: self.__lock.release() diff --git a/fail2ban/tests/datedetectortestcase.py b/fail2ban/tests/datedetectortestcase.py index e30027e1..23f7a174 100644 --- a/fail2ban/tests/datedetectortestcase.py +++ b/fail2ban/tests/datedetectortestcase.py @@ -86,6 +86,7 @@ class DateDetectorTest(unittest.TestCase): "2005-01-23T21:59:59-05:00Z", #ISO 8601 with TZ "<01/23/05@21:59:59>", "050123 21:59:59", # MySQL + "Jan 23, 2005 9:59:59 PM", # Apache Tomcat ): log = sdate + "[sshd] error: PAM: Authentication failure" # exclude