Skip to content

Conversation

ilija-lazoroski
Copy link
Contributor

@ilija-lazoroski ilija-lazoroski commented Jul 9, 2021

What does this PR do?

Fixes first task of #1287 . If we don't specify a directory, the readme should not be left.

image

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by {Running the Monkey locally with relevant config/running Island/...}

  • If applicable, add screenshots or log transcripts of the feature working

Explain Changes

Are the commit messages enough? If not, elaborate.

Comment on lines 249 to 259
def test_no_readme_if_no_directory(
build_ransomware_payload, ransomware_payload_config, ransomware_target
):
ransomware_payload_config["encryption"]["enabled"] = True
ransomware_payload_config["encryption"]["directories"]["linux_target_dir"] = ""
ransomware_payload_config["encryption"]["directories"]["windows_target_dir"] = ""
ransomware_payload_config["other_behaviors"]["readme"] = True
ransomware_payload = build_ransomware_payload(ransomware_payload_config)

ransomware_payload.run_payload()
assert not Path(ransomware_target / README_DEST).exists()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With an empty target directory, there's no reason to think that a readme would be left in ransomware_target/. From the test's perspective, it's very unpredictable where RansomwarePayload might leave the file. It depends on how we're processing the target directory and how that code handles an empty path. This assert is not sufficient to verify that no readme file is left on the system.

Take a look at test_readme_already_exists(). This test needs to basically do the same thing, which is to assert that no attempt at copying the file is made.

@codecov
Copy link

codecov bot commented Jul 9, 2021

Codecov Report

Merging #1309 (8b5091d) into develop (fb50ba1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 8b5091d differs from pull request most recent head eb36869. Consider uploading reports for the commit eb36869 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1309   +/-   ##
========================================
  Coverage    30.86%   30.87%           
========================================
  Files          454      454           
  Lines        13544    13545    +1     
========================================
+ Hits          4181     4182    +1     
  Misses        9363     9363           
Impacted Files Coverage Δ
...key_island/cc/services/config_schema/ransomware.py 100.00% <ø> (ø)
.../infection_monkey/ransomware/ransomware_payload.py 96.34% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb50ba1...eb36869. Read the comment docs.

@mssalvatore mssalvatore force-pushed the 1287/ransomware-readme-config-dirs branch from 8b5091d to eb36869 Compare July 9, 2021 19:46
@mssalvatore mssalvatore merged commit af739b6 into develop Jul 9, 2021
@mssalvatore mssalvatore deleted the 1287/ransomware-readme-config-dirs branch July 9, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants