mirror of https://github.com/fail2ban/fail2ban
fail2ban-testcases: added option "--ignore": negate [regexps] filter, to ignore tests matched specified regexps
parent
8eca2ecd84
commit
134c33cc6d
|
@ -67,6 +67,9 @@ def get_opt_parser():
|
||||||
Option('-f', "--fast", action="store_true",
|
Option('-f', "--fast", action="store_true",
|
||||||
dest="fast",
|
dest="fast",
|
||||||
help="Try to increase speed of the tests, decreasing of wait intervals, memory database"),
|
help="Try to increase speed of the tests, decreasing of wait intervals, memory database"),
|
||||||
|
Option('-i', "--ignore", action="store_true",
|
||||||
|
dest="negate_re",
|
||||||
|
help="negate [regexps] filter to ignore tests matched specified regexps"),
|
||||||
Option("-t", "--log-traceback", action='store_true',
|
Option("-t", "--log-traceback", action='store_true',
|
||||||
help="Enrich log-messages with compressed tracebacks"),
|
help="Enrich log-messages with compressed tracebacks"),
|
||||||
Option("--full-traceback", action='store_true',
|
Option("--full-traceback", action='store_true',
|
||||||
|
|
|
@ -55,6 +55,7 @@ class F2B(optparse.Values):
|
||||||
def __init__(self, opts={}):
|
def __init__(self, opts={}):
|
||||||
self.__dict__ = opts.__dict__ if opts else {
|
self.__dict__ = opts.__dict__ if opts else {
|
||||||
'fast': False, 'memory_db':False, 'no_gamin': False, 'no_network': False,
|
'fast': False, 'memory_db':False, 'no_gamin': False, 'no_network': False,
|
||||||
|
"negate_re": False,
|
||||||
}
|
}
|
||||||
if self.fast:
|
if self.fast:
|
||||||
self.memory_db = True
|
self.memory_db = True
|
||||||
|
@ -157,7 +158,8 @@ def gatherTests(regexps=None, opts=None):
|
||||||
for test in suite:
|
for test in suite:
|
||||||
s = str(test)
|
s = str(test)
|
||||||
for r in self._regexps:
|
for r in self._regexps:
|
||||||
if r.search(s):
|
m = r.search(s)
|
||||||
|
if (m if not opts.negate_re else not m):
|
||||||
matched.append(test)
|
matched.append(test)
|
||||||
break
|
break
|
||||||
for test in matched:
|
for test in matched:
|
||||||
|
|
Loading…
Reference in New Issue