From ea02bec0b486384155c4a10681a27b3fb1248c36 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 24 Jun 2022 12:42:09 -0400 Subject: [PATCH] Common: Remove circular dependency in agent_configuration.py --- monkey/common/configuration/agent_configuration.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/monkey/common/configuration/agent_configuration.py b/monkey/common/configuration/agent_configuration.py index a1f2eb70c..8c5b88646 100644 --- a/monkey/common/configuration/agent_configuration.py +++ b/monkey/common/configuration/agent_configuration.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass from typing import List -from marshmallow import Schema, fields, post_load +from marshmallow import Schema, fields from .agent_sub_configuration_schemas import ( CustomPBAConfigurationSchema, @@ -28,11 +28,13 @@ class AgentConfiguration: @staticmethod def from_dict(dict_: dict): - return AgentConfigurationSchema().load(dict_) + config_dict = AgentConfigurationSchema().load(dict_) + return AgentConfiguration(**config_dict) @staticmethod def from_json(config_json: dict): - return AgentConfigurationSchema().loads(config_json) + config_dict = AgentConfigurationSchema().loads(config_json) + return AgentConfiguration(**config_dict) @staticmethod def to_json(config: AgentConfiguration) -> str: @@ -46,7 +48,3 @@ class AgentConfigurationSchema(Schema): credential_collectors = fields.List(fields.Nested(PluginConfigurationSchema)) payloads = fields.List(fields.Nested(PluginConfigurationSchema)) propagation = fields.Nested(PropagationConfigurationSchema) - - @post_load - def _make_agent_configuration(self, data, **kwargs): - return AgentConfiguration(**data)