Skip to content

Require confirmation for sed in-place terminal commands, agent host - #328882

Merged
Anthony Kim (anthonykim1) merged 6 commits into
mainfrom
anthonykim1/agent-host-sed-inplace-writes
Aug 4, 2026
Merged

Anthony Kim (anthonykim1) merged 6 commits into
mainfrom
anthonykim1/agent-host-sed-inplace-writes

Conversation

@anthonykim1

@anthonykim1 Anthony Kim (anthonykim1) commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Resolves: #328901
Follow-up: #328898

  • Move the existing workbench SedFileWriteParser to vs/platform/terminal/common/autoApprove so workbench and Agent Host share the same canonical in-place detection.
  • Reuse the shared parser in Agent Host to require confirmation for -i, -I, clustered and backup-suffix variants, BSD empty suffixes, and --in-place.
  • Apply the Agent Host check before configured terminal allow rules so a full-command rule cannot override it.
  • Keep workbench destination extraction, file-write settings, and auto-approval behavior unchanged.
  • Preserve normal non-in-place sed auto-approval and the existing -e/-f deny rules.
  • Add focused shared-parser, Agent Host approval, and session-permission regression coverage.

Inspirations from:

Add a shared semantic sed analyzer and apply it before Agent Host terminal
allow rules so in-place and runtime-resolved option forms cannot auto-approve.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
Copilot AI review requested due to automatic review settings August 4, 2026 02:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a shared sed analyzer to prevent auto-approval of potentially destructive in-place edits.

Changes:

  • Detects in-place and runtime-expanded sed options.
  • Applies a non-overridable approval gate.
  • Adds analyzer, approver, and permission tests.
Show a summary per file
File Description
sedCommandAnalyzer.ts Implements shell-word and sed option analysis.
sedCommandAnalyzer.test.ts Tests safe and confirmation-required forms.
commandAutoApprover.ts Applies the safety gate before allow rules.
commandAutoApprover.test.ts Tests gate behavior and rule precedence.
sessionPermissions.test.ts Tests session-level confirmation behavior.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Use one GNU/BSD-aware analyzer in workbench and Agent Host, applying
existing destination policies to static writes and failing closed otherwise.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
@anthonykim1 Anthony Kim (anthonykim1) changed the title Require confirmation for sed in-place terminal auto-approve Check sed in-place write destinations before terminal auto-approval Aug 4, 2026
Normalize sed executable matching for PowerShell and avoid treating option
characters after an invalid short option as in-place flags.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
Use explicit analyzer callbacks for TypeScript and quote native Windows paths
in Bash session-policy tests so shell decoding preserves the absolute path.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
Move the existing workbench sed parser to terminal common and reuse its
in-place detection as a non-overridable Agent Host confirmation gate.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
@anthonykim1 Anthony Kim (anthonykim1) changed the title Check sed in-place write destinations before terminal auto-approval Require confirmation for sed in-place commands in Agent Host Aug 4, 2026
@anthonykim1
Anthony Kim (anthonykim1) requested a balanced review from Copilot August 4, 2026 06:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Place the shared parser and its tests under terminal/common/autoApprove to
make the feature-specific ownership explicit without changing behavior.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bda42f98-e73f-417f-b7e6-03cff9e2f604
@anthonykim1
Anthony Kim (anthonykim1) marked this pull request as ready for review August 4, 2026 06:39
@anthonykim1 Anthony Kim (anthonykim1) added this to the 1.133.0 milestone Aug 4, 2026
@anthonykim1 Anthony Kim (anthonykim1) changed the title Require confirmation for sed in-place commands in Agent Host Require confirmation for sed in-place terminal commands, agent host Aug 4, 2026
@anthonykim1
Anthony Kim (anthonykim1) enabled auto-merge (squash) August 4, 2026 06:42
@anthonykim1
Anthony Kim (anthonykim1) merged commit 59ec7e5 into main Aug 4, 2026
46 of 47 checks passed
@anthonykim1
Anthony Kim (anthonykim1) deleted the anthonykim1/agent-host-sed-inplace-writes branch August 4, 2026 07:39
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Agent Host auto-approves sed in-place edits

3 participants