Add shell command execution on client#9
Open
kieranklaassen wants to merge 3 commits intoterminalwire:mainfrom
Open
Add shell command execution on client#9kieranklaassen wants to merge 3 commits intoterminalwire:mainfrom
kieranklaassen wants to merge 3 commits intoterminalwire:mainfrom
Conversation
Implements secure shell command execution from server to client as requested in terminalwire#8. Uses array-based execution (no shell interpretation) to prevent command injection attacks. Security features: - Commands must be explicitly permitted by prefix (e.g. "git status") - Array execution via Open3.capture3 prevents shell injection - Working directory (chdir) validated against path entitlements - Timeout limits (default 30s, max 300s) prevent resource exhaustion - Output size limits (10MB) prevent memory exhaustion API: result = context.shell.run("git", "status") result = context.shell.run("bundle", "exec", "rspec", timeout: 60) result.stdout # => "output" result.stderr # => "errors" result.exitstatus # => 0 result.success? # => true Closes terminalwire#8 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Users can now configure shell, path, and environment variable permissions
via a config file at ~/.terminalwire/authorities/{authority}/config.yml
Example config:
```yaml
shell:
allow:
- "git remote"
- "git branch"
paths:
allow:
- "~/.config/myapp"
environment_variables:
allow:
- "HOME"
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Use catch/throw instead of direct exit() to allow Async cleanup - Return exit status from connect() instead of calling exit inside - Suppress async cleanup errors during shutdown 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
Let me know if this can merged or changed! |
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
Implements secure shell command execution from server to client as requested in #8.
git status,bundle exec)chdir) validated against path entitlementsUser Configuration
Users can configure permissions via a config file at
~/.terminalwire/authorities/{authority}/config.yml:This allows users to grant permissions to specific servers without modifying code.
Server API
Security Design
Array-based execution - Uses
Open3.capture3(cmd, *args)which bypasses the shell entirely. Shell metacharacters like&&,;,|, backticks are treated as literal strings.Command prefix allowlist - Commands are permitted by prefix matching (e.g.
"git status"allowsgit status --shortbut notgit push). No glob patterns to avoid bypass vulnerabilities.Path entitlement for chdir - If
chdiris specified, it must be a permitted path.Resource limits - Timeout (max 300s) and output size (max 10MB) prevent exhaustion attacks.
User-controlled permissions - All permissions are configured by the user, not the server. The server can only use what the user has explicitly allowed.
Test Plan
Closes #8
🤖 Generated with Claude Code