Island: Format fingerprinter config with options

This commit is contained in:
Mike Salvatore 2022-02-07 12:07:45 -05:00
parent 4b2fb260c3
commit a989e5543a
2 changed files with 19 additions and 7 deletions

View File

@ -538,10 +538,19 @@ class ConfigService:
@staticmethod
def _format_fingerprinters_from_flat_config(config: Dict):
flat_fingerprinter_classes_field = "finger_classes"
flat_http_ports_field = "HTTP_PORTS"
formatted_fingerprinters = [
{"name": f, "options": {}} for f in sorted(config[flat_fingerprinter_classes_field])
]
if "HTTPFinger" in config[flat_fingerprinter_classes_field]:
for fp in formatted_fingerprinters:
if fp["name"] == "HTTPFinger":
fp["options"] = {"http_ports": sorted(config[flat_http_ports_field])}
break
formatted_fingerprinters = config[flat_fingerprinter_classes_field]
config.pop(flat_fingerprinter_classes_field)
return formatted_fingerprinters
@staticmethod

View File

@ -147,11 +147,14 @@ def test_format_config_for_agent__network_scan(flat_monkey_config):
"timeout_ms": 1000,
},
"fingerprinters": [
"SMBFinger",
"SSHFinger",
"HTTPFinger",
"MSSQLFinger",
"ElasticFinger",
{"name": "ElasticFinger", "options": {}},
{
"name": "HTTPFinger",
"options": {"http_ports": [80, 443, 7001, 8008, 8080, 9200]},
},
{"name": "MSSQLFinger", "options": {}},
{"name": "SMBFinger", "options": {}},
{"name": "SSHFinger", "options": {}},
],
}
ConfigService.format_flat_config_for_agent(flat_monkey_config)