forked from p34709852/monkey
Agent: Extract code from try/except in _leave_readme_in_target_directory
This commit is contained in:
parent
fae0c8ded2
commit
3450ac93a3
|
@ -71,11 +71,11 @@ class Ransomware:
|
||||||
self._telemetry_messenger.send_telemetry(encryption_attempt)
|
self._telemetry_messenger.send_telemetry(encryption_attempt)
|
||||||
|
|
||||||
def _leave_readme_in_target_directory(self, interrupt: threading.Event):
|
def _leave_readme_in_target_directory(self, interrupt: threading.Event):
|
||||||
try:
|
if interrupt.is_set():
|
||||||
if interrupt.is_set():
|
logger.debug("Received a stop signal, skipping leave readme")
|
||||||
logger.debug("Received a stop signal, skipping leave readme")
|
return
|
||||||
return
|
|
||||||
|
|
||||||
|
try:
|
||||||
self._leave_readme(README_SRC, self._readme_file_path)
|
self._leave_readme(README_SRC, self._readme_file_path)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.warning(f"An error occurred while attempting to leave a README.txt file: {ex}")
|
logger.warning(f"An error occurred while attempting to leave a README.txt file: {ex}")
|
||||||
|
|
|
@ -117,7 +117,12 @@ def test_interrupt_while_encrypting(
|
||||||
mfe.assert_any_call(ransomware_test_data / HELLO_TXT)
|
mfe.assert_any_call(ransomware_test_data / HELLO_TXT)
|
||||||
|
|
||||||
|
|
||||||
def test_no_readme_after_interrupt(ransomware, interrupt, mock_leave_readme):
|
def test_no_readme_after_interrupt(
|
||||||
|
ransomware_options, build_ransomware, interrupt, mock_leave_readme
|
||||||
|
):
|
||||||
|
ransomware_options.readme_enabled = True
|
||||||
|
ransomware = build_ransomware(ransomware_options)
|
||||||
|
|
||||||
interrupt.set()
|
interrupt.set()
|
||||||
ransomware.run(interrupt)
|
ransomware.run(interrupt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue