fix(sandbox): preserve workdir for shell command lists - #1
Closed
hsusul wants to merge 473 commits into
Closed
Conversation
… Chat Completions path (openai#4295)
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
Co-authored-by: abhay-codes07 <abhaysingh0293@gmail.com>
Co-authored-by: LeSingh1 <sshaurya914@gmail.com>
Co-authored-by: Henry Su <henrysu4707@gmail.com>
…as not persisted (openai#4698)
Co-authored-by: Warren <warren@ciridae.com>
Co-authored-by: Henry Su <henrysu4707@gmail.com> Co-authored-by: ayaangazali <ayaangazali.work@gmail.com>
Owner
Author
|
Superseded by upstream PR openai#4915. |
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.
This pull request fixes
exec_commandso the configured working directory applies to the complete POSIX shell command list.Root cause
The tool generated
cd <workdir> && <cmd>. Shell operators in<cmd>are parsed together with that&&, so a command list beginning with a background job can continue after the directory change in a way that runs later commands from the sandbox root. Ifcdfails, semicolon, newline, and background command lists can still execute from the wrong directory.Reproduction
With
workdir=projectandcmd="true; printf expected > marker", the old wrapper writesmarkerin the workspace root whenprojectis missing. With an existing directory andcmd="true & wait; printf expected > marker", the old wrapper also writes in the workspace root.Solution
The wrapper now emits
cd <workdir> || exitfollowed by the caller command on a separate shell line. This establishes the directory before parsing and executing the caller command list and exits before user commands when the directory is unavailable.Validation
ruff format, targetedruff check, andgit diff --check: passed.make typecheck: passed.tests/sandbox/test_runtime.py::test_remote_realpath_guard_fails_closed_on_symlink_cycleand one existing subprocess cleanup warning.Risk assessment
The change is limited to shell command construction for an already-supported
workdir. Path normalization, shell selection, user selection, default unscoped commands, and successful command exit behavior remain unchanged.