Skip to content
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

Fix bug in WER plugin caused by special characters in field name #544

Conversation

Poeloe
Copy link
Contributor

@Poeloe Poeloe commented Feb 19, 2024

(DIS-2507)

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (fde5578) 73.98% compared to head (8047efa) 73.96%.

Files Patch % Lines
dissect/target/plugins/os/windows/wer.py 85.71% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #544      +/-   ##
==========================================
- Coverage   73.98%   73.96%   -0.02%     
==========================================
  Files         284      284              
  Lines       23521    23538      +17     
==========================================
+ Hits        17401    17409       +8     
- Misses       6120     6129       +9     
Flag Coverage Δ
unittests 73.96% <85.71%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Poeloe Poeloe force-pushed the fix/fix-bug-in-wer-plugin-caused-by-special-characters-in-field-name branch from b3c4225 to 2f51dae Compare February 19, 2024 12:10
for pattern in camel_case_patterns:
key = pattern.sub(r"\1_\2", key)

# Keep only basic characters in key
key = re.sub(r"[^a-zA-Z0-9_]", "", key)
Copy link
Contributor

@cecinestpasunepipe cecinestpasunepipe Feb 19, 2024

Choose a reason for hiding this comment

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

I foresee two possibly unwanted results:

  1. The key becomes empty ("невидимый")
  2. Or you might end up with duplicate keys (áErreur, éErreur)*
  • 'lowercasing' might also cause this

If that is no problem, then it does not matter of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True! Changed the code a bit around to be able to warn the user when these edge cases happen. I chose for a warning, because I don't think it's worth it to fully handle these edge cases. But please let me know if you think differently about this.

@Poeloe Poeloe merged commit 67b94ba into main Feb 21, 2024
17 of 18 checks passed
@Poeloe Poeloe deleted the fix/fix-bug-in-wer-plugin-caused-by-special-characters-in-field-name branch February 21, 2024 15:15
Poeloe added a commit that referenced this pull request Feb 29, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
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