Small changes

This commit is contained in:
Shreya 2020-07-12 00:06:06 +05:30
parent fa7cff755f
commit c77467079b
3 changed files with 7 additions and 10 deletions

View File

@ -3,6 +3,7 @@ from common.data.post_breach_consts import (
from monkey_island.cc.services.attack.technique_reports.pba_technique import \
PostBreachTechnique
__author__ = "shreyamalviya"

View File

@ -70,9 +70,10 @@ class AttackTechnique(object, metaclass=abc.ABCMeta):
'data.status': ScanStatus.SCANNED.value,
'data.technique': cls.tech_id}):
return ScanStatus.SCANNED.value
elif not AttackConfig.get_technique_values()[cls.tech_id]:
return ScanStatus.DISABLED.value
else:
return ScanStatus.DISABLED.value if not AttackConfig.get_technique_values()[cls.tech_id]\
else ScanStatus.UNSCANNED.value
return ScanStatus.UNSCANNED.value
@classmethod
def get_message_and_status(cls, status):
@ -91,6 +92,7 @@ class AttackTechnique(object, metaclass=abc.ABCMeta):
:param status: Enum from common/attack_utils.py integer value
:return: message string
"""
status = cls._check_status(status)
if status == ScanStatus.DISABLED.value:
return disabled_msg
if status == ScanStatus.UNSCANNED.value:
@ -141,7 +143,6 @@ class AttackTechnique(object, metaclass=abc.ABCMeta):
@classmethod
def _check_status(cls, status):
if status == ScanStatus.UNSCANNED.value:
return ScanStatus.DISABLED.value if not AttackConfig.get_technique_values()[cls.tech_id]\
else ScanStatus.UNSCANNED.value
if status == ScanStatus.UNSCANNED.value and not AttackConfig.get_technique_values()[cls.tech_id]:
return ScanStatus.DISABLED.value
return status

View File

@ -18,7 +18,6 @@ class PostBreachTechnique(AttackTechnique, metaclass=abc.ABCMeta):
@classmethod
def get_pba_query(cls, post_breach_action_names):
return [{'$match': {'telem_category': 'post_breach',
# 'data.name': post_breach_action_name}},
'$or': [{'data.name': pba_name} for pba_name in post_breach_action_names]}},
{'$project': {'_id': 0,
'machine': {'hostname': '$data.hostname',
@ -37,10 +36,6 @@ class PostBreachTechnique(AttackTechnique, metaclass=abc.ABCMeta):
status = (ScanStatus.USED.value if any(status) else ScanStatus.SCANNED.value)\
if status else ScanStatus.UNSCANNED.value
if status == ScanStatus.UNSCANNED.value and\
not AttackConfig.get_technique_values()[cls.tech_id]:
status = ScanStatus.DISABLED.value
data.update(cls.get_base_data_by_status(status))
data.update({'info': info})
return data