Zero Trust finding saving method refactored to remove code duplication between children

This commit is contained in:
VakarisZ 2021-02-11 16:53:19 +02:00
parent e96ee305fb
commit 25704b74c9
3 changed files with 6 additions and 26 deletions

View File

@ -5,8 +5,6 @@ Define a Document Schema for Zero Trust findings.
from __future__ import annotations
import abc
from mongoengine import Document, GenericLazyReferenceField, StringField
import common.common_consts.zero_trust_consts as zero_trust_consts
@ -45,9 +43,11 @@ class Finding(Document):
details = GenericLazyReferenceField(required=True)
# Creation methods
@staticmethod
@abc.abstractmethod
def save_finding(test: str,
@classmethod
def save_finding(cls,
test: str,
status: str,
detail_ref) -> Finding:
pass
finding = cls(test=test, status=status, details=detail_ref)
finding.save()
return finding

View File

@ -6,13 +6,3 @@ from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFind
class MonkeyFinding(Finding):
details = LazyReferenceField(MonkeyFindingDetails, required=True)
@staticmethod
def save_finding(test: str,
status: str,
detail_ref: MonkeyFindingDetails) -> Finding:
monkey_finding = MonkeyFinding(test=test,
status=status,
details=detail_ref)
monkey_finding.save()
return monkey_finding

View File

@ -6,13 +6,3 @@ from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutS
class ScoutSuiteFinding(Finding):
details = LazyReferenceField(ScoutSuiteFindingDetails, required=True)
@staticmethod
def save_finding(test: str,
status: str,
detail_ref: ScoutSuiteFindingDetails) -> Finding:
scoutsuite_finding = ScoutSuiteFinding(test=test,
status=status,
details=detail_ref)
scoutsuite_finding.save()
return scoutsuite_finding