Skip to content

fix(mcpx/config): refuse unclosed/empty regexp tool patterns; escape leading ^ in glob classes - #3038

Merged
dezren39 merged 1 commit into
mainfrom
queue/4067-1631-toolpattern
Oct 31, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4067-1631-toolpattern

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #1631. Queue task 4067 (repo-health-code-pilot).

What

CompileToolPatterns silently mistranslated three entry shapes:

  • an unclosed regexp entry (/delete, or the lone /) fell through to an exact name that matches nothing a server offers — a deny entry that silently protects nothing;
  • // compiled the empty RE2 regexp, which matches every name;
  • a glob class whose body begins with ^ ([^d]elete_*) copied the ^ verbatim into the RE2 class, inverting it (matched xelete_x, not delete_x).

Change (pkgs/mcpx/internal/config/toolpattern.go)

  • Any entry beginning with / must now be a complete /.../ pair: unclosed entries are a compile error naming the entry, and // is refused as an empty regexp. Well-formed regexp entries are unchanged (still unanchored RE2).
  • globRegexp escapes a body-leading ^ when the class is not the [!...] negation form, preserving the glob meaning (literal ^ member). [!...] is unchanged: there the body-leading ^ is a member of the negated set, which RE2 already reads correctly.

Tests

New regression tests in toolpattern_test.go cover all three shapes plus controls (/delete/ unanchored, /(/, delete_[, empty entry, [!d] negation). go test ./internal/config/ passes on the laptop; CI (mcpx workflow) is the remaining gate.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…ape leading ^ in glob classes (#1631)

CompileToolPatterns silently mistranslated three entry shapes: an unclosed /regexp fell through to a never-matching exact name, // compiled the empty regexp and matched everything, and a glob class body beginning with ^ was copied verbatim into the RE2 class, inverting it. Now: any entry beginning with / that is not a complete /.../ pair (including the lone /) is a compile error naming the entry, // is refused as an empty regexp, and a body-leading ^ is escaped when the class is not the [!...] negation form. Regression tests cover all three shapes plus controls (well-formed /delete/, /( /, delete_[, empty entry, [!d] negation). go test ./internal/config/ passes on the laptop.
@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 11:52
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5bbb2d00-dfa8-4914-95b0-4a4c096f9fd6
Commits

Reviewing files that changed from the base of the PR and between 661582d and c0563b3.

Files selected for processing: 2
  • pkgs/mcpx/internal/config/toolpattern.go
  • pkgs/mcpx/internal/config/toolpattern_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T11:54:40.534949Z c0563b3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

None yet

Projects

None yet

1 participant