mirror of https://github.com/fail2ban/fail2ban
BF: Stop actName being passed to python actions
parent
98bf511443
commit
414c5e1146
|
@ -126,7 +126,7 @@ class JailReader(ConfigReader):
|
||||||
"set",
|
"set",
|
||||||
self.__name,
|
self.__name,
|
||||||
"addaction",
|
"addaction",
|
||||||
actOpt.get("actname", os.path.splitext(actName)[0]),
|
actOpt.pop("actname", os.path.splitext(actName)[0]),
|
||||||
os.path.join(
|
os.path.join(
|
||||||
self.getBaseDir(), "action.d", actName),
|
self.getBaseDir(), "action.d", actName),
|
||||||
json.dumps(actOpt),
|
json.dumps(actOpt),
|
||||||
|
|
|
@ -539,6 +539,8 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
[testjail1]
|
[testjail1]
|
||||||
action = testaction1[actname=test1]
|
action = testaction1[actname=test1]
|
||||||
testaction1[actname=test2]
|
testaction1[actname=test2]
|
||||||
|
testaction.py
|
||||||
|
testaction.py[actname=test3]
|
||||||
filter = testfilter1
|
filter = testfilter1
|
||||||
""")
|
""")
|
||||||
jailfd.close()
|
jailfd.close()
|
||||||
|
@ -547,8 +549,12 @@ filter = testfilter1
|
||||||
self.assertTrue(jails.getOptions())
|
self.assertTrue(jails.getOptions())
|
||||||
comm_commands = jails.convert(allow_no_files=True)
|
comm_commands = jails.convert(allow_no_files=True)
|
||||||
|
|
||||||
action_names = [comm[-1] for comm in comm_commands if comm[:3] == ['set', 'testjail1', 'addaction']]
|
add_actions = [comm[3:] for comm in comm_commands
|
||||||
|
if comm[:3] == ['set', 'testjail1', 'addaction']]
|
||||||
|
|
||||||
self.assertNotEqual(len(set(action_names)), 1)
|
self.assertEqual(len(set(action[0] for action in add_actions)), 4)
|
||||||
|
|
||||||
|
# Python actions should not be passed `actname`
|
||||||
|
self.assertEqual(add_actions[-1][-1], "{}")
|
||||||
|
|
||||||
shutil.rmtree(basedir)
|
shutil.rmtree(basedir)
|
||||||
|
|
Loading…
Reference in New Issue