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

View File

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

View File

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