Island: Remove ScoutSuiteFinding
This commit is contained in:
parent
039a62a224
commit
b23360db37
|
@ -1,20 +0,0 @@
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from mongoengine import LazyReferenceField
|
|
||||||
|
|
||||||
from monkey_island.cc.models.zero_trust.finding import Finding
|
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails
|
|
||||||
|
|
||||||
|
|
||||||
class ScoutSuiteFinding(Finding):
|
|
||||||
# We put additional info into a lazy reference field, because this info should be only
|
|
||||||
# pulled when explicitly needed due to performance
|
|
||||||
details = LazyReferenceField(ScoutSuiteFindingDetails, required=True)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def save_finding(
|
|
||||||
test: str, status: str, detail_ref: ScoutSuiteFindingDetails
|
|
||||||
) -> ScoutSuiteFinding:
|
|
||||||
finding = ScoutSuiteFinding(test=test, status=status, details=detail_ref)
|
|
||||||
finding.save()
|
|
||||||
return finding
|
|
|
@ -1,13 +0,0 @@
|
||||||
from mongoengine import Document, EmbeddedDocumentListField
|
|
||||||
|
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_rule import ScoutSuiteRule
|
|
||||||
|
|
||||||
|
|
||||||
class ScoutSuiteFindingDetails(Document):
|
|
||||||
# SCHEMA
|
|
||||||
scoutsuite_rules = EmbeddedDocumentListField(document_type=ScoutSuiteRule, required=False)
|
|
||||||
|
|
||||||
def add_rule(self, rule: ScoutSuiteRule) -> None:
|
|
||||||
if rule not in self.scoutsuite_rules:
|
|
||||||
self.scoutsuite_rules.append(rule)
|
|
||||||
self.save()
|
|
|
@ -1,25 +0,0 @@
|
||||||
from mongoengine import DynamicField, EmbeddedDocument, IntField, ListField, StringField
|
|
||||||
|
|
||||||
from monkey_island.cc.services.zero_trust.scoutsuite.consts import rule_consts
|
|
||||||
|
|
||||||
|
|
||||||
class ScoutSuiteRule(EmbeddedDocument):
|
|
||||||
"""
|
|
||||||
This model represents ScoutSuite security rule check results:
|
|
||||||
how many resources break the security rule
|
|
||||||
security rule description and remediation and etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# SCHEMA
|
|
||||||
description = StringField(required=True)
|
|
||||||
path = StringField(required=True)
|
|
||||||
level = StringField(required=True, options=rule_consts.RULE_LEVELS)
|
|
||||||
items = ListField()
|
|
||||||
dashboard_name = StringField(required=True)
|
|
||||||
checked_items = IntField(min_value=0)
|
|
||||||
flagged_items = IntField(min_value=0)
|
|
||||||
service = StringField(required=True)
|
|
||||||
rationale = StringField(required=True)
|
|
||||||
remediation = StringField(required=False)
|
|
||||||
compliance = DynamicField(required=False)
|
|
||||||
references = ListField(required=False)
|
|
|
@ -1,4 +0,0 @@
|
||||||
RULE_LEVEL_DANGER = "danger"
|
|
||||||
RULE_LEVEL_WARNING = "warning"
|
|
||||||
|
|
||||||
RULE_LEVELS = (RULE_LEVEL_DANGER, RULE_LEVEL_WARNING)
|
|
|
@ -7,7 +7,6 @@ from common.common_consts import zero_trust_consts
|
||||||
from common.utils.exceptions import UnknownFindingError
|
from common.utils.exceptions import UnknownFindingError
|
||||||
from monkey_island.cc.models.zero_trust.finding import Finding
|
from monkey_island.cc.models.zero_trust.finding import Finding
|
||||||
from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding
|
from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
|
||||||
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_details_service import (
|
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_details_service import (
|
||||||
MonkeyZTDetailsService,
|
MonkeyZTDetailsService,
|
||||||
)
|
)
|
||||||
|
@ -55,7 +54,5 @@ class FindingService:
|
||||||
def _get_finding_details(finding: Finding) -> Union[dict, SON]:
|
def _get_finding_details(finding: Finding) -> Union[dict, SON]:
|
||||||
if type(finding) == MonkeyFinding:
|
if type(finding) == MonkeyFinding:
|
||||||
return MonkeyZTDetailsService.fetch_details_for_display(finding.details.id)
|
return MonkeyZTDetailsService.fetch_details_for_display(finding.details.id)
|
||||||
elif type(finding) == ScoutSuiteFinding:
|
|
||||||
return finding.details.fetch().to_mongo()
|
|
||||||
else:
|
else:
|
||||||
raise UnknownFindingError(f"Unknown finding type {str(type(finding))}")
|
raise UnknownFindingError(f"Unknown finding type {str(type(finding))}")
|
||||||
|
|
Loading…
Reference in New Issue