Skip to content

Conversation

@JeremyKuhne
Copy link
Member

NtQueryDirectoryFile should always be able to take filters as long as they are properly escaped for how we'll do our matching. The special directories . and .. get blocked, but anything outside of that should be fair game.

cc: @stephentoub

NtQueryDirectoryFile should always be able to take filters as long as they are properly escaped for how we'll do our matching. The special directories `.` and `..` get blocked, but anything outside of that should be fair game.

cc: @stephentoub
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how filter expressions are prepared for NtQueryDirectoryFile on Windows. Instead of conservatively rejecting patterns that might be unsafe for OS-level filtering, it now escapes special DOS wildcard characters to ensure any expression (except . and ..) can be safely passed to the OS.

Changes:

  • Adds expression preprocessing logic to escape special characters (\, ", <, >) for MatchType.Simple patterns
  • Replaces the conservative IsSafePatternForOSFilter check with a simple null check, allowing more patterns to use OS-level filtering
  • Removes the IsSafePatternForOSFilter method and its associated SearchValues helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants