From da18fcba6777173c2893e7cb04b8aaef3b949d16 Mon Sep 17 00:00:00 2001 From: mrigankanand Date: Tue, 2 Aug 2022 10:13:52 +0530 Subject: [PATCH 1/2] fix - kill network capture process if any container is killed --- core/load.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/load.py b/core/load.py index 44450340..922815bc 100644 --- a/core/load.py +++ b/core/load.py @@ -362,13 +362,16 @@ def wait_until_interrupt(virtual_machine_container_reset_factory_time_seconds, c # start containers based on selected modules start_containers(configuration) if not new_network_events_thread.is_alive(): - return error(messages["interrupt_application"]) + error(messages["interrupt_application"]) + return True + if containers_are_unhealthy(configuration): - return error( + error( "Interrupting the application because \"{0}\" container(s) is(are) not alive!".format( ", ".join(containers_are_unhealthy(configuration)) ) ) + return True if run_as_test: break except KeyboardInterrupt: @@ -884,6 +887,9 @@ def load_honeypot_engine(): ) # killed the network traffic capture process by ctrl + c... waiting to end. info(messages["killing_capture_process"]) + if exit_flag: + # Terminate the network capture process + network_traffic_capture_process.terminate() if run_as_test: network_traffic_capture_process.terminate() # without ci it will be terminate after a few seconds, it needs to kill the tshark and update pcap file collection From b38ed0fe1bb09426838e012386efc737f6c275f1 Mon Sep 17 00:00:00 2001 From: mrigankanand Date: Sat, 10 Sep 2022 23:30:12 +0530 Subject: [PATCH 2/2] update command to terminate thread when container is unhealthy or killed --- core/load.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/load.py b/core/load.py index 922815bc..fcf75b1e 100644 --- a/core/load.py +++ b/core/load.py @@ -363,15 +363,16 @@ def wait_until_interrupt(virtual_machine_container_reset_factory_time_seconds, c start_containers(configuration) if not new_network_events_thread.is_alive(): error(messages["interrupt_application"]) - return True - + new_network_events_thread.terminate() + break if containers_are_unhealthy(configuration): error( "Interrupting the application because \"{0}\" container(s) is(are) not alive!".format( ", ".join(containers_are_unhealthy(configuration)) ) ) - return True + new_network_events_thread.terminate() + break if run_as_test: break except KeyboardInterrupt: @@ -887,9 +888,6 @@ def load_honeypot_engine(): ) # killed the network traffic capture process by ctrl + c... waiting to end. info(messages["killing_capture_process"]) - if exit_flag: - # Terminate the network capture process - network_traffic_capture_process.terminate() if run_as_test: network_traffic_capture_process.terminate() # without ci it will be terminate after a few seconds, it needs to kill the tshark and update pcap file collection