chevah / compat

Chevah OS Compatibility Layer
Other
4 stars 1 forks source link

Fix path split for single quotes. #105

Closed adiroiban closed 3 years ago

adiroiban commented 3 years ago

Scope

This fix a critical bug in which path containing single quotes are not handled corretly.

The single quote is replaced for a path separator.

For example, with the old code a path line

/some/O`Reilly/file

was converted in 

/some/O/Reilly/file

Changes

Update the path split code and simplify it with explicit regrex escaping.

I have no idea why I have used %r there.

How to try and test the changes

reviewers: @danuker

Check that changes make sense.

For now this is a quick fix as this is urgent

In the future we should start using https://hypothesis.readthedocs.io/en/latest/index.html for unit testing in this low level libraries so that we can generate all possible characters and make sure path splinting works for them.

codecov[bot] commented 3 years ago

Codecov Report

Merging #105 (6c390a0) into master (1f6af3b) will decrease coverage by 1.41%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
- Coverage   89.52%   88.10%   -1.42%     
==========================================
  Files          61       61              
  Lines        7914     7920       +6     
  Branches      652      652              
==========================================
- Hits         7085     6978     -107     
- Misses        642      738      +96     
- Partials      187      204      +17     
Impacted Files Coverage Δ
chevah/compat/tests/elevated/test_system_users.py 91.26% <ø> (-3.18%) :arrow_down:
chevah/compat/posix_filesystem.py 92.99% <100.00%> (-0.43%) :arrow_down:
chevah/compat/tests/normal/test_filesystem.py 97.92% <100.00%> (-0.92%) :arrow_down:
chevah/compat/tests/normal/test_capabilities.py 79.45% <0.00%> (-17.30%) :arrow_down:
chevah/compat/tests/elevated/__init__.py 80.95% <0.00%> (-9.53%) :arrow_down:
chevah/compat/capabilities.py 63.15% <0.00%> (-7.90%) :arrow_down:
chevah/compat/helpers.py 53.33% <0.00%> (-6.67%) :arrow_down:
chevah/compat/administration.py 67.02% <0.00%> (-5.14%) :arrow_down:
chevah/compat/nt_capabilities.py 85.15% <0.00%> (-4.69%) :arrow_down:
... and 6 more