Skip to content

feat: add regex support for bash permissions - #11908

Closed
JtMotoX wants to merge 4 commits into
anomalyco:devfrom
JtMotoX:feature/regex-bash-permissions
Closed

JtMotoX wants to merge 4 commits into
anomalyco:devfrom
JtMotoX:feature/regex-bash-permissions

Conversation

@JtMotoX

@JtMotoX JtMotoX commented Feb 3, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes #11397

This adds regex pattern support to the permission system for more flexible pattern matching. Previously, the permission system only supported simple wildcards (* and ?). This enhancement allows users to define more complex patterns using regular expressions by wrapping them in forward slashes (e.g., "/pattern/").

The changes include:

  • Modified the Wildcard.match function to detect and handle regex patterns (patterns starting and ending with "/")
  • Added comprehensive tests for regex patterns including alternation, wildcards, and whitespace matching
  • Updated documentation in both agents.mdx and permissions.mdx to explain regex usage with examples

This allows users to write more precise permission rules, such as:

  • "/brew (install|info|list)/" to allow specific brew commands
  • "/git\s+(status|log|diff)/" to match git commands with proper whitespace handling

How did you verify your code works?

I copied all of my regex patterns from my vscode github copilot extension settings over to my opencode.json permissions. All my bash allow/ask/deny rules worked perfectly in opencode. I also tested the original wildcard rules and they still work.

@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title feature: add regex support for bash permissions doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@JtMotoX JtMotoX changed the title feature: add regex support for bash permissions feat: add regex support for bash permissions Feb 3, 2026
@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@JtMotoX
JtMotoX marked this pull request as draft February 3, 2026 07:19
Enhances the pattern matching functionality to support regex patterns for more complex use cases.

- Implemented regex matching in Wildcard.match function
- Added tests for regex patterns in wildcard tests
- Updated documentation to include regex usage examples
- Enhanced permission evaluation to handle regex patterns
@JtMotoX
JtMotoX force-pushed the feature/regex-bash-permissions branch 2 times, most recently from 59d7a6c to e4faa16 Compare February 3, 2026 07:26
Clarified the explanation of regex patterns in the permissions documentation.

- Removed examples of regex features for conciseness
- Maintained focus on JavaScript regex evaluation
@JtMotoX
JtMotoX marked this pull request as ready for review February 3, 2026 07:29
@broboa

broboa commented Feb 9, 2026

Copy link
Copy Markdown

This would relieve my pain! 👍

@MaTeuff

MaTeuff commented Feb 13, 2026

Copy link
Copy Markdown

Great job!

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

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.

[FEATURE]: Support regex in permissions configuration

3 participants