From 5dd27eeea535e6250f241a8fb3d22816124630d4 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Mon, 20 Jun 2022 19:50:38 -0700 Subject: [PATCH] Island: Add definition for GET in new Configuration resource --- .../cc/resources/configuration.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/resources/configuration.py b/monkey/monkey_island/cc/resources/configuration.py index 79f1d2a0c..055fe5db1 100644 --- a/monkey/monkey_island/cc/resources/configuration.py +++ b/monkey/monkey_island/cc/resources/configuration.py @@ -1,13 +1,26 @@ +from enum import Enum +from flask import jsonify, request + from monkey_island.cc.resources.AbstractResource import AbstractResource from monkey_island.cc.resources.request_authentication import jwt_required +from monkey_island.cc.repository import FileAgentConfigurationRepository + +class ConfigurationTypeEnum(Enum): + ISLAND = "island" + AGENT = "agent" class Configuration(AbstractResource): - urls = ["/api/configuration"] + urls = ["/api/configuration/"] @jwt_required - def get(self): - pass + def get(self, configuration_type: str): + # we probably still need this because of credential fields, HTTP ports, etc in the config? + if configuration_type == ConfigurationTypeEnum.ISLAND: + pass + elif configuration_type == ConfigurationTypeEnum.AGENT: + configuration = FileAgentConfigurationRepository.get_configuration() + return jsonify(configuration=configuration) @jwt_required def post(self):