fix(#1649): add UploadFile for file-to-file sandbox upload semantics - #1651
fix(#1649): add UploadFile for file-to-file sandbox upload semantics#1651fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
Site previewPreview: https://4ecbbe03-site.fullsend-ai.workers.dev Commit: |
ReviewFindingsLow
Info
Previous runReviewFindingsLow
Info
|
| // If that differs from the desired remotePath, rename it in-sandbox. | ||
| uploadedPath := filepath.Join(remoteDir, filepath.Base(localPath)) | ||
| if uploadedPath != remotePath { | ||
| mvCmd := fmt.Sprintf("mv %s %s", uploadedPath, remotePath) |
There was a problem hiding this comment.
[low] injection-defense
The mv command in UploadFile uses fmt.Sprintf without shell-quoting paths. Pre-existing pattern but not defensive against paths with spaces or metacharacters.
Suggested fix: Use shell-safe quoting for paths in sandbox Exec commands. Consider a helper function for constructing sandbox shell commands.
openshell sandbox upload treats the remote path as a directory, placing the uploaded file inside it with the source basename. This caused host_files staging to create a directory at the destination path (e.g. prior-review.txt/) with the file nested inside, producing EISDIR errors when the agent tried to read the file. Add sandbox.UploadFile() — analogous to the existing DownloadFile() — which uploads to the parent directory and renames in-sandbox if the basename differs. Update all three sandbox.Upload() calls in bootstrapEnv's host_files staging and .env upload to use UploadFile instead. Note: Go tests could not run in sandbox (go.mod requires go >= 1.26.0, sandbox has 1.24.13 with read-only GOPATH). Pre-commit could not run (same Go toolchain issue). Manual verification of go-test is required. Closes #1649
907d482 to
ea8b30e
Compare
|
|
||
| // openshell places the file as <remoteDir>/<basename(localPath)>. | ||
| // If that differs from the desired remotePath, rename it in-sandbox. | ||
| uploadedPath := filepath.Join(remoteDir, filepath.Base(localPath)) |
There was a problem hiding this comment.
[low] shell-quoting
UploadFile constructs the in-sandbox mv command via fmt.Sprintf("mv %s %s", ...) without shell-quoting either path. If a path contains spaces or shell metacharacters, the command will fail or behave unexpectedly. Current callers pass safe paths. This matches the pre-existing pattern in UploadDir and is not a regression.
Suggested fix: Use shell-quoted format strings (e.g. single-quote wrapping) consistent with a broader cleanup of the same pattern in UploadDir.
|
Closing in favour of #1887 |
openshell sandbox upload treats the remote path as a directory, placing the uploaded file inside it with the source basename. This caused host_files staging to create a directory at the destination path (e.g. prior-review.txt/) with the file nested inside, producing EISDIR errors when the agent tried to read the file.
Add sandbox.UploadFile() — analogous to the existing DownloadFile() — which uploads to the parent directory and renames in-sandbox if the basename differs. Update all three sandbox.Upload() calls in bootstrapEnv's host_files staging and .env upload to use UploadFile instead.
Note: Go tests could not run in sandbox (go.mod requires go >= 1.26.0, sandbox has 1.24.13 with read-only GOPATH). Pre-commit could not run (same Go toolchain issue). Manual verification of go-test is required.
Closes #1649
Post-script verification
agent/1649-fix-upload-file-staging)557c0a1189eed1adca4ec44cbdb53bf81f423703..HEAD)