Skip to content

Fix false positives in blocklisted file extensions - #508

Open
martatorredev wants to merge 1 commit into
WordPress:trunkfrom
martatorredev:fix/504-file-extension-patterns
Open

martatorredev wants to merge 1 commit into
WordPress:trunkfrom
martatorredev:fix/504-file-extension-patterns

Conversation

@martatorredev

Copy link
Copy Markdown

Summary

Fixes #504.

This PR anchors seven blocklisted file-extension patterns to the end of filenames to prevent false positives.

Previously, filenames containing a blocklisted extension as a substring could be incorrectly flagged. For example, tokens.sys.shape.css matched the .sh pattern.

Changes

  • Add end-of-string anchors ($) to the .kpf, .sql, .lubith, .wie, .dat, .xml, and .sh patterns.
  • Preserve detection of files ending with these blocklisted extensions.

Testing

  • PHP syntax validation passed.
  • PHP_CodeSniffer passed.
  • 21 isolated regular-expression test cases passed.
  • 6 integration test cases using File_Check::check() passed.

Verified that blocklisted files such as deploy.sh, backup.sql, and config.xml are still detected, while filenames such as tokens.sys.shape.css and backup.sql.txt no longer produce false positives.

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.

Blocklisted file-extension patterns are unanchored, so ordinary filenames fail the check

1 participant