diff --git a/lib/python/matano_detection/detection/common.py b/lib/python/matano_detection/detection/common.py index 955e4729..1c10724e 100644 --- a/lib/python/matano_detection/detection/common.py +++ b/lib/python/matano_detection/detection/common.py @@ -104,12 +104,16 @@ def _load_table_detection_config(): ret = defaultdict(list) for detection_path, detection_config in DETECTION_CONFIGS.items(): for table_name in detection_config["tables"]: - ret[table_name].append( - { - "detection": detection_config, - "module": importlib.import_module(".", f"{detection_path}.detect"), - } - ) + if detection_config.get("enabled", False): + ret[table_name].append( + { + "detection": detection_config, + "module": importlib.import_module(".", f"{detection_path}.detect"), + } + ) + else: + detection_name = detection_config.get("name") + logger.warning(f"skipping disabled detection {detection_name}") TABLE_DETECTION_CONFIG = ret @@ -195,7 +199,7 @@ def debug_metrics(record_count, detection_run_count, alert_count): dl_time = timers.get_timer("data_download").elapsed avg_detection_run_time = ( - 0 if record_count == 0 else processing_time / detection_run_count + 0 if (record_count == 0 or detection_run_count == 0) else processing_time / detection_run_count ) logger.info( f"Took {processing_time} seconds, processed {record_count} records, ran {detection_run_count} detections, an average time of {avg_detection_run_time} seconds per detection run, generating {alert_count} alerts"