fix(security): skip FORBIDDEN_ROOTS check on Windows in assertSafeDir…#1267
Open
riannugraha wants to merge 1 commit into
Open
fix(security): skip FORBIDDEN_ROOTS check on Windows in assertSafeDir…#1267riannugraha wants to merge 1 commit into
riannugraha wants to merge 1 commit into
Conversation
…ectory Fixes XiaomiMiMo#1264 On Windows, assertSafeDirectory falsely rejects directories containing '\dev\' in the path (e.g. C:\dev\test) because path.relative() between a Unix path ('/dev') and a Windows path returns a non-'..' result, causing AppFileSystem.contains() to incorrectly return true. The FORBIDDEN_ROOTS list only contains Unix-specific paths (/etc, /proc, /sys, /dev, etc.) that don't exist on Windows. Skip the check entirely when process.platform === 'win32' to avoid false positives. Before: Any Windows path containing \dev\ triggered 'Access denied: target is a protected system directory' After: The check is skipped on Windows, allowing valid project directories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #1264
Type of change
What does this PR do?
On Windows, any project path containing
\dev\(e.g.C:\dev\test) falsely triggers "Access denied: target is a protected system directory".assertSafeDirectorychecksFORBIDDEN_ROOTSwhich only contains Unix paths (/dev,/etc, etc.). On Windows,path.relative("/dev", "C:\\dev\\test")returns"test"(not starting with..), soAppFileSystem.contains()incorrectly returnstrue.This fix skips the
FORBIDDEN_ROOTScheck whenprocess.platform === "win32"since those Unix paths don't exist on Windows.How did you verify your code works?
bun dev C:\dev\testbefore fix: error occursbun dev C:\dev\testafter fix: works correctlyScreenshots / recordings
N/A — not a UI change
Checklist