From 207a65e2a9c3daa1cb4021e00a6d170219feee2b Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 7 Feb 2022 13:02:01 -0500 Subject: [PATCH] Island: Simplify the names of fingerprinters in the config --- monkey/monkey_island/cc/services/config.py | 8 +++++++- .../monkey_island/cc/services/test_config.py | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 163c9d1da..1396a130b 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -2,6 +2,7 @@ import collections import copy import functools import logging +import re from typing import Dict, List from jsonschema import Draft4Validator, validators @@ -548,11 +549,16 @@ class ConfigService: for fp in formatted_fingerprinters: if fp["name"] == "HTTPFinger": fp["options"] = {"http_ports": sorted(config[flat_http_ports_field])} - break + + fp["name"] = ConfigService._translate_fingerprinter_name(fp["name"]) config.pop(flat_fingerprinter_classes_field) return formatted_fingerprinters + @staticmethod + def _translate_fingerprinter_name(name: str): + return re.sub(r"Finger", "", name).lower() + @staticmethod def _format_targets_from_flat_config(config: Dict): flat_blocked_ips_field = "blocked_ips" diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py index fe8ec639e..daecec1b6 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py @@ -147,14 +147,14 @@ def test_format_config_for_agent__network_scan(flat_monkey_config): "timeout_ms": 1000, }, "fingerprinters": [ - {"name": "ElasticFinger", "options": {}}, + {"name": "elastic", "options": {}}, { - "name": "HTTPFinger", + "name": "http", "options": {"http_ports": [80, 443, 7001, 8008, 8080, 9200]}, }, - {"name": "MSSQLFinger", "options": {}}, - {"name": "SMBFinger", "options": {}}, - {"name": "SSHFinger", "options": {}}, + {"name": "mssql", "options": {}}, + {"name": "smb", "options": {}}, + {"name": "ssh", "options": {}}, ], } ConfigService.format_flat_config_for_agent(flat_monkey_config)