forked from p15670423/monkey
Island: Add logic to add metadata to config in new configuration resource's GET
This commit is contained in:
parent
922495785c
commit
d861def86c
|
@ -7,6 +7,7 @@ import marshmallow
|
||||||
from flask import jsonify, request
|
from flask import jsonify, request
|
||||||
|
|
||||||
from common.configuration.agent_configuration import AgentConfigurationSchema
|
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.repository import IAgentConfigurationRepository
|
||||||
from monkey_island.cc.resources.AbstractResource import AbstractResource
|
from monkey_island.cc.resources.AbstractResource import AbstractResource
|
||||||
from monkey_island.cc.resources.request_authentication import jwt_required
|
from monkey_island.cc.resources.request_authentication import jwt_required
|
||||||
|
@ -37,7 +38,21 @@ class AgentConfiguration(AbstractResource):
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def get(self):
|
def get(self):
|
||||||
configuration = self._agent_configuration_repository.get_configuration()
|
configuration = self._agent_configuration_repository.get_configuration()
|
||||||
return jsonify(configuration=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
|
@jwt_required
|
||||||
def post(self):
|
def post(self):
|
||||||
|
|
Loading…
Reference in New Issue