From 0a06d39d4c67a788ae3616c3114c7aa5858cfaca Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 2 Dec 2024 10:19:58 -0600 Subject: [PATCH] More specific filename to module name * improved docs to reference plugin `family` name changes * spelling for log of successful action * more specific removal of file extension in filename Signed-off-by: Jeffrey Martin --- garak/resources/fixer/20240628_gcg_rename.py | 2 +- garak/resources/fixer/20240822_knownbadsignatures_rename.py | 2 +- garak/resources/fixer/20241011_replay_rename.py | 2 +- garak/resources/fixer/__init__.py | 4 ++-- tests/resources/test_fixer.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/garak/resources/fixer/20240628_gcg_rename.py b/garak/resources/fixer/20240628_gcg_rename.py index 21ce7d9d..c507d687 100644 --- a/garak/resources/fixer/20240628_gcg_rename.py +++ b/garak/resources/fixer/20240628_gcg_rename.py @@ -7,7 +7,7 @@ class RenameGCG(Migration): def apply(config_dict: dict) -> dict: - """Rename probe gcg -> suffix""" + """Rename probe family gcg -> suffix""" path = ["plugins", "probes"] old = "gcg" diff --git a/garak/resources/fixer/20240822_knownbadsignatures_rename.py b/garak/resources/fixer/20240822_knownbadsignatures_rename.py index 3daebc01..f8c577d0 100644 --- a/garak/resources/fixer/20240822_knownbadsignatures_rename.py +++ b/garak/resources/fixer/20240822_knownbadsignatures_rename.py @@ -7,7 +7,7 @@ class RenameKnownbadsignatures(Migration): def apply(config_dict: dict) -> dict: - """Rename probe knownbadsignatures -> av_spam_scanning""" + """Rename probe family knownbadsignatures -> av_spam_scanning""" path = ["plugins", "probes"] old = "knownbadsignatures" diff --git a/garak/resources/fixer/20241011_replay_rename.py b/garak/resources/fixer/20241011_replay_rename.py index 689e950b..3d8a919c 100644 --- a/garak/resources/fixer/20241011_replay_rename.py +++ b/garak/resources/fixer/20241011_replay_rename.py @@ -7,7 +7,7 @@ class RenameReplay(Migration): def apply(config_dict: dict) -> dict: - """Rename probe replay -> divergence""" + """Rename probe family replay -> divergence""" path = ["plugins", "probes"] old = "replay" diff --git a/garak/resources/fixer/__init__.py b/garak/resources/fixer/__init__.py index bd17c101..103ef5f3 100644 --- a/garak/resources/fixer/__init__.py +++ b/garak/resources/fixer/__init__.py @@ -28,7 +28,7 @@ def apply(config_dict: dict) -> dict: continue if module_filename.startswith("__"): continue - module_name = module_filename.replace(".py", "") + module_name = module_filename[:-3] # strip ".py" known from check above mod = importlib.import_module(f"{__package__}.{module_name}") migrations = [ # Extract only classes that are a `Migration` klass @@ -50,6 +50,6 @@ def migrate(original_config: dict) -> dict: logging.info(msg) if original_config != updated_config: - logging.info("Migration preformed") + logging.info("Migration performed") return updated_config diff --git a/tests/resources/test_fixer.py b/tests/resources/test_fixer.py index 2168b653..314bddc5 100644 --- a/tests/resources/test_fixer.py +++ b/tests/resources/test_fixer.py @@ -147,7 +147,7 @@ def test_fixer_migrate( ), "Logging should not be called when no migrations are applied" else: # expect `migration_name` in a log call via mock of logging.info() - assert "Migration preformed" in mock_log_info.call_args.args[0] + assert "Migration performed" in mock_log_info.call_args.args[0] found_class = False for calls in mock_log_info.call_args_list: found_class = migration_name in calls.args[0]