-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ransomware skip encrypt readme #1333
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1333 +/- ##
===========================================
+ Coverage 40.25% 40.31% +0.06%
===========================================
Files 474 475 +1
Lines 13860 13874 +14
===========================================
+ Hits 5579 5593 +14
Misses 8281 8281
Continue to review full report at Codecov.
|
if filepath.name != README_FILE_NAME: | ||
return True | ||
|
||
return get_file_sha256_hash(filepath) != README_SHA256_HASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it turns out that even on windows, the readme.txt dropped retains the unix line endings, good to know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I even opened the file in notepad, added a space, and saved it and the line endings were not changed. This will likely vary from editor to editor.
|
||
|
||
@pytest.fixture(scope="session") | ||
def stable_file(data_for_tests_dir) -> Path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a typehint that data_for_tests_dir
is a Path
as well. If we pass something else, the syntax of some_path / "some_file.txt"
will break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_for_tests_dir
isn't actually a Path in this case, it's a pytest fixture. There are type hints for fixtures, but you have to import them from a file that's intended to be private. pytest-dev/pytest#5981 (comment)
@@ -53,3 +55,12 @@ def test_directories_not_selected(ransomware_test_data, file_selector): | |||
selected_files = file_selector(ransomware_test_data) | |||
|
|||
assert (ransomware_test_data / SUBDIR / HELLO_TXT) not in selected_files | |||
|
|||
|
|||
def test_ransomware_readme_not_selected(ransomware_target, file_selector): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add a test where README.txt get's selected if contents are different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but maybe could be improved by adding a test that asserts that we encrypt/don't filter out the readme file if it's contents are not the same as our file's
b45cf6c
to
52412ab
Compare
What does this PR do?
Fixes #1304
PR Checklist
Was the CHANGELOG.md updated to reflect the changes?Was the documentation framework updated to reflect the changes?Testing Checklist
If applicable, add screenshots or log transcripts of the feature working