Skip to content

Make terminal auto approve more aware of paths #259673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 8, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 4, 2025

When configuring terminal auto approval, users expect path variations to work intuitively. Previously, if you approved bin/foo, it would only match that exact path separator style, requiring separate entries for Windows and Unix variants.

This change makes the auto approval system path-aware by detecting strings that contain path separators (/ or \) and creating flexible regex patterns that handle common path variations:

Before:

{
  "terminal.integrated.autoApprove": {
    "bin/foo": true,
    "bin\\foo": true,     // Required separate entry
    "./bin/foo": true,    // Required separate entry  
    ".\\bin\\foo": true   // Required separate entry
  }
}

After:

{
  "terminal.integrated.autoApprove": {
    "bin/foo": true  // Now matches all variations automatically
  }
}

With this change, approving bin/foo automatically allows:

  • bin/foo (exact match)
  • bin\foo (Windows backslashes)
  • ./bin/foo (current directory with forward slash)
  • .\bin\foo (current directory with backslash)
  • Mixed separator combinations

The implementation:

  1. Detects path-like strings by checking for / or \ separators
  2. Creates flexible regex patterns using character classes [/\\] for separators
  3. Adds optional prefix matching for ./ and .\ patterns
  4. Preserves existing behavior for non-path commands (like echo, ls)
  5. Properly escapes regex special characters in path names

This makes the terminal auto approval feature more intuitive for cross-platform development workflows where the same logical path might be referenced with different separator styles.

Fixes #259672.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and Tyriar Aug 4, 2025
@Tyriar Tyriar added this to the August 2025 milestone Aug 4, 2025
@Copilot Copilot AI changed the title [WIP] Make terminal auto approve more aware of paths Make terminal auto approve more aware of paths Aug 4, 2025
@Copilot Copilot AI requested a review from Tyriar August 4, 2025 21:50
Copilot finished work on behalf of Tyriar August 4, 2025 21:50
@Tyriar Tyriar marked this pull request as ready for review August 8, 2025 12:46
@Tyriar Tyriar enabled auto-merge August 8, 2025 12:46
@Tyriar Tyriar merged commit b8b82df into main Aug 8, 2025
18 checks passed
@Tyriar Tyriar deleted the copilot/fix-259672 branch August 8, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make terminal auto approve more aware of paths
3 participants