|
|
|
@ -565,7 +565,7 @@ class FilterReaderTest(LogCaptureTestCase):
|
|
|
|
|
|
|
|
|
|
def testFilterReaderSubstitionDefault(self): |
|
|
|
|
output = [['set', 'jailname', 'addfailregex', 'to=sweet@example.com fromip=<IP>']] |
|
|
|
|
filterReader = FilterReader('substition', "jailname", {}, |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", {}, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
@ -585,7 +585,7 @@ class FilterReaderTest(LogCaptureTestCase):
|
|
|
|
|
|
|
|
|
|
def testFilterReaderSubstitionSet(self): |
|
|
|
|
output = [['set', 'jailname', 'addfailregex', 'to=sour@example.com fromip=<IP>']] |
|
|
|
|
filterReader = FilterReader('substition', "jailname", {'honeypot': 'sour@example.com'}, |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", {'honeypot': 'sour@example.com'}, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
@ -595,8 +595,8 @@ class FilterReaderTest(LogCaptureTestCase):
|
|
|
|
|
def testFilterReaderSubstitionKnown(self): |
|
|
|
|
output = [['set', 'jailname', 'addfailregex', '^to=test,sweet@example.com,test2,sweet@example.com fromip=<IP>$']] |
|
|
|
|
filterName, filterOpt = extractOptions( |
|
|
|
|
'substition[failregex="^<known/failregex>$", honeypot="<sweet>,<known/honeypot>", sweet="test,<known/honeypot>,test2"]') |
|
|
|
|
filterReader = FilterReader('substition', "jailname", filterOpt, |
|
|
|
|
'substitution[failregex="^<known/failregex>$", honeypot="<sweet>,<known/honeypot>", sweet="test,<known/honeypot>,test2"]') |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", filterOpt, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
@ -606,8 +606,8 @@ class FilterReaderTest(LogCaptureTestCase):
|
|
|
|
|
def testFilterReaderSubstitionSection(self): |
|
|
|
|
output = [['set', 'jailname', 'addfailregex', '^\\s*to=fail2ban@localhost fromip=<IP>\\s*$']] |
|
|
|
|
filterName, filterOpt = extractOptions( |
|
|
|
|
'substition[failregex="^\\s*<Definition/failregex>\\s*$", honeypot="<default/honeypot>"]') |
|
|
|
|
filterReader = FilterReader('substition', "jailname", filterOpt, |
|
|
|
|
'substitution[failregex="^\\s*<Definition/failregex>\\s*$", honeypot="<default/honeypot>"]') |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", filterOpt, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
@ -616,13 +616,13 @@ class FilterReaderTest(LogCaptureTestCase):
|
|
|
|
|
|
|
|
|
|
def testFilterReaderSubstitionFail(self): |
|
|
|
|
# directly subst the same var : |
|
|
|
|
filterReader = FilterReader('substition', "jailname", {'honeypot': '<honeypot>'}, |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", {'honeypot': '<honeypot>'}, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
|
self.assertRaises(ValueError, FilterReader.convert, filterReader) |
|
|
|
|
# cross subst the same var : |
|
|
|
|
filterReader = FilterReader('substition', "jailname", {'honeypot': '<sweet>', 'sweet': '<honeypot>'}, |
|
|
|
|
filterReader = FilterReader('substitution', "jailname", {'honeypot': '<sweet>', 'sweet': '<honeypot>'}, |
|
|
|
|
share_config=TEST_FILES_DIR_SHARE_CFG, basedir=TEST_FILES_DIR) |
|
|
|
|
filterReader.read() |
|
|
|
|
filterReader.getOptions(None) |
|
|
|
|