Skip to content

Fix terminal command substitution quote handling#12429

Open
pragnyanramtha wants to merge 1 commit into
continuedev:mainfrom
pragnyanramtha:codex/terminal-security-command-substitution-quotes
Open

Fix terminal command substitution quote handling#12429
pragnyanramtha wants to merge 1 commit into
continuedev:mainfrom
pragnyanramtha:codex/terminal-security-command-substitution-quotes

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 17, 2026

Description

Fixes command-substitution scanning in @continuedev/terminal-security so it follows shell quoting rules more closely:

  • ignores $() and backticks when they are literal text inside single quotes
  • keeps command-substitution detection active inside double quotes
  • evaluates nested commands inside process substitutions such as <(...)
  • treats process-substitution-looking text inside double quotes as literal text

This avoids unnecessary permission prompts for safe commands like echo 'literal $(name)' while preserving and tightening detection for executable substitutions.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

N/A - terminal-security unit test coverage only.

Tests

  • npx vitest run test/terminalCommandSecurity.test.ts -t "Subshell and Command Substitution"
  • npm test
  • npm run build
  • git diff --check

Summary by cubic

Fixes command-substitution detection in @continuedev/terminal-security to follow shell quoting rules. Reduces false permission prompts while tightening detection for nested and process substitutions.

  • Bug Fixes
    • Ignore $() and backticks inside single quotes; keep detection inside double quotes.
    • Detect nested substitutions and process substitutions like <(...)/>(...), but treat them as literal inside double quotes.
    • Replace naive checks with scanCommandSubstitutions, findClosingBacktick, and findClosingParen for quote- and escape-aware parsing.
    • Expand tests to cover single vs. double quotes and process substitution scenarios.

Written for commit a1402d4. Summary will update on new commits. Review in cubic

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 17, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 03:48
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 17, 2026 03:48
Copilot AI review requested due to automatic review settings May 17, 2026 03:48
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 17, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@pragnyanramtha
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants