From 3c772c7df85daddd0326fed07cd2408c259c9b96 Mon Sep 17 00:00:00 2001 From: Mathy Vanhoef Date: Sun, 28 Jun 2020 09:49:07 +0400 Subject: [PATCH] fragattack: only import tests currently in the directory --- research/fragattack.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/research/fragattack.py b/research/fragattack.py index 70f463d3e..a55d537f2 100755 --- a/research/fragattack.py +++ b/research/fragattack.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 +import glob, importlib from fraginternals import * -from tests_common import * -from tests_qca import * -from tests_attacks import * #TODO: Check that modified drivers are used using debugfs #TODO: Check that atheros is using patched firmware using debugfs @@ -250,6 +248,15 @@ if __name__ == "__main__": else: options.inject_test_postauth = False + # Dynamically import tests depending on their availability in the directory + for test in glob("tests_*.py"): + module = importlib.import_module(test[:-3]) + globals().update( + {n: getattr(module, n) for n in module.__all__} if hasattr(module, '__all__') + else + {k: v for (k, v) in module.__dict__.items() if not k.startswith('_') + }) + # Construct the test options.test = prepare_tests(options) if options.test == None: