Island: Remove config type logic from new configuration resource

This commit is contained in:
Shreya Malviya 2022-06-21 14:31:23 -07:00
parent 5f253e79b3
commit 74bc55e077
1 changed files with 5 additions and 16 deletions

View File

@ -1,6 +1,5 @@
import json
from dataclasses import dataclass
from enum import Enum
from itertools import chain
from typing import Mapping
@ -13,11 +12,6 @@ from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.resources.request_authentication import jwt_required
class ConfigurationTypeEnum(Enum):
ISLAND = "island"
AGENT = "agent"
class ImportStatuses:
UNSAFE_OPTION_VERIFICATION_REQUIRED = "unsafe_options_verification_required"
INVALID_CONFIGURATION = "invalid_configuration"
@ -38,23 +32,18 @@ class ResponseContents:
class Configuration(AbstractResource):
urls = ["/api/configuration/<string:configuration_type>"]
urls = ["/api/configuration"]
def __init__(self, file_agent_configuration_repository: IAgentConfigurationRepository):
self._file_agent_configuration_repository = file_agent_configuration_repository
@jwt_required
def get(self, configuration_type: str):
# Q: 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:
def get(self):
configuration = self._file_agent_configuration_repository.get_configuration()
return jsonify(configuration=configuration)
@jwt_required
def post(self, configuration_type: str):
def post(self):
request_contents = json.loads(request.data)
configuration_json = json.loads(request_contents["config"])
Configuration._remove_metadata_from_config(configuration_json)