Improved ZT report generation performance.

This commit is contained in:
VakarisZ 2020-04-30 16:17:54 +03:00
parent 8603d18879
commit 4dcae80a64
1 changed files with 5 additions and 4 deletions

View File

@ -9,13 +9,13 @@ class ZeroTrustService(object):
@staticmethod @staticmethod
def get_pillars_grades(): def get_pillars_grades():
pillars_grades = [] pillars_grades = []
all_findings = Finding.objects().exclude('events')
for pillar in zero_trust_consts.PILLARS: for pillar in zero_trust_consts.PILLARS:
pillars_grades.append(ZeroTrustService.__get_pillar_grade(pillar)) pillars_grades.append(ZeroTrustService.__get_pillar_grade(pillar, all_findings))
return pillars_grades return pillars_grades
@staticmethod @staticmethod
def __get_pillar_grade(pillar): def __get_pillar_grade(pillar, all_findings):
all_findings = Finding.objects()
pillar_grade = { pillar_grade = {
"pillar": pillar, "pillar": pillar,
zero_trust_consts.STATUS_FAILED: 0, zero_trust_consts.STATUS_FAILED: 0,
@ -147,7 +147,8 @@ class ZeroTrustService(object):
@staticmethod @staticmethod
def __get_status_of_single_pillar(pillar): def __get_status_of_single_pillar(pillar):
grade = ZeroTrustService.__get_pillar_grade(pillar) all_findings = Finding.objects().exclude('events')
grade = ZeroTrustService.__get_pillar_grade(pillar, all_findings)
for status in zero_trust_consts.ORDERED_TEST_STATUSES: for status in zero_trust_consts.ORDERED_TEST_STATUSES:
if grade[status] > 0: if grade[status] > 0:
return status return status