forked from p15670423/monkey
Common: Revert circular dependency in agent_configuration.py
This commit is contained in:
parent
91e8ce62db
commit
1252ad3b87
|
@ -16,7 +16,7 @@ from .agent_sub_configurations import (
|
||||||
PluginConfiguration,
|
PluginConfiguration,
|
||||||
PropagationConfiguration,
|
PropagationConfiguration,
|
||||||
)
|
)
|
||||||
from .utils import freeze_lists
|
from ..utils.code_utils import freeze_lists_in_dict
|
||||||
|
|
||||||
|
|
||||||
class InvalidConfigurationError(Exception):
|
class InvalidConfigurationError(Exception):
|
||||||
|
@ -59,7 +59,9 @@ class AgentConfiguration:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return AgentConfigurationSchema().load(config_mapping)
|
config_dict = AgentConfigurationSchema().load(config_mapping)
|
||||||
|
config_dict = freeze_lists_in_dict(config_dict)
|
||||||
|
return AgentConfiguration(**config_dict)
|
||||||
except MarshmallowError as err:
|
except MarshmallowError as err:
|
||||||
raise InvalidConfigurationError(str(err))
|
raise InvalidConfigurationError(str(err))
|
||||||
|
|
||||||
|
@ -74,7 +76,9 @@ class AgentConfiguration:
|
||||||
AgentConfiguration
|
AgentConfiguration
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return AgentConfigurationSchema().loads(config_json)
|
config_dict = AgentConfigurationSchema().loads(config_json)
|
||||||
|
config_dict = freeze_lists_in_dict(config_dict)
|
||||||
|
return AgentConfiguration(**config_dict)
|
||||||
except MarshmallowError as err:
|
except MarshmallowError as err:
|
||||||
raise InvalidConfigurationError(str(err))
|
raise InvalidConfigurationError(str(err))
|
||||||
|
|
||||||
|
@ -106,8 +110,3 @@ class AgentConfigurationSchema(Schema):
|
||||||
credential_collectors = fields.List(fields.Nested(PluginConfigurationSchema))
|
credential_collectors = fields.List(fields.Nested(PluginConfigurationSchema))
|
||||||
payloads = fields.List(fields.Nested(PluginConfigurationSchema))
|
payloads = fields.List(fields.Nested(PluginConfigurationSchema))
|
||||||
propagation = fields.Nested(PropagationConfigurationSchema)
|
propagation = fields.Nested(PropagationConfigurationSchema)
|
||||||
|
|
||||||
@post_load
|
|
||||||
@freeze_lists
|
|
||||||
def _make_agent_configuration(self, data, **kwargs):
|
|
||||||
return AgentConfiguration(**data)
|
|
||||||
|
|
Loading…
Reference in New Issue