Common: Use IJSONSerializable interface for credentials
This commit is contained in:
parent
4bbcffabd3
commit
43387dc1a5
|
@ -7,6 +7,7 @@ from typing import Any, Mapping, MutableMapping, Sequence, Tuple
|
|||
from marshmallow import Schema, fields, post_load, pre_dump
|
||||
from marshmallow.exceptions import MarshmallowError
|
||||
|
||||
from ..utils import IJSONSerializable
|
||||
from . import (
|
||||
CredentialComponentType,
|
||||
InvalidCredentialComponentError,
|
||||
|
@ -116,7 +117,7 @@ class CredentialsSchema(Schema):
|
|||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Credentials:
|
||||
class Credentials(IJSONSerializable):
|
||||
identities: Tuple[ICredentialComponent]
|
||||
secrets: Tuple[ICredentialComponent]
|
||||
|
||||
|
@ -141,8 +142,8 @@ class Credentials:
|
|||
except MarshmallowError as err:
|
||||
raise InvalidCredentialsError(str(err))
|
||||
|
||||
@staticmethod
|
||||
def from_json(credentials: str) -> Credentials:
|
||||
@classmethod
|
||||
def from_json(cls, credentials: str) -> Credentials:
|
||||
"""
|
||||
Construct a Credentials object from a JSON string
|
||||
|
||||
|
@ -180,8 +181,8 @@ class Credentials:
|
|||
credentials_list = json.loads(credentials_array_json)
|
||||
return [Credentials.from_mapping(c) for c in credentials_list]
|
||||
|
||||
@staticmethod
|
||||
def to_json(credentials: Credentials) -> str:
|
||||
@classmethod
|
||||
def to_json(cls, credentials: Credentials) -> str:
|
||||
"""
|
||||
Serialize a Credentials object to JSON
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from .timer import Timer
|
||||
from .IJSONSerializable import IJSONSerializable
|
||||
|
|
|
@ -4,7 +4,6 @@ dead or is kept deliberately. Referencing these in a file like this makes sure t
|
|||
Vulture doesn't mark these as dead again.
|
||||
"""
|
||||
from infection_monkey.exploit.log4shell_utils.ldap_server import LDAPServerFactory
|
||||
from monkey_island.cc import app
|
||||
from monkey_island.cc.models import Report
|
||||
from monkey_island.cc.models.networkmap import Arc, NetworkMap
|
||||
from monkey_island.cc.repository.attack.IMitigationsRepository import IMitigationsRepository
|
||||
|
@ -207,6 +206,12 @@ _make_simulation # unused method (monkey/monkey_island/cc/models/simulation.py:
|
|||
|
||||
|
||||
# TODO DELETE AFTER RESOURCE REFACTORING
|
||||
|
||||
# https://github.com/jendrikseipp/vulture/issues/287
|
||||
# Both happen in common\utils\IJSONSerializable.py
|
||||
json_string
|
||||
class_object
|
||||
|
||||
NetworkMap
|
||||
Arc.dst_machine
|
||||
IMitigationsRepository.get_mitigations
|
||||
|
|
Loading…
Reference in New Issue