Harden tool terminal execution with command blocklisting and persistent shell process#558
Conversation
|
@copilot allow command "cd", "code","dotnet build" and any other noon-intrusive commands that does not compromise the security. Only maintain the list of blocked command everything else should be allowed |
Done in commit Blocked (shell interpreters and privilege-escalation tools):
Allowed: everything else — |
|
@copilot Work on the review comments |
…l default, shell injection guard
|
@copilot getting error when executing a regular commands |
Fixed in the latest commit. The root cause was that The fix:
With this change |
When PowerShell (and other shells) run in interactive mode with stdin piped, they echo the commands written to stdin back to stdout. This caused the internal sentinel command used for exit-code detection to appear verbatim in the terminal UI. Fix: buffer stdout by line while a command is executing and drop any line that matches the per-shell-type sentinel echo pattern before emitting output to the display. Remaining buffered data is flushed (with the same filter applied) when the pending command is resolved or fails.
Bundle Size Report 📦
Bundle Analysis ReportsThe detailed bundle analysis reports are available in the workflow artifacts:
Download the artifacts from the workflow run to view interactive visualizations. Bundle size tracking is now active! This helps prevent bundle bloat. |
When PowerShell (and other shells) run in interactive mode with stdin piped rather than a real PTY, they echo commands written to stdin back to stdout. This caused the internal sentinel used for exit-code detection to appear verbatim in the terminal UI:
Changes
handleStdoutChunk()— replaces the inline stdout handler. When a command is executing, stdout is line-buffered and lines matching the sentinel echo pattern are dropped before display. Pass-through is immediate when no command is in flight.isSentinelEchoLine()— per-shell predicate matching the echoed sentinel:pwsh:$__pptb_ok__ = $?;cmd:echo PPTB_CMD_END___pptb__=$?;flushStdoutBuffer()— drains the line buffer (with the same filter) when a pending command resolves or fails, shared betweenresolvePendingCommandandfailPendingCommand.Use a meaningful title for the pull request.
Follow the guidelines from the CONTRIBUTING.md.
Mention the bug or the feature number the PR will be targeting.
Test the change in your own code. (Compile and run)
Resolve all GH Copilot comments.