from __future__ import annotations import importlib from pathlib import Path from typing import Any, Dict from lab.runners.common import RunnerContext def _module_name(profile: Dict[str, Any]) -> str: runner_id = str(profile.get("runner_id") or "").strip() if runner_id: system_name, family_name = runner_id.split(".", 1) else: system_name = str(profile.get("system_id") or "").strip() family_name = str(profile.get("vuln_family") or "").strip() system_name = system_name.replace("-", "_") family_name = family_name.replace("-", "_") return f"lab.runners.{system_name}.{family_name}" def _load_runner(profile: Dict[str, Any]): return importlib.import_module(_module_name(profile)) def run_seed(profile: Dict[str, Any], advisory: Dict[str, Any], run_dir: Path) -> Dict[str, Any]: module = _load_runner(profile) context = RunnerContext(profile=profile, advisory=advisory, run_dir=run_dir) return module.run_seed(context) def run_attack(profile: Dict[str, Any], advisory: Dict[str, Any], run_dir: Path) -> Dict[str, Any]: module = _load_runner(profile) context = RunnerContext(profile=profile, advisory=advisory, run_dir=run_dir) return module.run_attack(context)