forked from p15670423/monkey
More simple ZT performance improvements and profiler decorator bugfix
This commit is contained in:
parent
9be8d4af1b
commit
7a13e71588
|
@ -65,7 +65,7 @@ class ZeroTrustService(object):
|
||||||
worst_status = zero_trust_consts.STATUS_UNEXECUTED
|
worst_status = zero_trust_consts.STATUS_UNEXECUTED
|
||||||
all_statuses = set()
|
all_statuses = set()
|
||||||
for test in principle_tests:
|
for test in principle_tests:
|
||||||
all_statuses |= set(Finding.objects(test=test).distinct("status"))
|
all_statuses |= set(Finding.objects(test=test).exclude('events').distinct("status"))
|
||||||
|
|
||||||
for status in all_statuses:
|
for status in all_statuses:
|
||||||
if zero_trust_consts.ORDERED_TEST_STATUSES.index(status) \
|
if zero_trust_consts.ORDERED_TEST_STATUSES.index(status) \
|
||||||
|
@ -78,7 +78,7 @@ class ZeroTrustService(object):
|
||||||
def __get_tests_status(principle_tests):
|
def __get_tests_status(principle_tests):
|
||||||
results = []
|
results = []
|
||||||
for test in principle_tests:
|
for test in principle_tests:
|
||||||
test_findings = Finding.objects(test=test)
|
test_findings = Finding.objects(test=test).exclude('events')
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"test": zero_trust_consts.TESTS_MAP[test][zero_trust_consts.TEST_EXPLANATION_KEY],
|
"test": zero_trust_consts.TESTS_MAP[test][zero_trust_consts.TEST_EXPLANATION_KEY],
|
||||||
|
|
|
@ -6,12 +6,12 @@ PROFILER_LOG_DIR = "./profiler_logs/"
|
||||||
|
|
||||||
|
|
||||||
def profile(sort_args=['cumulative'], print_args=[100]):
|
def profile(sort_args=['cumulative'], print_args=[100]):
|
||||||
profiler = Profile()
|
|
||||||
|
|
||||||
def decorator(fn):
|
def decorator(fn):
|
||||||
def inner(*args, **kwargs):
|
def inner(*args, **kwargs):
|
||||||
result = None
|
result = None
|
||||||
try:
|
try:
|
||||||
|
profiler = Profile()
|
||||||
result = profiler.runcall(fn, *args, **kwargs)
|
result = profiler.runcall(fn, *args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue