Skip to content

fix: tighten relationRef anchoring and permission word boundary#69

Merged
miparnisari merged 2 commits intoauthzed:mainfrom
ivanauth:fix/grammar-relationref-greediness
May 1, 2026
Merged

fix: tighten relationRef anchoring and permission word boundary#69
miparnisari merged 2 commits intoauthzed:mainfrom
ivanauth:fix/grammar-relationref-greediness

Conversation

@ivanauth
Copy link
Copy Markdown
Contributor

@ivanauth ivanauth commented May 1, 2026

Two related regex-correctness fixes in the permission rule.

1. Anchor relationRef so it can't shadow arrow rules. It matched any identifier and only worked because the arrow / .any() / .all() rules were listed first in the patterns. Switched to a negative lookahead so it explicitly skips identifiers immediately followed by ->, .any(, or .all( — correctness is now regex-local instead of depending on include order. The \b matters: without it, Oniguruma backtracks \w* into the middle of an identifier when the lookahead fails (matching grou for group->member).

2. Add the missing leading \b to the permission keyword. definition, relation, and caveat all start their begin regex with \b<keyword>\b; permission was the odd one out ((permission\b)). One-character fix for consistency.

@ivanauth ivanauth changed the title fix: anchor relationRef so it can't shadow arrow rules fix: tighten relationRef anchoring and permission word boundary May 1, 2026
@miparnisari miparnisari merged commit 4ecc35c into authzed:main May 1, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants