fix(file_tools): normalize path separator before device-path blocklist compare (#69373) - #69401
Closed
Enough1122 wants to merge 1 commit into
Closed
Enough1122 wants to merge 1 commit into
Enough1122 wants to merge 1 commit into
Conversation
…t compare (NousResearch#69373) On Windows, os.path.normpath preserves backslashes which never match the POSIX strings in _BLOCKED_DEVICE_PATHS. The entire device/fd/proc read-guard — including the /proc/*/environ secret-leak family added for NousResearch#4427 — was a silent no-op on Windows, and read_file(/dev/zero) genuinely hung via Git Bash's MSYS /dev/zero emulation. Normalize to forward slashes (POSIX form) before the blocklist compare so the check is cross-platform. Fixes NousResearch#69373. Refs NousResearch#4427.
Contributor
Author
|
cc @teknium1 @alt-glitch — fix pushed for #69373. Verification on head
Implementation summary:
NOT doing: not changing the blocklist contents, not adding platform-specific branches, no public API change. Ready for maintainer review. — written by Hermes Agent on behalf of @Enough1122 |
Contributor
Author
|
Closing this stale PR for now: it has had no substantive human review/action and is unlikely to be merged in its current state. Reopen or submit a fresh PR if the issue remains relevant. |
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.
Summary
_is_blocked_device_path()normalizes withos.path.normpathand compares against POSIX strings. On Windows,normpath("/dev/zero")returns"\dev\zero"(backslashes) which never matches the POSIX"/dev/zero". The same applies to thestartswith("/proc/")checks. The entire device/fd/proc read-guard was a silent no-op on Windows, andread_file("/dev/zero")genuinely hung via Git Bash's MSYS/dev/zeroemulation.Fix
Add
_normalize_for_blocklist()helper that converts to forward slashes afteros.path.normpath, then use it in_is_blocked_device_path(). The fix is cross-platform (same code path on all platforms, no platform-specific branches).Files touched
tools/file_tools.py— add_normalize_for_blocklist()helper + one-line change in_is_blocked_device_path()tests/tools/test_file_read_guards.py— addTestWindowsBlocklistSeparatorNormalizewith 4 regression testsTest plan
What this does NOT do
Fixes #69373. Refs #4427.
— written by Hermes Agent on behalf of @Enough1122