diff --git a/boefjes/boefjes/plugins/kat_external_db/description.md b/boefjes/boefjes/plugins/kat_external_db/description.md index a15211a1c5b..f40bffd9733 100644 --- a/boefjes/boefjes/plugins/kat_external_db/description.md +++ b/boefjes/boefjes/plugins/kat_external_db/description.md @@ -25,11 +25,11 @@ For example: ```json { "ip_addresses": [ - { "ip_address": "198.51.100.2" }, - { "ip_address": "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff" }, - { "ip_address": "192.0.2.0/24" } + { "address": "198.51.100.2" }, + { "address": "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff" }, + { "address": "192.0.2.0/24" } ], - "domains": [{ "domain": "example.com" }] + "domains": [{ "name": "example.com" }] } ``` diff --git a/boefjes/boefjes/plugins/kat_external_db/normalize.py b/boefjes/boefjes/plugins/kat_external_db/normalize.py index 1ec7d04ce04..e1b7fdb99c9 100644 --- a/boefjes/boefjes/plugins/kat_external_db/normalize.py +++ b/boefjes/boefjes/plugins/kat_external_db/normalize.py @@ -14,9 +14,9 @@ # are defined below. # T O D O add these variables as normalizer settings in UI. IP_ADDRESS_LIST_PATH = ["ip_addresses"] -IP_ADDRESS_ITEM_PATH = ["ip_address"] +IP_ADDRESS_ITEM_PATH = ["address"] DOMAIN_LIST_PATH = ["domains"] -DOMAIN_ITEM_PATH = ["domain"] +DOMAIN_ITEM_PATH = ["name"] def follow_path_in_dict(path, path_dict): diff --git a/boefjes/tests/test_scan_profiles.py b/boefjes/tests/test_scan_profiles.py index 0de46e595c5..e56da244c37 100644 --- a/boefjes/tests/test_scan_profiles.py +++ b/boefjes/tests/test_scan_profiles.py @@ -14,20 +14,17 @@ from octopoes.models import DeclaredScanProfile from tests.loading import get_dummy_data +RAW_DATA = json.dumps( + {"ip_addresses": [{"address": "127.0.0.1"}, {"address": "10.0.0.0"}], "domains": [{"name": "example.com"}]} +) + class ScanProfileTest(TestCase): def test_normalizer_can_yield_scan_profiles(self): local_repository = LocalPluginRepository(Path(__file__).parent.parent / "boefjes" / "plugins") runner = LocalNormalizerJobRunner(local_repository) meta = NormalizerMeta.model_validate_json(get_dummy_data("external_db.json")) - - raw = json.dumps( - { - "ip_addresses": [{"ip_address": "127.0.0.1"}, {"ip_address": "10.0.0.0"}], - "domains": [{"domain": "example.com"}], - } - ) - output = runner.run(meta, bytes(raw, "UTF-8")) + output = runner.run(meta, bytes(RAW_DATA, "UTF-8")) self.assertEqual(1, len(output.observations)) self.assertEqual(3, len(output.observations[0].results)) @@ -49,12 +46,8 @@ def test_normalizer_can_yield_scan_profiles(self): self.assertEqual(3, profile.level) def test_job_handler_respects_whitelist(self): - raw = { - "ip_addresses": [{"ip_address": "127.0.0.1"}, {"ip_address": "10.0.0.0"}], - "domains": [{"domain": "example.com"}], - } bytes_mock = mock.Mock() - bytes_mock.get_raw.return_value = json.dumps(raw) + bytes_mock.get_raw.return_value = RAW_DATA octopoes = mock.Mock() local_repository = LocalPluginRepository(Path(__file__).parent.parent / "boefjes" / "plugins")