mirror of https://github.com/fail2ban/fail2ban
Merge branch 'master' into 0.9 (propagating \r\n fix)
* master: Previous coverage was 56% (without disregarding any pragma) Changelog for preceeding commit ENH: strip CR and LF while analyzing the lines (processLine) (Close #202) Conflicts: fail2ban/server/filter.pypull/218/head
commit
f5dfa610e6
|
@ -46,7 +46,7 @@ ver. 0.8.9 (2013/05/XX) - wanna-be-stable
|
||||||
|
|
||||||
Originally targeted as a bugfix release, it incorporated many new
|
Originally targeted as a bugfix release, it incorporated many new
|
||||||
enhancements, few new features, and more importantly -- quite extended
|
enhancements, few new features, and more importantly -- quite extended
|
||||||
tests battery with current 94% coverage.
|
tests battery with current 94% coverage (from 56% of 0.8.8).
|
||||||
|
|
||||||
This release introduces over 200 of non-merge commits from 16
|
This release introduces over 200 of non-merge commits from 16
|
||||||
contributors (sorted by number of commits): Yaroslav Halchenko, Daniel
|
contributors (sorted by number of commits): Yaroslav Halchenko, Daniel
|
||||||
|
@ -137,6 +137,7 @@ fail2ban-users mailing list and IRC.
|
||||||
* [40c5a2d] adding more of diagnostic messages into -client while starting
|
* [40c5a2d] adding more of diagnostic messages into -client while starting
|
||||||
the daemon.
|
the daemon.
|
||||||
* [8e63d4c] Compare against None with 'is' instead of '=='.
|
* [8e63d4c] Compare against None with 'is' instead of '=='.
|
||||||
|
* [6fef85f] Strip CR and LF while analyzing the log line
|
||||||
Daniel Black
|
Daniel Black
|
||||||
* [3aeb1a9] Add jail.conf manual page. Closes gh-143.
|
* [3aeb1a9] Add jail.conf manual page. Closes gh-143.
|
||||||
* [MANY] man page edits.
|
* [MANY] man page edits.
|
||||||
|
|
|
@ -310,6 +310,7 @@ class Filter(JailThread):
|
||||||
def processLine(self, line):
|
def processLine(self, line):
|
||||||
"""Split the time portion from log msg and return findFailures on them
|
"""Split the time portion from log msg and return findFailures on them
|
||||||
"""
|
"""
|
||||||
|
line = line.rstrip('\r\n')
|
||||||
timeMatch = self.dateDetector.matchTime(line)
|
timeMatch = self.dateDetector.matchTime(line)
|
||||||
if timeMatch:
|
if timeMatch:
|
||||||
# Lets split into time part and log part of the line
|
# Lets split into time part and log part of the line
|
||||||
|
|
|
@ -603,11 +603,29 @@ class GetFailures(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def testGetFailures01(self):
|
def testGetFailures01(self, filename=None, failures=None):
|
||||||
self.filter.addLogPath(GetFailures.FILENAME_01)
|
filename = filename or GetFailures.FILENAME_01
|
||||||
self.filter.addFailRegex("(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>")
|
failures = failures or GetFailures.FAILURES_01
|
||||||
self.filter.getFailures(GetFailures.FILENAME_01)
|
|
||||||
_assert_correct_last_attempt(self, self.filter, GetFailures.FAILURES_01)
|
self.filter.addLogPath(filename)
|
||||||
|
self.filter.addFailRegex("(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>$")
|
||||||
|
self.filter.getFailures(filename)
|
||||||
|
_assert_correct_last_attempt(self, self.filter, failures)
|
||||||
|
|
||||||
|
def testCRLFFailures01(self):
|
||||||
|
# We first adjust logfile/failures to end with CR+LF
|
||||||
|
fname = tempfile.mktemp(prefix='tmp_fail2ban', suffix='crlf')
|
||||||
|
f = open(fname, 'w')
|
||||||
|
for l in open(GetFailures.FILENAME_01).readlines():
|
||||||
|
f.write('%s\r\n' % l.rstrip('\n'))
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
# now see if we should be getting the "same" failures
|
||||||
|
self.testGetFailures01(filename=fname,
|
||||||
|
failures=GetFailures.FAILURES_01[:3] +
|
||||||
|
([x.rstrip('\n') + '\r\n' for x in
|
||||||
|
GetFailures.FAILURES_01[-1]],))
|
||||||
|
_killfile(f, fname)
|
||||||
|
|
||||||
|
|
||||||
def testGetFailures02(self):
|
def testGetFailures02(self):
|
||||||
|
|
Loading…
Reference in New Issue