Fix #166: Quote sandbox names in shell commands and add validation#211
Closed
hkc5 wants to merge 2 commits intoNVIDIA:mainfrom
Closed
Fix #166: Quote sandbox names in shell commands and add validation#211hkc5 wants to merge 2 commits intoNVIDIA:mainfrom
hkc5 wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Fixes NVIDIA#166 - Add shellEscape() function to properly escape sandbox names in shell commands - Add validateSandboxName() function to enforce alphanumeric + hyphens only - Apply shell escaping to all shell commands that use sandboxName: - openshell sandbox delete - openshell sandbox create --name - openshell forward start - Exit with error if sandbox name fails validation This prevents shell injection and failures when sandbox names contain spaces or special characters.
Author
|
Closing this PR because it was accidentally created with The quoting/validation changes from the first commit will be resubmitted on a proper branch ( |
3 tasks
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
Fixes #166 - Sandbox names were being interpolated into shell commands without proper quoting, causing failures when names contain spaces or special characters.
Changes
Added function: Properly escapes strings for safe use in shell commands using single quotes and handling embedded single quotes.
Added function: Enforces that sandbox names contain only alphanumeric characters and hyphens (plus 64-character max length), rejecting names that could cause issues.
Applied shell escaping to all shell commands that use :
Added validation check: Exits with a clear error message if the user provides an invalid sandbox name.
Security
This fix prevents potential shell injection vulnerabilities where malicious sandbox names could execute arbitrary commands.
Testing
Tested validation and escaping logic with various inputs including:
my-assistant,assistant123,test-123-abcname'; rm -rf /; echo 'All tests pass.