Skip to content

[FEATURE]: Support regex in permissions configuration #11397

Closed

Description

@JtMotoX

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Feature Request: Regex Support for Permissions Configuration

Summary

Permissions currently support only simple wildcards. Adding regex support would reduce repetitive rules and prevent unnecessary permission prompts, especially when the LLM varies argument order.


Problems

  • Repetition: Git commands require many separate wildcard entries.
  • Argument reordering: Commands like kubectl -n default get ... still trigger approval request even when kubectl get * is allowed. In my vscode copilot extension, I have a regex that takes care of this, so any - or -- arguments are completely ignored, while allowing the regex (get|describe|config|logs|api-resources|explain|cluster-info|top|debug|events|diff). This allows commands like kubectl -n myns -o json get pod mypod to run without asking for approval. My entire kubectl configuration is a single line regex in my vscode copilot configuration.

Git Example

Current:

"git": "ask",
"git branch *": "allow",
"git diff *": "allow",
"git log *": "allow",
"git shortlog *": "allow",
"git show *": "allow",
"git status *": "allow",
"git remote -v": "allow",

Desired Example (basically what I currently have configured in my vscode copilot extension):

"git": "ask",
"/^git (branch|diff|log|shortlog|show|status|(remote -v))/": "allow",

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 31, 2026
  2. github-actions commented on Jan 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Both issues share the core problem: simple wildcard patterns are insufficient for complex permission rules. Your regex approach would directly address these limitations.

    Feel free to ignore if your use case differs from these existing requests.

  3. broboa commented on Feb 2, 2026

    @broboa

    Confirming this is somewhat of a blocker when migrating from Kiro to OpenCode. Regex expressions in Kiro's permissions configuration provide both reduced rule verbosity and maintained security without trading off either.

    Migration Pain Points

    When converting a Kiro configuration with regex-based permissions to OpenCode wildcards, the constraints are stark:

    1. Security regression: Wildcards (*, ?) cannot express the safety constraints that regex enforces. A pattern like "*git commit*--no-gpg-sign*" to deny unsafe git operations becomes impossible to express safely—wildcards would match arbitrary prefixes and allow shell injection vectors.

    2. Argument position sensitivity: Commands with flags in any position (e.g., kubectl -n ns get pods vs kubectl get -n ns pods) require separate wildcard rules. Regex handles this trivially with optional argument groups; wildcards force explicit enumeration or dangerous blanket permissions.

    3. Pipe chain control: Regex can enforce that piping is only allowed to specific safe commands (head, grep, jq, etc.). Wildcards cannot distinguish between kubectl get | grep (safe) and kubectl get | xargs rm -rf (dangerous).

    Example: kubectl Configuration

    Kiro (single regex):

    "^(export\\s+KUBECONFIG=[^;&>`$]+\\s+&&\\s+)?kubectl\\s+(get|describe|logs|top|explain|version|cluster-info)(\\s+[^;&>`$]*)?( \\| (head|tail|grep|wc|sort|uniq|cut|awk|less|more|column|jq|yq)(\\s+[^;&>`$]*)?)*$": "allow"
    

    OpenCode wildcards (requires ~30+ rules or accepts security degradation):

    "kubectl get*": "allow"
    "kubectl describe*": "allow"
    ... (compromised: allows arbitrary arguments, pipes, and flags in any order)
    

    Regex support would eliminate this migration friction and restore the security model that made Kiro configurations maintainable.

  4. JtMotoX commented on Feb 3, 2026

    @JtMotoX
    Author

    Created PR #11908

  5. github-actions commented on Apr 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  6. NicolasWebDev commented on Jun 16, 2026

    @NicolasWebDev

    I understand @JtMotoX that the PR was never merged, right?

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

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions