Minor style refactoring

This commit is contained in:
VakarisZ 2020-10-13 17:45:00 +03:00
parent eb5648dc0e
commit 24ac497eec
5 changed files with 16 additions and 32 deletions

View File

@ -30,9 +30,8 @@ def check_antivirus_existence(process_list_json, monkey_guid):
test_status = zero_trust_consts.STATUS_PASSED
else:
test_status = zero_trust_consts.STATUS_FAILED
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_ENDPOINT_SECURITY_EXISTS, status=test_status, events=events
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_ENDPOINT_SECURITY_EXISTS,
status=test_status, events=events)
def filter_av_processes(process_list):

View File

@ -8,15 +8,12 @@ COMM_AS_NEW_USER_SUCCEEDED_FORMAT = \
def check_new_user_communication(current_monkey, success, message):
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_COMMUNICATE_AS_NEW_USER,
# If the monkey succeeded to create a user, then the test failed.
status=zero_trust_consts.STATUS_FAILED if success else zero_trust_consts.STATUS_PASSED,
events=[
get_attempt_event(current_monkey),
get_result_event(current_monkey, message, success)
]
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_COMMUNICATE_AS_NEW_USER,
status=zero_trust_consts.STATUS_FAILED if success else zero_trust_consts.STATUS_PASSED,
events=[
get_attempt_event(current_monkey),
get_result_event(current_monkey, message, success)
])
def get_attempt_event(current_monkey):

View File

@ -55,16 +55,10 @@ def check_open_data_endpoints(telemetry_json):
event_type=zero_trust_consts.EVENT_TYPE_MONKEY_NETWORK
))
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_DATA_ENDPOINT_HTTP,
status=found_http_server_status,
events=events
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_DATA_ENDPOINT_HTTP,
status=found_http_server_status, events=events)
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_DATA_ENDPOINT_ELASTIC,
status=found_elastic_search_server,
events=events
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_DATA_ENDPOINT_ELASTIC,
status=found_elastic_search_server, events=events)
MonkeyFindingService.add_malicious_activity_to_timeline(events)

View File

@ -29,10 +29,7 @@ def check_machine_exploited(current_monkey, exploit_successful, exploiter, targe
)
status = zero_trust_consts.STATUS_FAILED
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_MACHINE_EXPLOITED,
status=status,
events=events
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_MACHINE_EXPLOITED, status=status,
events=events)
MonkeyFindingService.add_malicious_activity_to_timeline(events)

View File

@ -18,10 +18,7 @@ def check_tunneling_violation(tunnel_telemetry_json):
timestamp=tunnel_telemetry_json['timestamp']
)]
MonkeyFindingService.create_or_add_to_existing(
test=zero_trust_consts.TEST_TUNNELING,
status=zero_trust_consts.STATUS_FAILED,
events=tunneling_events
)
MonkeyFindingService.create_or_add_to_existing(test=zero_trust_consts.TEST_TUNNELING,
status=zero_trust_consts.STATUS_FAILED, events=tunneling_events)
MonkeyFindingService.add_malicious_activity_to_timeline(tunneling_events)