forked from p15670423/monkey
Island: Remove logic to remove/add config metadata in new configuration resource
This commit is contained in:
parent
ec710d9e5f
commit
142eed72ac
|
@ -1,12 +1,9 @@
|
|||
import json
|
||||
from itertools import chain
|
||||
from typing import Mapping
|
||||
|
||||
import marshmallow
|
||||
from flask import jsonify, make_response, request
|
||||
|
||||
from common.configuration.agent_configuration import AgentConfigurationSchema
|
||||
from common.configuration.default_agent_configuration import DEFAULT_AGENT_CONFIGURATION
|
||||
from monkey_island.cc.repository import IAgentConfigurationRepository
|
||||
from monkey_island.cc.resources.AbstractResource import AbstractResource
|
||||
from monkey_island.cc.resources.request_authentication import jwt_required
|
||||
|
@ -23,26 +20,12 @@ class AgentConfiguration(AbstractResource):
|
|||
def get(self):
|
||||
configuration = self._agent_configuration_repository.get_configuration()
|
||||
configuration_json = self._schema.dumps(configuration)
|
||||
# for when the agent requests the config; it needs the exploiters' metadata
|
||||
# Q: but this'll cause issues when the frontend requests the config?
|
||||
AgentConfiguration._add_metadata_to_config(configuration_json)
|
||||
return jsonify(configuration_json=configuration_json)
|
||||
|
||||
@staticmethod
|
||||
def _add_metadata_to_config(configuration_json):
|
||||
for exploiter_type in ["brute_force", "vulnerability"]:
|
||||
for exploiter in configuration_json["propagation"]["exploitation"][exploiter_type]:
|
||||
# there has to be a better way to do this
|
||||
if "supported_os" not in exploiter:
|
||||
exploiter["supported_os"] = DEFAULT_AGENT_CONFIGURATION["propagation"][
|
||||
"exploitation"
|
||||
][exploiter_type]["supported_os"]
|
||||
|
||||
@jwt_required
|
||||
def post(self):
|
||||
request_contents = json.loads(request.data)
|
||||
configuration_json = json.loads(request_contents["config"])
|
||||
AgentConfiguration._remove_metadata_from_config(configuration_json)
|
||||
|
||||
try:
|
||||
configuration_object = self._schema.loads(configuration_json)
|
||||
|
@ -56,12 +39,3 @@ class AgentConfiguration(AbstractResource):
|
|||
},
|
||||
400,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _remove_metadata_from_config(configuration_json: Mapping):
|
||||
for exploiter in chain(
|
||||
configuration_json["propagation"]["exploitation"]["brute_force"],
|
||||
configuration_json["propagation"]["exploitation"]["vulnerability"],
|
||||
):
|
||||
if "supported_os" in exploiter:
|
||||
del exploiter["supported_os"]
|
||||
|
|
Loading…
Reference in New Issue