wordfence / wordfence-cli

Wordfence malware and vulnerability scanner command line utility.
https://www.wordfence.com/products/wordfence-cli/
GNU General Public License v3.0
100 stars 20 forks source link

File name filtering error #267

Closed akenion closed 1 month ago

akenion commented 1 month ago

When using the --include-files-pattern pattern parameter, the pattern is a string (str instance) but it's being used to match against bytes instances.

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/scanner.py", line 356, in run
    locator.locate()
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/scanner.py", line 268, in locate
    for path in self.search_directory(real_path):
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/scanner.py", line 247, in search_directory
    if not self.file_filter.filter(item_path):
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/filtering.py", line 32, in filter
    matched = condition.evaluate(path)
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/filtering.py", line 13, in evaluate
    return self.test(path)
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/filtering.py", line 102, in __call__
    return matches_regex(self.pattern, path)
  File "/home/alex/Defiant/wordfence-cli/wordfence/scanning/filtering.py", line 42, in matches_regex
    return regex.search(string) is not None
TypeError: cannot use a string pattern on a bytes-like object
davidnuzik commented 1 month ago

v4.0.3rc4 7/31/24

SUMMARY: QA validation PASSED. I was successfully able to reproduce with v4.0.2 then validate this is fixed in v4.0.3rc4

REPRODUCTION AND VALIDATION STEPS Reproduce: With v4.0.2, run a wordfence malware-scan like as follows: wordfence malware-scan <path> --include-files-pattern=.* -d I reproduce and get the same TypeError as described in the issue. Validate: Do the same but with v4.0.3rc4 rather than v4.0.2 and I encounter no issues and output appears as I would expect.