Common: Add PluginConfiguration

This commit is contained in:
Mike Salvatore 2022-06-16 14:57:50 -04:00
parent 660c1421c0
commit c79f62e682
5 changed files with 40 additions and 0 deletions

View File

View File

@ -0,0 +1 @@
from .agent_configuration import PluginConfiguration, PluginConfigurationSchema

View File

@ -0,0 +1,21 @@
from dataclasses import dataclass
from marshmallow import RAISE, Schema, fields, post_load
@dataclass(frozen=True)
class PluginConfiguration:
name: str
options: dict
class PluginConfigurationSchema(Schema):
class Meta:
unknown = RAISE
name = fields.Str()
options = fields.Mapping()
@post_load
def make_plugin_configuration(self, data, **kwargs):
return PluginConfiguration(**data)

View File

@ -0,0 +1,12 @@
from common.configuration import PluginConfigurationSchema
def test_build_plugin_configuration():
name = "bond"
options = {"gun": "Walther PPK", "car": "Aston Martin DB5"}
pcs = PluginConfigurationSchema()
pc = pcs.load({"name": name, "options": options})
assert pc.name == name
assert pc.options == options

View File

@ -183,6 +183,12 @@ architecture # unused variable (monkey/infection_monkey/exploit/caching_agent_r
response_code # unused variable (monkey/monkey_island/cc/services/aws/aws_command_runner.py:26)
# Agent Configuration
Meta # unused class(monkey/common/configuration/agent_configuration.py:13)
unknown # unused variable(monkey/common/configuration/agent_configuration.py:14)
make_plugin_configuration # unused method(monkey/common/configuration/agent_configuration.py:19)
# TODO DELETE AFTER RESOURCE REFACTORING
NetworkMap
Arc.dst_machine