From 6e9212780781d54629731d6a0c4f79dedbc6fcbd Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 9 Apr 2021 13:09:27 +0530 Subject: [PATCH 1/8] Rename unit test files from *_test.py to test_*.py --- .../tools/{payload_parsing_test.py => test_payload_parsing.py} | 0 ...ictim_host_generator_test.py => test_victim_host_generator.py} | 0 .../utils/plugins/{plugin_test.py => test_plugin.py} | 0 .../monkey_island/cc/resources/test/{log_test.py => test_log.py} | 0 .../cc/resources/test/{monkey_test.py => test_monkey.py} | 0 .../cc/resources/test/{telemetry_test.py => test_telemetry.py} | 0 .../cc/resources/{bootloader_test.py => test_bootloader.py} | 0 .../cc/services/{bootloader_test.py => test_bootloader.py} | 0 .../services/{representations_test.py => test_representations.py} | 0 .../services/utils/{node_states_test.py => test_node_states.py} | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename monkey/infection_monkey/exploit/tools/{payload_parsing_test.py => test_payload_parsing.py} (100%) rename monkey/infection_monkey/model/{victim_host_generator_test.py => test_victim_host_generator.py} (100%) rename monkey/infection_monkey/utils/plugins/{plugin_test.py => test_plugin.py} (100%) rename monkey/monkey_island/cc/resources/test/{log_test.py => test_log.py} (100%) rename monkey/monkey_island/cc/resources/test/{monkey_test.py => test_monkey.py} (100%) rename monkey/monkey_island/cc/resources/test/{telemetry_test.py => test_telemetry.py} (100%) rename monkey/monkey_island/cc/resources/{bootloader_test.py => test_bootloader.py} (100%) rename monkey/monkey_island/cc/services/{bootloader_test.py => test_bootloader.py} (100%) rename monkey/monkey_island/cc/services/{representations_test.py => test_representations.py} (100%) rename monkey/monkey_island/cc/services/utils/{node_states_test.py => test_node_states.py} (100%) diff --git a/monkey/infection_monkey/exploit/tools/payload_parsing_test.py b/monkey/infection_monkey/exploit/tools/test_payload_parsing.py similarity index 100% rename from monkey/infection_monkey/exploit/tools/payload_parsing_test.py rename to monkey/infection_monkey/exploit/tools/test_payload_parsing.py diff --git a/monkey/infection_monkey/model/victim_host_generator_test.py b/monkey/infection_monkey/model/test_victim_host_generator.py similarity index 100% rename from monkey/infection_monkey/model/victim_host_generator_test.py rename to monkey/infection_monkey/model/test_victim_host_generator.py diff --git a/monkey/infection_monkey/utils/plugins/plugin_test.py b/monkey/infection_monkey/utils/plugins/test_plugin.py similarity index 100% rename from monkey/infection_monkey/utils/plugins/plugin_test.py rename to monkey/infection_monkey/utils/plugins/test_plugin.py diff --git a/monkey/monkey_island/cc/resources/test/log_test.py b/monkey/monkey_island/cc/resources/test/test_log.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/log_test.py rename to monkey/monkey_island/cc/resources/test/test_log.py diff --git a/monkey/monkey_island/cc/resources/test/monkey_test.py b/monkey/monkey_island/cc/resources/test/test_monkey.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/monkey_test.py rename to monkey/monkey_island/cc/resources/test/test_monkey.py diff --git a/monkey/monkey_island/cc/resources/test/telemetry_test.py b/monkey/monkey_island/cc/resources/test/test_telemetry.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/telemetry_test.py rename to monkey/monkey_island/cc/resources/test/test_telemetry.py diff --git a/monkey/monkey_island/cc/resources/bootloader_test.py b/monkey/monkey_island/cc/resources/test_bootloader.py similarity index 100% rename from monkey/monkey_island/cc/resources/bootloader_test.py rename to monkey/monkey_island/cc/resources/test_bootloader.py diff --git a/monkey/monkey_island/cc/services/bootloader_test.py b/monkey/monkey_island/cc/services/test_bootloader.py similarity index 100% rename from monkey/monkey_island/cc/services/bootloader_test.py rename to monkey/monkey_island/cc/services/test_bootloader.py diff --git a/monkey/monkey_island/cc/services/representations_test.py b/monkey/monkey_island/cc/services/test_representations.py similarity index 100% rename from monkey/monkey_island/cc/services/representations_test.py rename to monkey/monkey_island/cc/services/test_representations.py diff --git a/monkey/monkey_island/cc/services/utils/node_states_test.py b/monkey/monkey_island/cc/services/utils/test_node_states.py similarity index 100% rename from monkey/monkey_island/cc/services/utils/node_states_test.py rename to monkey/monkey_island/cc/services/utils/test_node_states.py From 5469c7cc41d18de0ebb3abc0d01901583f74340b Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 9 Apr 2021 14:25:44 +0530 Subject: [PATCH 2/8] Match unit tests' class names and file names Renamed class/file name depending on which was more applicable --- monkey/common/cloud/aws/test_aws_service.py | 2 +- ...est_payload_parsing.py => test_payload.py} | 0 .../model/test_victim_host_generator.py | 2 +- .../utils/plugins/pluginTests/BadImport.py | 2 +- .../utils/plugins/pluginTests/BadInit.py | 4 +-- .../utils/plugins/pluginTests/ComboFile.py | 6 ++--- .../plugins/pluginTests/PluginTestClass.py | 4 +-- .../plugins/pluginTests/PluginWorking.py | 4 +-- .../utils/plugins/test_plugin.py | 26 +++++++++---------- .../{test__init__.py => test_environment.py} | 0 .../cc/resources/test/test_log.py | 2 +- .../cc/resources/test/test_monkey.py | 2 +- .../cc/resources/test/test_telemetry.py | 2 +- ...edge.py => test_displayed_edge_service.py} | 0 .../{test_edge.py => test_edge_service.py} | 0 ... test_environment_telemetry_processing.py} | 0 ...otloader.py => test_bootloader_service.py} | 0 .../cc/services/test_representations.py | 2 +- .../cc/services/utils/test_node_states.py | 2 +- 19 files changed, 30 insertions(+), 30 deletions(-) rename monkey/infection_monkey/exploit/tools/{test_payload_parsing.py => test_payload.py} (100%) rename monkey/monkey_island/cc/environment/{test__init__.py => test_environment.py} (100%) rename monkey/monkey_island/cc/services/edge/{test_displayed_edge.py => test_displayed_edge_service.py} (100%) rename monkey/monkey_island/cc/services/edge/{test_edge.py => test_edge_service.py} (100%) rename monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/{test_environment.py => test_environment_telemetry_processing.py} (100%) rename monkey/monkey_island/cc/services/{test_bootloader.py => test_bootloader_service.py} (100%) diff --git a/monkey/common/cloud/aws/test_aws_service.py b/monkey/common/cloud/aws/test_aws_service.py index 8b17d707d..95fa6329b 100644 --- a/monkey/common/cloud/aws/test_aws_service.py +++ b/monkey/common/cloud/aws/test_aws_service.py @@ -6,7 +6,7 @@ from .aws_service import filter_instance_data_from_aws_response __author__ = "shay.nehmad" -class TestFilterInstanceDataFromAwsResponse(TestCase): +class TestAwsService(TestCase): def test_filter_instance_data_from_aws_response(self): json_response_full = """ { diff --git a/monkey/infection_monkey/exploit/tools/test_payload_parsing.py b/monkey/infection_monkey/exploit/tools/test_payload.py similarity index 100% rename from monkey/infection_monkey/exploit/tools/test_payload_parsing.py rename to monkey/infection_monkey/exploit/tools/test_payload.py diff --git a/monkey/infection_monkey/model/test_victim_host_generator.py b/monkey/infection_monkey/model/test_victim_host_generator.py index 26ca99352..c60992fee 100644 --- a/monkey/infection_monkey/model/test_victim_host_generator.py +++ b/monkey/infection_monkey/model/test_victim_host_generator.py @@ -4,7 +4,7 @@ from common.network.network_range import CidrRange, SingleIpRange from infection_monkey.model.victim_host_generator import VictimHostGenerator -class VictimHostGeneratorTester(TestCase): +class TestVictimHostGenerator(TestCase): def setUp(self): self.cidr_range = CidrRange("10.0.0.0/28", False) # this gives us 15 hosts self.local_host_range = SingleIpRange("localhost") diff --git a/monkey/infection_monkey/utils/plugins/pluginTests/BadImport.py b/monkey/infection_monkey/utils/plugins/pluginTests/BadImport.py index ffd3ebb2d..41e8c1387 100644 --- a/monkey/infection_monkey/utils/plugins/pluginTests/BadImport.py +++ b/monkey/infection_monkey/utils/plugins/pluginTests/BadImport.py @@ -1,4 +1,4 @@ -from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin # noqa: F401 +from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester # noqa: F401 class SomeDummyPlugin: diff --git a/monkey/infection_monkey/utils/plugins/pluginTests/BadInit.py b/monkey/infection_monkey/utils/plugins/pluginTests/BadInit.py index 7e4c93940..61c1df7ad 100644 --- a/monkey/infection_monkey/utils/plugins/pluginTests/BadInit.py +++ b/monkey/infection_monkey/utils/plugins/pluginTests/BadInit.py @@ -1,6 +1,6 @@ -from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin +from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester -class BadPluginInit(TestPlugin): +class BadPluginInit(PluginTester): def __init__(self): raise Exception("TestException") diff --git a/monkey/infection_monkey/utils/plugins/pluginTests/ComboFile.py b/monkey/infection_monkey/utils/plugins/pluginTests/ComboFile.py index 09abae314..6f33142cc 100644 --- a/monkey/infection_monkey/utils/plugins/pluginTests/ComboFile.py +++ b/monkey/infection_monkey/utils/plugins/pluginTests/ComboFile.py @@ -1,14 +1,14 @@ -from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin +from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester class NoInheritance: pass -class BadInit(TestPlugin): +class BadInit(PluginTester): def __init__(self): raise Exception("TestException") -class ProperClass(TestPlugin): +class ProperClass(PluginTester): pass diff --git a/monkey/infection_monkey/utils/plugins/pluginTests/PluginTestClass.py b/monkey/infection_monkey/utils/plugins/pluginTests/PluginTestClass.py index 310cf7f2c..4de543fb0 100644 --- a/monkey/infection_monkey/utils/plugins/pluginTests/PluginTestClass.py +++ b/monkey/infection_monkey/utils/plugins/pluginTests/PluginTestClass.py @@ -2,7 +2,7 @@ import infection_monkey.utils.plugins.pluginTests from infection_monkey.utils.plugins.plugin import Plugin -class TestPlugin(Plugin): +class PluginTester(Plugin): classes_to_load = [] @staticmethod @@ -11,7 +11,7 @@ class TestPlugin(Plugin): Decides if post breach action is enabled in config :return: True if it needs to be ran, false otherwise """ - return class_name in TestPlugin.classes_to_load + return class_name in PluginTester.classes_to_load @staticmethod def base_package_file(): diff --git a/monkey/infection_monkey/utils/plugins/pluginTests/PluginWorking.py b/monkey/infection_monkey/utils/plugins/pluginTests/PluginWorking.py index a3fe237b6..27da245f2 100644 --- a/monkey/infection_monkey/utils/plugins/pluginTests/PluginWorking.py +++ b/monkey/infection_monkey/utils/plugins/pluginTests/PluginWorking.py @@ -1,5 +1,5 @@ -from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin +from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester -class PluginWorking(TestPlugin): +class PluginWorking(PluginTester): pass diff --git a/monkey/infection_monkey/utils/plugins/test_plugin.py b/monkey/infection_monkey/utils/plugins/test_plugin.py index d8034c016..35eaaed63 100644 --- a/monkey/infection_monkey/utils/plugins/test_plugin.py +++ b/monkey/infection_monkey/utils/plugins/test_plugin.py @@ -3,33 +3,33 @@ from unittest import TestCase from infection_monkey.utils.plugins.pluginTests.BadImport import SomeDummyPlugin from infection_monkey.utils.plugins.pluginTests.BadInit import BadPluginInit from infection_monkey.utils.plugins.pluginTests.ComboFile import BadInit, ProperClass -from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin +from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester from infection_monkey.utils.plugins.pluginTests.PluginWorking import PluginWorking -class PluginTester(TestCase): +class TestPlugin(TestCase): def test_combo_file(self): - TestPlugin.classes_to_load = [BadInit.__name__, ProperClass.__name__] - to_init = TestPlugin.get_classes() + PluginTester.classes_to_load = [BadInit.__name__, ProperClass.__name__] + to_init = PluginTester.get_classes() self.assertEqual(len(to_init), 2) - objects = TestPlugin.get_instances() + objects = PluginTester.get_instances() self.assertEqual(len(objects), 1) def test_bad_init(self): - TestPlugin.classes_to_load = [BadPluginInit.__name__] - to_init = TestPlugin.get_classes() + PluginTester.classes_to_load = [BadPluginInit.__name__] + to_init = PluginTester.get_classes() self.assertEqual(len(to_init), 1) - objects = TestPlugin.get_instances() + objects = PluginTester.get_instances() self.assertEqual(len(objects), 0) def test_bad_import(self): - TestPlugin.classes_to_load = [SomeDummyPlugin.__name__] - to_init = TestPlugin.get_classes() + PluginTester.classes_to_load = [SomeDummyPlugin.__name__] + to_init = PluginTester.get_classes() self.assertEqual(len(to_init), 0) def test_flow(self): - TestPlugin.classes_to_load = [PluginWorking.__name__] - to_init = TestPlugin.get_classes() + PluginTester.classes_to_load = [PluginWorking.__name__] + to_init = PluginTester.get_classes() self.assertEqual(len(to_init), 1) - objects = TestPlugin.get_instances() + objects = PluginTester.get_instances() self.assertEqual(len(objects), 1) diff --git a/monkey/monkey_island/cc/environment/test__init__.py b/monkey/monkey_island/cc/environment/test_environment.py similarity index 100% rename from monkey/monkey_island/cc/environment/test__init__.py rename to monkey/monkey_island/cc/environment/test_environment.py diff --git a/monkey/monkey_island/cc/resources/test/test_log.py b/monkey/monkey_island/cc/resources/test/test_log.py index c6ec50f71..9332d71f8 100644 --- a/monkey/monkey_island/cc/resources/test/test_log.py +++ b/monkey/monkey_island/cc/resources/test/test_log.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import database, mongo from monkey_island.cc.resources.auth.auth import jwt_required -class LogTest(flask_restful.Resource): +class TestLog(flask_restful.Resource): @jwt_required def get(self): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/test/test_monkey.py b/monkey/monkey_island/cc/resources/test/test_monkey.py index 1122141d2..5eddc61ac 100644 --- a/monkey/monkey_island/cc/resources/test/test_monkey.py +++ b/monkey/monkey_island/cc/resources/test/test_monkey.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class MonkeyTest(flask_restful.Resource): +class TestMonkey(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/test/test_telemetry.py b/monkey/monkey_island/cc/resources/test/test_telemetry.py index 54be08d71..f929988ac 100644 --- a/monkey/monkey_island/cc/resources/test/test_telemetry.py +++ b/monkey/monkey_island/cc/resources/test/test_telemetry.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class TelemetryTest(flask_restful.Resource): +class TestTelemetry(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/services/edge/test_displayed_edge.py b/monkey/monkey_island/cc/services/edge/test_displayed_edge_service.py similarity index 100% rename from monkey/monkey_island/cc/services/edge/test_displayed_edge.py rename to monkey/monkey_island/cc/services/edge/test_displayed_edge_service.py diff --git a/monkey/monkey_island/cc/services/edge/test_edge.py b/monkey/monkey_island/cc/services/edge/test_edge_service.py similarity index 100% rename from monkey/monkey_island/cc/services/edge/test_edge.py rename to monkey/monkey_island/cc/services/edge/test_edge_service.py diff --git a/monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment.py b/monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py similarity index 100% rename from monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment.py rename to monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py diff --git a/monkey/monkey_island/cc/services/test_bootloader.py b/monkey/monkey_island/cc/services/test_bootloader_service.py similarity index 100% rename from monkey/monkey_island/cc/services/test_bootloader.py rename to monkey/monkey_island/cc/services/test_bootloader_service.py diff --git a/monkey/monkey_island/cc/services/test_representations.py b/monkey/monkey_island/cc/services/test_representations.py index 8aadc0bed..c088c3dce 100644 --- a/monkey/monkey_island/cc/services/test_representations.py +++ b/monkey/monkey_island/cc/services/test_representations.py @@ -6,7 +6,7 @@ import bson from monkey_island.cc.services.representations import normalize_obj -class TestJsonRepresentations(TestCase): +class TestRepresentations(TestCase): def test_normalize_obj(self): # empty self.assertEqual({}, normalize_obj({})) diff --git a/monkey/monkey_island/cc/services/utils/test_node_states.py b/monkey/monkey_island/cc/services/utils/test_node_states.py index 98df5455b..e39a0c246 100644 --- a/monkey/monkey_island/cc/services/utils/test_node_states.py +++ b/monkey/monkey_island/cc/services/utils/test_node_states.py @@ -3,7 +3,7 @@ from unittest import TestCase from monkey_island.cc.services.utils.node_states import NodeStates, NoGroupsFoundException -class TestNodeGroups(TestCase): +class TestNodeStates(TestCase): def test_get_group_by_keywords(self): self.assertEqual(NodeStates.get_by_keywords(["island"]), NodeStates.ISLAND) self.assertEqual( From a39cfd21fb7fe90297d29a93ea4d79f5abff05f7 Mon Sep 17 00:00:00 2001 From: Shreya Date: Sat, 10 Apr 2021 23:14:32 +0530 Subject: [PATCH 3/8] Swimm: update exercise Add a simple Post Breach action (id: tbxb2cGgUiJQ8Btma0fp). --- .swm/tbxb2cGgUiJQ8Btma0fp.swm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.swm/tbxb2cGgUiJQ8Btma0fp.swm b/.swm/tbxb2cGgUiJQ8Btma0fp.swm index 4450451e1..9fda0cb20 100644 --- a/.swm/tbxb2cGgUiJQ8Btma0fp.swm +++ b/.swm/tbxb2cGgUiJQ8Btma0fp.swm @@ -81,7 +81,7 @@ "type": "snippet", "path": "monkey/monkey_island/cc/services/config_schema/definitions/post_breach_actions.py", "comments": [], - "firstLineNumber": 4, + "firstLineNumber": 5, "lines": [ " \"might do after breaching a new machine. Used in ATT&CK and Zero trust reports.\",", " \"type\": \"string\",", @@ -92,7 +92,7 @@ "* \"enum\": [\"BackdoorUser\"],", "* \"title\": \"Back door user\",", "* \"safe\": True,", - "* \"info\": \"Attempts to create a new user on the system and delete it afterwards.\",", + "* \"info\": \"Attempts to create a new user on the system and delete it \" \"afterwards.\",", "* \"attack_techniques\": [\"T1136\"],", "* },", " {", @@ -113,7 +113,7 @@ "monkey/common/common_consts/post_breach_consts.py": "25e6679cb1623aae1a732deb05cc011a452743e3", "monkey/infection_monkey/post_breach/actions/add_user.py": "cae5a2428fa01b333a2e70365c9da1e189e31bc4", "monkey/monkey_island/cc/services/attack/technique_reports/T1136.py": "dfc5945a362b88c1135f4476526c6c82977b02ee", - "monkey/monkey_island/cc/services/config_schema/definitions/post_breach_actions.py": "ea9b18aba7f71da12c9c82ac39d8a0cf2c472a9c" + "monkey/monkey_island/cc/services/config_schema/definitions/post_breach_actions.py": "2c1104bcbe3ba0f885907d9d00210bd658ce8f74" } } } From 26684bbb4e9cb35d9a7dad8f7a93e8c563849778 Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 13 Apr 2021 10:47:48 +0530 Subject: [PATCH 4/8] Rename files having endpoints for blackbox tests --- monkey/monkey_island/cc/app.py | 12 ++++++------ .../test/{test_log.py => log_test_endpoint.py} | 2 +- .../test/{test_monkey.py => monkey_test_endpoint.py} | 2 +- ...{test_telemetry.py => telemetry_test_endpoint.py} | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename monkey/monkey_island/cc/resources/test/{test_log.py => log_test_endpoint.py} (91%) rename monkey/monkey_island/cc/resources/test/{test_monkey.py => monkey_test_endpoint.py} (87%) rename monkey/monkey_island/cc/resources/test/{test_telemetry.py => telemetry_test_endpoint.py} (87%) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 1d9b7ce79..4cc37e269 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -37,9 +37,9 @@ from monkey_island.cc.resources.T1216_pba_file_download import T1216PBAFileDownl from monkey_island.cc.resources.telemetry import Telemetry from monkey_island.cc.resources.telemetry_feed import TelemetryFeed from monkey_island.cc.resources.test.clear_caches import ClearCaches -from monkey_island.cc.resources.test.log_test import LogTest -from monkey_island.cc.resources.test.monkey_test import MonkeyTest -from monkey_island.cc.resources.test.telemetry_test import TelemetryTest +from monkey_island.cc.resources.test.log_test_endpoint import LogTestEndpoint +from monkey_island.cc.resources.test.monkey_test_endpoint import MonkeyTestEndpoint +from monkey_island.cc.resources.test.telemetry_test_endpoint import TelemetryTestEndpoint from monkey_island.cc.resources.version_update import VersionUpdate from monkey_island.cc.resources.zero_trust.finding_event import ZeroTrustFindingEvent from monkey_island.cc.resources.zero_trust.scoutsuite_auth.aws_keys import AWSKeys @@ -165,10 +165,10 @@ def init_api_resources(api): api.add_resource(AWSKeys, "/api/aws_keys") # Resources used by black box tests - api.add_resource(MonkeyTest, "/api/test/monkey") + api.add_resource(MonkeyTestEndpoint, "/api/test/monkey") api.add_resource(ClearCaches, "/api/test/clear_caches") - api.add_resource(LogTest, "/api/test/log") - api.add_resource(TelemetryTest, "/api/test/telemetry") + api.add_resource(LogTestEndpoint, "/api/test/log") + api.add_resource(TelemetryTestEndpoint, "/api/test/telemetry") def init_app(mongo_url): diff --git a/monkey/monkey_island/cc/resources/test/test_log.py b/monkey/monkey_island/cc/resources/test/log_test_endpoint.py similarity index 91% rename from monkey/monkey_island/cc/resources/test/test_log.py rename to monkey/monkey_island/cc/resources/test/log_test_endpoint.py index 9332d71f8..26868a289 100644 --- a/monkey/monkey_island/cc/resources/test/test_log.py +++ b/monkey/monkey_island/cc/resources/test/log_test_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import database, mongo from monkey_island.cc.resources.auth.auth import jwt_required -class TestLog(flask_restful.Resource): +class LogTestEndpoint(flask_restful.Resource): @jwt_required def get(self): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/test/test_monkey.py b/monkey/monkey_island/cc/resources/test/monkey_test_endpoint.py similarity index 87% rename from monkey/monkey_island/cc/resources/test/test_monkey.py rename to monkey/monkey_island/cc/resources/test/monkey_test_endpoint.py index 5eddc61ac..903331280 100644 --- a/monkey/monkey_island/cc/resources/test/test_monkey.py +++ b/monkey/monkey_island/cc/resources/test/monkey_test_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class TestMonkey(flask_restful.Resource): +class MonkeyTestEndpoint(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/test/test_telemetry.py b/monkey/monkey_island/cc/resources/test/telemetry_test_endpoint.py similarity index 87% rename from monkey/monkey_island/cc/resources/test/test_telemetry.py rename to monkey/monkey_island/cc/resources/test/telemetry_test_endpoint.py index f929988ac..0321bb86b 100644 --- a/monkey/monkey_island/cc/resources/test/test_telemetry.py +++ b/monkey/monkey_island/cc/resources/test/telemetry_test_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class TestTelemetry(flask_restful.Resource): +class TelemetryTestEndpoint(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query")) From 86c4f9f63d36910f0eb17d82b81a2fdac932c3fc Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Apr 2021 10:42:04 +0530 Subject: [PATCH 5/8] Rename directory "test" to "blackbox" in monkey_island/cc/resources/ --- monkey/monkey_island/cc/app.py | 8 ++++---- .../cc/resources/{test => blackbox}/__init__.py | 0 .../cc/resources/{test => blackbox}/clear_caches.py | 0 .../cc/resources/{test => blackbox}/log_test_endpoint.py | 0 .../resources/{test => blackbox}/monkey_test_endpoint.py | 0 .../{test => blackbox}/telemetry_test_endpoint.py | 0 .../cc/resources/{test => blackbox}/utils/telem_store.py | 0 monkey/monkey_island/cc/resources/log.py | 2 +- monkey/monkey_island/cc/resources/monkey.py | 2 +- monkey/monkey_island/cc/resources/telemetry.py | 2 +- monkey/monkey_island/cc/services/infection_lifecycle.py | 2 +- 11 files changed, 8 insertions(+), 8 deletions(-) rename monkey/monkey_island/cc/resources/{test => blackbox}/__init__.py (100%) rename monkey/monkey_island/cc/resources/{test => blackbox}/clear_caches.py (100%) rename monkey/monkey_island/cc/resources/{test => blackbox}/log_test_endpoint.py (100%) rename monkey/monkey_island/cc/resources/{test => blackbox}/monkey_test_endpoint.py (100%) rename monkey/monkey_island/cc/resources/{test => blackbox}/telemetry_test_endpoint.py (100%) rename monkey/monkey_island/cc/resources/{test => blackbox}/utils/telem_store.py (100%) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 4cc37e269..564898845 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -12,6 +12,10 @@ from monkey_island.cc.resources.attack.attack_config import AttackConfiguration from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.auth.auth import Authenticate, init_jwt from monkey_island.cc.resources.auth.registration import Registration +from monkey_island.cc.resources.blackbox.clear_caches import ClearCaches +from monkey_island.cc.resources.blackbox.log_test_endpoint import LogTestEndpoint +from monkey_island.cc.resources.blackbox.monkey_test_endpoint import MonkeyTestEndpoint +from monkey_island.cc.resources.blackbox.telemetry_test_endpoint import TelemetryTestEndpoint from monkey_island.cc.resources.bootloader import Bootloader from monkey_island.cc.resources.client_run import ClientRun from monkey_island.cc.resources.edge import Edge @@ -36,10 +40,6 @@ from monkey_island.cc.resources.security_report import SecurityReport from monkey_island.cc.resources.T1216_pba_file_download import T1216PBAFileDownload from monkey_island.cc.resources.telemetry import Telemetry from monkey_island.cc.resources.telemetry_feed import TelemetryFeed -from monkey_island.cc.resources.test.clear_caches import ClearCaches -from monkey_island.cc.resources.test.log_test_endpoint import LogTestEndpoint -from monkey_island.cc.resources.test.monkey_test_endpoint import MonkeyTestEndpoint -from monkey_island.cc.resources.test.telemetry_test_endpoint import TelemetryTestEndpoint from monkey_island.cc.resources.version_update import VersionUpdate from monkey_island.cc.resources.zero_trust.finding_event import ZeroTrustFindingEvent from monkey_island.cc.resources.zero_trust.scoutsuite_auth.aws_keys import AWSKeys diff --git a/monkey/monkey_island/cc/resources/test/__init__.py b/monkey/monkey_island/cc/resources/blackbox/__init__.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/__init__.py rename to monkey/monkey_island/cc/resources/blackbox/__init__.py diff --git a/monkey/monkey_island/cc/resources/test/clear_caches.py b/monkey/monkey_island/cc/resources/blackbox/clear_caches.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/clear_caches.py rename to monkey/monkey_island/cc/resources/blackbox/clear_caches.py diff --git a/monkey/monkey_island/cc/resources/test/log_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/log_test_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/log_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/log_test_endpoint.py diff --git a/monkey/monkey_island/cc/resources/test/monkey_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/monkey_test_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/monkey_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/monkey_test_endpoint.py diff --git a/monkey/monkey_island/cc/resources/test/telemetry_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/telemetry_test_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/telemetry_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/telemetry_test_endpoint.py diff --git a/monkey/monkey_island/cc/resources/test/utils/telem_store.py b/monkey/monkey_island/cc/resources/blackbox/utils/telem_store.py similarity index 100% rename from monkey/monkey_island/cc/resources/test/utils/telem_store.py rename to monkey/monkey_island/cc/resources/blackbox/utils/telem_store.py diff --git a/monkey/monkey_island/cc/resources/log.py b/monkey/monkey_island/cc/resources/log.py index aae23fed3..126e1f697 100644 --- a/monkey/monkey_island/cc/resources/log.py +++ b/monkey/monkey_island/cc/resources/log.py @@ -6,7 +6,7 @@ from flask import request from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -from monkey_island.cc.resources.test.utils.telem_store import TestTelemStore +from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore from monkey_island.cc.services.log import LogService from monkey_island.cc.services.node import NodeService diff --git a/monkey/monkey_island/cc/resources/monkey.py b/monkey/monkey_island/cc/resources/monkey.py index 66dbd881a..7d8a18a98 100644 --- a/monkey/monkey_island/cc/resources/monkey.py +++ b/monkey/monkey_island/cc/resources/monkey.py @@ -7,7 +7,7 @@ from flask import request from monkey_island.cc.database import mongo from monkey_island.cc.models.monkey_ttl import create_monkey_ttl_document -from monkey_island.cc.resources.test.utils.telem_store import TestTelemStore +from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.edge.edge import EdgeService diff --git a/monkey/monkey_island/cc/resources/telemetry.py b/monkey/monkey_island/cc/resources/telemetry.py index 9bf2f7dda..15e7139a0 100644 --- a/monkey/monkey_island/cc/resources/telemetry.py +++ b/monkey/monkey_island/cc/resources/telemetry.py @@ -10,7 +10,7 @@ from common.common_consts.telem_categories import TelemCategoryEnum from monkey_island.cc.database import mongo from monkey_island.cc.models.monkey import Monkey from monkey_island.cc.resources.auth.auth import jwt_required -from monkey_island.cc.resources.test.utils.telem_store import TestTelemStore +from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore from monkey_island.cc.services.node import NodeService from monkey_island.cc.services.telemetry.processing.processing import process_telemetry diff --git a/monkey/monkey_island/cc/services/infection_lifecycle.py b/monkey/monkey_island/cc/services/infection_lifecycle.py index e921adc3e..476bc2a0e 100644 --- a/monkey/monkey_island/cc/services/infection_lifecycle.py +++ b/monkey/monkey_island/cc/services/infection_lifecycle.py @@ -4,7 +4,7 @@ from datetime import datetime from flask import jsonify from monkey_island.cc.database import mongo -from monkey_island.cc.resources.test.utils.telem_store import TestTelemStore +from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.node import NodeService from monkey_island.cc.services.reporting.report import ReportService From 6d43ce900c6e71cd419c5bc5cceb9db7dcb664b6 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Apr 2021 10:46:14 +0530 Subject: [PATCH 6/8] Rename blackbox test files under monkey_island/cc/resources/blackbox/ --- monkey/monkey_island/cc/app.py | 6 +++--- .../{log_test_endpoint.py => log_blackbox_endpoint.py} | 0 ...{monkey_test_endpoint.py => monkey_blackbox_endpoint.py} | 0 ...etry_test_endpoint.py => telemetry_blackbox_endpoint.py} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename monkey/monkey_island/cc/resources/blackbox/{log_test_endpoint.py => log_blackbox_endpoint.py} (100%) rename monkey/monkey_island/cc/resources/blackbox/{monkey_test_endpoint.py => monkey_blackbox_endpoint.py} (100%) rename monkey/monkey_island/cc/resources/blackbox/{telemetry_test_endpoint.py => telemetry_blackbox_endpoint.py} (100%) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 564898845..519d57877 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -13,9 +13,9 @@ from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.auth.auth import Authenticate, init_jwt from monkey_island.cc.resources.auth.registration import Registration from monkey_island.cc.resources.blackbox.clear_caches import ClearCaches -from monkey_island.cc.resources.blackbox.log_test_endpoint import LogTestEndpoint -from monkey_island.cc.resources.blackbox.monkey_test_endpoint import MonkeyTestEndpoint -from monkey_island.cc.resources.blackbox.telemetry_test_endpoint import TelemetryTestEndpoint +from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogTestEndpoint +from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyTestEndpoint +from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import TelemetryTestEndpoint from monkey_island.cc.resources.bootloader import Bootloader from monkey_island.cc.resources.client_run import ClientRun from monkey_island.cc.resources.edge import Edge diff --git a/monkey/monkey_island/cc/resources/blackbox/log_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/blackbox/log_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py diff --git a/monkey/monkey_island/cc/resources/blackbox/monkey_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/blackbox/monkey_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py diff --git a/monkey/monkey_island/cc/resources/blackbox/telemetry_test_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py similarity index 100% rename from monkey/monkey_island/cc/resources/blackbox/telemetry_test_endpoint.py rename to monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py From c10f2f690aa8075ce641f8d328e1e6f67ca9e7c0 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Apr 2021 11:18:00 +0530 Subject: [PATCH 7/8] Swimm: update exercise Add a simple Post Breach action (id: tbxb2cGgUiJQ8Btma0fp). --- .swm/tbxb2cGgUiJQ8Btma0fp.swm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.swm/tbxb2cGgUiJQ8Btma0fp.swm b/.swm/tbxb2cGgUiJQ8Btma0fp.swm index 9fda0cb20..d6a1b742b 100644 --- a/.swm/tbxb2cGgUiJQ8Btma0fp.swm +++ b/.swm/tbxb2cGgUiJQ8Btma0fp.swm @@ -92,7 +92,7 @@ "* \"enum\": [\"BackdoorUser\"],", "* \"title\": \"Back door user\",", "* \"safe\": True,", - "* \"info\": \"Attempts to create a new user on the system and delete it \" \"afterwards.\",", + "* \"info\": \"Attempts to create a new user on the system and delete it afterwards.\",", "* \"attack_techniques\": [\"T1136\"],", "* },", " {", @@ -113,7 +113,7 @@ "monkey/common/common_consts/post_breach_consts.py": "25e6679cb1623aae1a732deb05cc011a452743e3", "monkey/infection_monkey/post_breach/actions/add_user.py": "cae5a2428fa01b333a2e70365c9da1e189e31bc4", "monkey/monkey_island/cc/services/attack/technique_reports/T1136.py": "dfc5945a362b88c1135f4476526c6c82977b02ee", - "monkey/monkey_island/cc/services/config_schema/definitions/post_breach_actions.py": "2c1104bcbe3ba0f885907d9d00210bd658ce8f74" + "monkey/monkey_island/cc/services/config_schema/definitions/post_breach_actions.py": "086dc85693ae02ddfa106099245c0f155139805c" } } } From 025cb7851cbab1dbc037d4e63a21facb5ab12697 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Apr 2021 15:33:02 +0530 Subject: [PATCH 8/8] Rename blackbox endpoint classes to match filenames --- monkey/monkey_island/cc/app.py | 14 ++++++++------ .../cc/resources/blackbox/log_blackbox_endpoint.py | 2 +- .../resources/blackbox/monkey_blackbox_endpoint.py | 2 +- .../blackbox/telemetry_blackbox_endpoint.py | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 519d57877..7467c4bdd 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -13,9 +13,11 @@ from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.auth.auth import Authenticate, init_jwt from monkey_island.cc.resources.auth.registration import Registration from monkey_island.cc.resources.blackbox.clear_caches import ClearCaches -from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogTestEndpoint -from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyTestEndpoint -from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import TelemetryTestEndpoint +from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogBlackboxEndpoint +from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyBlackboxEndpoint +from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import ( + TelemetryBlackboxEndpoint, +) from monkey_island.cc.resources.bootloader import Bootloader from monkey_island.cc.resources.client_run import ClientRun from monkey_island.cc.resources.edge import Edge @@ -165,10 +167,10 @@ def init_api_resources(api): api.add_resource(AWSKeys, "/api/aws_keys") # Resources used by black box tests - api.add_resource(MonkeyTestEndpoint, "/api/test/monkey") + api.add_resource(MonkeyBlackboxEndpoint, "/api/test/monkey") api.add_resource(ClearCaches, "/api/test/clear_caches") - api.add_resource(LogTestEndpoint, "/api/test/log") - api.add_resource(TelemetryTestEndpoint, "/api/test/telemetry") + api.add_resource(LogBlackboxEndpoint, "/api/test/log") + api.add_resource(TelemetryBlackboxEndpoint, "/api/test/telemetry") def init_app(mongo_url): diff --git a/monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py index 26868a289..c101b567a 100644 --- a/monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py +++ b/monkey/monkey_island/cc/resources/blackbox/log_blackbox_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import database, mongo from monkey_island.cc.resources.auth.auth import jwt_required -class LogTestEndpoint(flask_restful.Resource): +class LogBlackboxEndpoint(flask_restful.Resource): @jwt_required def get(self): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py index 903331280..2957fd4b9 100644 --- a/monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py +++ b/monkey/monkey_island/cc/resources/blackbox/monkey_blackbox_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class MonkeyTestEndpoint(flask_restful.Resource): +class MonkeyBlackboxEndpoint(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query")) diff --git a/monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py b/monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py index 0321bb86b..5573e5152 100644 --- a/monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py +++ b/monkey/monkey_island/cc/resources/blackbox/telemetry_blackbox_endpoint.py @@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.resources.auth.auth import jwt_required -class TelemetryTestEndpoint(flask_restful.Resource): +class TelemetryBlackboxEndpoint(flask_restful.Resource): @jwt_required def get(self, **kw): find_query = json_util.loads(request.args.get("find_query"))