Skip to content

Commit

Permalink
Agent: Move ransomware readme constants to ransomware/consts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mssalvatore committed Jul 16, 2021
1 parent b1fe850 commit 07937d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 5 additions & 0 deletions monkey/infection_monkey/ransomware/consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pathlib import Path

README_SRC = Path(__file__).parent / "ransomware_readme.txt"
README_FILE_NAME = "README.txt"
README_SHA256_HASH = "e3d9343cbcce6097c83044327b00ead14b6e8e6aa0d411160610033a856032fc"
6 changes: 2 additions & 4 deletions monkey/infection_monkey/ransomware/ransomware_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
from pathlib import Path
from typing import Callable, List

from infection_monkey.ransomware.consts import README_FILE_NAME, README_SRC
from infection_monkey.ransomware.ransomware_config import RansomwareConfig
from infection_monkey.telemetry.file_encryption_telem import FileEncryptionTelem
from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger

LOG = logging.getLogger(__name__)

README_SRC = Path(__file__).parent / "ransomware_readme.txt"
README_DEST = "README.txt"


class RansomwarePayload:
def __init__(
Expand Down Expand Up @@ -39,7 +37,7 @@ def run_payload(self):
self._encrypt_files(file_list)

if self._config.readme_enabled:
self._leave_readme(README_SRC, self._config.target_directory / README_DEST)
self._leave_readme(README_SRC, self._config.target_directory / README_FILE_NAME)

def _find_files(self) -> List[Path]:
LOG.info(f"Collecting files in {self._config.target_directory}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
TEST_KEYBOARD_TXT,
)

from infection_monkey.ransomware.consts import README_FILE_NAME, README_SRC
from infection_monkey.ransomware.ransomware_config import RansomwareConfig
from infection_monkey.ransomware.ransomware_payload import (
README_DEST,
README_SRC,
RansomwarePayload,
)
from infection_monkey.ransomware.ransomware_payload import RansomwarePayload


@pytest.fixture
Expand Down Expand Up @@ -162,7 +159,7 @@ def test_readme_true(
ransomware_payload = build_ransomware_payload(ransomware_payload_config)

ransomware_payload.run_payload()
mock_leave_readme.assert_called_with(README_SRC, ransomware_test_data / README_DEST)
mock_leave_readme.assert_called_with(README_SRC, ransomware_test_data / README_FILE_NAME)


def test_no_readme_if_no_directory(
Expand Down

0 comments on commit 07937d7

Please sign in to comment.