Change property names. Add type hints

This commit is contained in:
Daniel Goldberg 2019-11-03 15:01:26 -05:00
parent 0044eb393b
commit 029c3bb24d
3 changed files with 8 additions and 9 deletions

View File

@ -3,8 +3,9 @@ from abc import ABCMeta, abstractproperty, abstractmethod
from infection_monkey.config import WormConfiguration from infection_monkey.config import WormConfiguration
class HostFinger(object, metaclass=ABCMeta): class HostFinger(metaclass=ABCMeta):
@abstractproperty @property
@abstractmethod
def _SCANNED_SERVICE(self): def _SCANNED_SERVICE(self):
pass pass
@ -18,9 +19,5 @@ class HostFinger(object, metaclass=ABCMeta):
raise NotImplementedError() raise NotImplementedError()
@staticmethod @staticmethod
def should_run(class_name): def should_run(class_name: str) -> bool:
"""
Decides if post breach action is enabled in config
:return: True if it needs to be ran, false otherwise
"""
return class_name in WormConfiguration.finger_classes return class_name in WormConfiguration.finger_classes

View File

@ -1,7 +1,8 @@
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
class HostScanner(object, metaclass=ABCMeta): class HostScanner(metaclass=ABCMeta):
@property
@abstractmethod @abstractmethod
def is_host_alive(self, host): def is_host_alive(self, host):
raise NotImplementedError() raise NotImplementedError()

View File

@ -1,11 +1,12 @@
import logging import logging
from typing import Sequence
from infection_monkey.utils.load_plugins import get_instances from infection_monkey.utils.load_plugins import get_instances
from infection_monkey.network.HostFinger import HostFinger from infection_monkey.network.HostFinger import HostFinger
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def get_fingerprint_instances(): def get_fingerprint_instances() -> Sequence[HostFinger]:
""" """
Returns the fingerprint objects according to configuration as a list Returns the fingerprint objects according to configuration as a list
:return: A list of HostFinger objects. :return: A list of HostFinger objects.