Fix sudo -S sensitive input detection#317594
Merged
meganrogge merged 2 commits intoMay 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts terminal agent tooling’s OutputMonitor so the canonical sudo password prompt ([sudo] password for …:) is not treated as a sensitive prompt when the executed command includes sudo -S, preventing the sensitive-input flow from triggering in that scenario. It also adds unit tests to cover sudo -S vs plain sudo.
Changes:
- Centralize sensitive-prompt classification behind
OutputMonitor._isSensitivePrompt(...). - Add a
sudo -Sexception for the canonical[sudo] password for …:line. - Add focused unit tests asserting
sudo -Sroutes toonDidDetectInputNeededwhile plainsudostill routes toonDidDetectSensitiveInputNeeded.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.ts | Routes sensitive-prompt checks through a helper and introduces the sudo -S exception. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/outputMonitor.test.ts | Adds tests for sudo -S vs plain sudo prompt classification. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.ts:609
isNonInteractiveSudoSensitivePromptreads like it returns true when a prompt is sensitive, but the only call site uses it to returnfalse(ie treat the prompt as non-sensitive). Renaming it (or inverting the predicate) would make the intent clearer and reduce the chance of future misuse when additional exceptions are added.
function isNonInteractiveSudoSensitivePrompt(command: string, prompt: string): boolean {
return /(?:^|\s)sudo\s+-S(?:\s|$)/.test(command) && /^\[sudo\]\s+password for .+:\s*$/i.test(prompt);
}
- Files reviewed: 2/2 changed files
- Comments generated: 2
dmitrivMS
approved these changes
May 20, 2026
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.
Fixes #317490
Summary
When
run_in_terminalsees a sudo password prompt, it currently always classifies it as sensitive interactive input and triggers the sensitive-input flow. That is correct for plainsudo, but it is wrong forsudo -S, where the password is expected onstdinand the[sudo] password for ...:line is just status output.This change keeps the existing sensitive-input behavior for interactive prompts, but treats the canonical sudo prompt as non-sensitive when the command includes
sudo -S, so the terminal stays on the normal input-needed path instead of being auto-cancelled in auto-approve mode.Changes
OutputMonitor._isSensitivePrompt(...)sudo -Swith the canonical[sudo] password for ...:promptsudo -Sand plainsudo