Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory approval for API file operations doesn't work properly when Butler runs on Windows #346

Open
mountaindude opened this issue Jan 28, 2022 · 1 comment

Comments

@mountaindude
Copy link
Collaborator

Describe the bug
When Butler runs on Windows the library used to manage paths will convert all paths to Windows style back-slash () notation.

For example, if the config file states that deletes should be allowed in directory ./dir1/dir2, this will behind the scenes be converted to .\dir1\dir2 when running Butler on Windows.

Another example would be a UNC path like \\server.my.domain\fileshare\dir1\dir2.
The config file could contain either that UNC string, or //server.my.domain/fileshare/dir1/dir2. Both are allowed (even though the second one is proper UNC syntax, of course!).
Internally both paths would be converted into \\server.my.domain\fileshare\dir1\dir2.

Then there is also code that is responsible for determining if a particular directory is a subdirectory of another directory.
In the example above this code would be used to determine if a file to be deleted \\server.my.domain\fileshare\dir1\dir2\dir3\file1.txt is in a sub-directory of the approved directory \\server.my.domain\fileshare\dir1\dir2.

The problem is that this code does not handle back-slash notation properly.
It does handle these scenarios correctly:
✅ Butler running on Linux, with an approved directory such as /data/dir1/dir2. A file /data/dir1/dir2/dir3/file2.txt is the correctly classified as being in a subdirectory of the approved directory.
✅ Butler running on Windows, with an approved directory such as \\server.my.domain\fileshare\dir1\dir2 or //server.my.domain/fileshare/dir1/dir2. A file \\server.my.domain\fileshare\dir1\dir2\file3.txt is then correctly classified as being in the approved directory. Note that file3.txt is in this case located in the approved directory itself, rather than in a subdirectory of the approved directory.

What does not work as intended is:
❌ Butler running on Windows, with an approved directory such as \\server.my.domain\fileshare\dir1\dir2 or //server.my.domain/fileshare/dir1/dir2. A file \\server.my.domain\fileshare\dir1\dir2\dir3\file4.txt would NOT be classified as residing in a subdirectory of the approved directory. This is a bug.

The code in question is found here.

Expected behavior
Linux and Windows paths should be possible when it comes to determining whether or not a file is in the subdirectory path of some other directory.

Also add test cases for this scenario.

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant