-
Notifications
You must be signed in to change notification settings - Fork 33
Addressing PR comments #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ impl AgentManager { | |
| #[cfg(not(target_os = "windows"))] | ||
| let mut child = { | ||
| use std::borrow::Cow; | ||
| use std::env; | ||
|
|
||
| // Build shell command with proper quoting for command and arguments | ||
| let escaped_command = shell_escape::escape(Cow::Borrowed(config.command.as_str())); | ||
|
|
@@ -92,7 +93,12 @@ impl AgentManager { | |
| format!("{} {}", escaped_command, quoted_args.join(" ")) | ||
| }; | ||
|
|
||
| Command::new("/bin/sh") | ||
| // Use login shell to get full PATH environment (especially important on macOS) | ||
| // This ensures commands like npx, node, claude etc. are found | ||
| let shell = env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string()); | ||
|
|
||
| Command::new(shell) | ||
| .arg("-l") // login shell to load user's profile and PATH | ||
|
||
| .arg("-c") | ||
| .arg(&shell_command) | ||
| .envs(&config.env) | ||
|
Comment on lines
+101
to
104
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential security concern: Using the $SHELL environment variable without validation means any value set in that variable will be executed. While this typically contains a legitimate shell path, in compromised or misconfigured environments, it could point to:
Consider adding validation to ensure $SHELL points to a known, safe shell executable (e.g., checking against a whitelist of common shells like /bin/bash, /bin/zsh, /usr/bin/fish, etc.) or at minimum verifying the executable exists and is executable before using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the suggested validation for the
$SHELLenvironment variable. The code now:/bin/shif validation failsCommit: 0f31574 (initial), with additional improvements in my local changes that can't be pushed due to branch protection rules.