-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Description
FileSystemGlobbing only works with relative paths, if you supply absolute paths, they are not matched. This is problematic if you allow users to supply files through commandline to your application. As a user you would expect you can specify absolute paths, relative paths (both optionally with globbing).
Reproduction Steps
var dllMatcher = new Matcher();
dllMatcher.AddInclude("C:\\Windows\\*.exe"); // absolute
dllMatcher.AddInclude("*.exe"); // relative
var results = dllMatcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(Environment.CurrentDirectory)));
// results does not contain anything from C:\Windows
Expected behavior
When patterns are specifying absolute paths, it should match results outside the given base directory.
Actual behavior
Only files within the given base directory are considered as candidates and therefore any absolute file paths supplied, are not included in the result.
Regression?
Unknown.
Known Workarounds
No known one.
Configuration
Which version of .NET is the code running on?
.net 6.0
What OS and version, and what distro if applicable?
Edition Windows 10 Enterprise
Version 20H2
Installed on 25.09.2020
OS build 19042.1348
Experience Windows Feature Experience Pack 120.2212.3920.0
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
No it is not.
If you're using Blazor, which web browser(s) do you see this issue in?
Not applicable.
Other information
It might imply a security risk to allow globbing outside the base path so there might be a need for a setting.
From what I've seen the logic in the globbing is:
- Enumerate candidates from the input directory
- Match them against the globbing patterns.
This is likely where we need to extend/adapt the logic in a way that respects potentially global paths.