From ba947a6b3001730a2f78ed9d443a6072823f2b87 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 11 Jan 2021 11:43:01 +0200 Subject: [PATCH] "type" param renamed to "finding_type" in finding DAO Fixed bug, which happened due to type -> finding_type refactoring --- monkey/monkey_island/cc/models/zero_trust/finding.py | 4 ++-- .../monkey_island/cc/services/zero_trust/finding_service.py | 6 +++--- .../zero_trust/scoutsuite/scoutsuite_finding_service.py | 2 +- .../components/report-components/zerotrust/FindingsTable.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/monkey/monkey_island/cc/models/zero_trust/finding.py b/monkey/monkey_island/cc/models/zero_trust/finding.py index bad69bc95..7a6b924c8 100644 --- a/monkey/monkey_island/cc/models/zero_trust/finding.py +++ b/monkey/monkey_island/cc/models/zero_trust/finding.py @@ -34,7 +34,7 @@ class Finding(Document): # SCHEMA test = StringField(required=True, choices=zero_trust_consts.TESTS) status = StringField(required=True, choices=zero_trust_consts.ORDERED_TEST_STATUSES) - type = StringField(required=True, choices=zero_trust_consts.FINDING_TYPES) + finding_type = StringField(required=True, choices=zero_trust_consts.FINDING_TYPES) details = GenericLazyReferenceField(choices=[MonkeyFindingDetails, ScoutSuiteFindingDetails], required=True) # http://docs.mongoengine.org/guide/defining-documents.html#document-inheritance meta = {'allow_inheritance': True} @@ -54,7 +54,7 @@ class Finding(Document): temp_finding = Finding(test=test, status=status, details=detail_ref, - type=Finding._get_finding_type_by_details(detail_ref)) + finding_type=Finding._get_finding_type_by_details(detail_ref)) temp_finding.save() return temp_finding diff --git a/monkey/monkey_island/cc/services/zero_trust/finding_service.py b/monkey/monkey_island/cc/services/zero_trust/finding_service.py index 4d165da7e..618be9550 100644 --- a/monkey/monkey_island/cc/services/zero_trust/finding_service.py +++ b/monkey/monkey_island/cc/services/zero_trust/finding_service.py @@ -12,9 +12,9 @@ class FindingService: findings = list(Finding.objects) details = [] for i in range(len(findings)): - if findings[i].type == zero_trust_consts.MONKEY_FINDING: + if findings[i].finding_type == zero_trust_consts.MONKEY_FINDING: details = MonkeyDetailsService.fetch_details_for_display(findings[i].details.id) - elif findings[i].type == zero_trust_consts.SCOUTSUITE_FINDING: + elif findings[i].finding_type == zero_trust_consts.SCOUTSUITE_FINDING: details = findings[i].details.fetch().to_mongo() findings[i] = findings[i].to_mongo() findings[i] = FindingService.get_enriched_finding(findings[i]) @@ -30,6 +30,6 @@ class FindingService: 'test_key': finding['test'], 'pillars': test_info[zero_trust_consts.PILLARS_KEY], 'status': finding['status'], - 'type': finding['type'] + 'finding_type': finding['finding_type'] } return enriched_finding diff --git a/monkey/monkey_island/cc/services/zero_trust/scoutsuite/scoutsuite_finding_service.py b/monkey/monkey_island/cc/services/zero_trust/scoutsuite/scoutsuite_finding_service.py index 6f8e64e87..8424e61c9 100644 --- a/monkey/monkey_island/cc/services/zero_trust/scoutsuite/scoutsuite_finding_service.py +++ b/monkey/monkey_island/cc/services/zero_trust/scoutsuite/scoutsuite_finding_service.py @@ -12,7 +12,7 @@ class ScoutSuiteFindingService: @staticmethod # TODO add type hinting like finding: Union[SCOUTSUITE_FINDINGS]? def process_rule(finding, rule: ScoutSuiteRule): - existing_findings = Finding.objects(test=finding.test, type=zero_trust_consts.SCOUTSUITE_FINDING) + existing_findings = Finding.objects(test=finding.test, finding_type=zero_trust_consts.SCOUTSUITE_FINDING) assert (len(existing_findings) < 2), "More than one finding exists for {}".format(finding.test) if len(existing_findings) == 0: diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/FindingsTable.js b/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/FindingsTable.js index 1c908665a..ada0e08ba 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/FindingsTable.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/FindingsTable.js @@ -22,10 +22,10 @@ export class FindingsTable extends Component { { Header: 'Details', id: 'details', accessor: x => { - if (x.type === 'scoutsuite_finding') { + if (x.finding_type === 'scoutsuite_finding') { return ; - } else if (x.type === 'monkey_finding') { + } else if (x.finding_type === 'monkey_finding') { return