From 6314ddd71ad0efbc6368e23e3a8b3270400cc17e Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Fri, 10 Jun 2022 13:48:05 +0200 Subject: [PATCH] Island: Remove PATCH method from api/agent * Remove config_error from monkey document --- monkey/monkey_island/cc/models/monkey.py | 1 - monkey/monkey_island/cc/resources/monkey.py | 23 --------------------- 2 files changed, 24 deletions(-) diff --git a/monkey/monkey_island/cc/models/monkey.py b/monkey/monkey_island/cc/models/monkey.py index 653972456..a106f9965 100644 --- a/monkey/monkey_island/cc/models/monkey.py +++ b/monkey/monkey_island/cc/models/monkey.py @@ -51,7 +51,6 @@ class Monkey(Document): # (even with required=False of null=True). # See relevant issue: https://github.com/MongoEngine/mongoengine/issues/1904 parent = ListField(ListField(DynamicField())) - config_error = BooleanField() critical_services = ListField(StringField()) pba_results = ListField() ttl_ref = ReferenceField(MonkeyTtl) diff --git a/monkey/monkey_island/cc/resources/monkey.py b/monkey/monkey_island/cc/resources/monkey.py index 4438733f6..411c383d2 100644 --- a/monkey/monkey_island/cc/resources/monkey.py +++ b/monkey/monkey_island/cc/resources/monkey.py @@ -27,29 +27,6 @@ class Monkey(AbstractResource): def get(self): return {"config": ConfigService.format_flat_config_for_agent()} - # Used by monkey. can't secure. - @TestTelemStore.store_exported_telem - def patch(self, guid): - - # TODO: This endpoint appears to be doing 3 things, although only one of them is used - # (config_error). The WormConfiguration will be removed in #1960. We should consider - # removing this endpoint - monkey_json = json.loads(request.data) - update = {"$set": {"modifytime": datetime.now()}} - monkey = NodeService.get_monkey_by_guid(guid) - if "config_error" in monkey_json: - update["$set"]["config_error"] = monkey_json["config_error"] - - if "tunnel" in monkey_json: - tunnel_host_ip = monkey_json["tunnel"].split(":")[-2].replace("//", "") - NodeService.set_monkey_tunnel(monkey["_id"], tunnel_host_ip) - - ttl = create_monkey_ttl_document(DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS) - update["$set"]["ttl_ref"] = ttl.id - - # API Spec: What is this returning? Check that it follows rules. - return mongo.db.monkey.update({"_id": monkey["_id"]}, update, upsert=False) - # Used by monkey. can't secure. # Called on monkey wakeup to initialize local configuration @TestTelemStore.store_exported_telem