~ubuntu-branches/ubuntu/saucy/fail2ban/saucy

« back to all changes in this revision

Viewing changes to server/datetemplate.py

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-05-13 11:58:56 UTC
  • mfrom: (1.1.15) (10.2.13 sid)
  • Revision ID: package-import@ubuntu.com-20130513115856-x7six9p53qcie0vl
Tags: 0.8.9-1
* New upstream release
  - significant improvements in documentation (Closes: #400416)
  - roundcube auth filter (Closes: #699442)
  - enforces C locale for dates (Closes: #686341)
  - provides bash_completion.d/fail2ban
* debian/jail.conf:
  - added findtime and documentation on those basic options from jail.conf
    (Closes: #704568)
  - added new sample jails definitions for ssh-route, ssh-iptables-ipset{4,6},
    roundcube-auth, sogo-auth, mysqld-auth
* debian/control:
  - suggest system-log-daemon (Closes: #691001)
  - boost policy compliance to 3.9.4
* debian/rules:
  - run fail2ban's unittests at build time but ignore the failures
    (there are still some known issues to fix up to guarantee robust testing
    in clean chroots etc).
    Only pyinotify was added to build-depends since gamin might still be
    buggy on older releases and get stuck, which would complicate
    backporting

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
# Author: Cyril Jaquier
21
21
22
 
# $Revision$
23
22
 
24
23
__author__ = "Cyril Jaquier"
25
 
__version__ = "$Revision$"
26
 
__date__ = "$Date$"
27
24
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
28
25
__license__ = "GPL"
29
26
 
50
47
        def getName(self):
51
48
                return self.__name
52
49
        
53
 
        def setRegex(self, regex):
54
 
                self.__regex = regex.strip()
 
50
        def setRegex(self, regex, wordBegin=True):
 
51
                regex = regex.strip()
 
52
                if (wordBegin and not re.search(r'^\^', regex)):
 
53
                        regex = r'\b' + regex
 
54
                self.__regex = regex
55
55
                self.__cRegex = re.compile(regex)
56
56
                
57
57
        def getRegex(self):
62
62
        
63
63
        def matchDate(self, line):
64
64
                dateMatch = self.__cRegex.search(line)
65
 
                if not dateMatch == None:
 
65
                if not dateMatch is None:
66
66
                        self.__hits += 1
67
67
                return dateMatch
68
68
        
158
158
                                                        "pattern" % (opattern, e))
159
159
                        if date[0] < 2000:
160
160
                                # There is probably no year field in the logs
 
161
                                # NOTE: Possibly makes week/year day incorrect
161
162
                                date[0] = MyTime.gmtime()[0]
162
163
                                # Bug fix for #1241756
163
164
                                # If the date is greater than the current time, we suppose
166
167
                                        logSys.debug(
167
168
                                                u"Correcting deduced year from %d to %d since %f > %f" %
168
169
                                                (date[0], date[0]-1, time.mktime(date), MyTime.time()))
 
170
                                        # NOTE: Possibly makes week/year day incorrect
169
171
                                        date[0] -= 1
170
172
                                elif date[1] == 1 and date[2] == 1:
171
173
                                        # If it is Jan 1st, it is either really Jan 1st or there
172
174
                                        # is neither month nor day in the log.
 
175
                                        # NOTE: Possibly makes week/year day incorrect
173
176
                                        date[1] = MyTime.gmtime()[1]
174
177
                                        date[2] = MyTime.gmtime()[2]
175
178
                return date
180
183
        def __init__(self):
181
184
                DateTemplate.__init__(self)
182
185
                # We already know the format for TAI64N
183
 
                self.setRegex("@[0-9a-f]{24}")
 
186
                # yoh: we should not add an additional front anchor
 
187
                self.setRegex("@[0-9a-f]{24}", wordBegin=False)
184
188
        
185
189
        def getDate(self, line):
186
190
                date = None
211
215
                        value = dateMatch.group()
212
216
                        date = list(iso8601.parse_date(value).timetuple())
213
217
                return date
 
218