fix(env): safely quote ~/ subpaths in wrapped cd commands - #15394
Merged
Conversation
Contributor
🚨 CRITICAL Supply Chain Risk DetectedThis PR contains a pattern that has been used in real supply chain attacks. A maintainer must review the flagged code carefully before merging. 🚨 CRITICAL: Install-hook file added or modifiedThese files can execute code during package installation or interpreter startup. Files: Scanner only fires on high-signal indicators: .pth files, base64+exec/eval combos, subprocess with encoded commands, or install-hook files. Low-signal warnings were removed intentionally — if you're seeing this comment, the finding is worth inspecting. |
Contributor
|
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.
Salvage of #15098 by @Yukipukii1 onto current main.
Summary
BaseEnvironment._wrap_command()left~/...paths unquoted to preserve bash~expansion. Worked for bare~, but~/my repoemittedbuiltin cd ~/my repo || exit 126— bash split it into two args andcdfailed.Changes
tools/environments/base.py: new_quote_cwd_for_cd()helper. Bare~kept as-is;~/→$HOME;~/X→$HOME/'X'(shlex-quoted suffix).tests/tools/test_base_environment.py: regression coverage for~/my repoand~/.Validation
scripts/run_tests.sh tests/tools/test_base_environment.py— 17/17 passing. Reproduced the bug on main, confirmed the fix works in real bash.Closes #15098.