Skip to content

RANGER-5746: Improvement in Ranger policy engine - #1172

Open
maheshbandal15 wants to merge 1 commit into
ranger-2.10from
mb-ranger-5746
Open

RANGER-5746: Improvement in Ranger policy engine#1172
maheshbandal15 wants to merge 1 commit into
ranger-2.10from
mb-ranger-5746

Conversation

@maheshbandal15

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Align case-insensitive folding in RangerResourceTrie with the folding used by resource matchers.

When ignoreCase is enabled, the resource trie indexes child nodes using getLookupChar(), while policy resource matching uses StringUtils.equalsIgnoreCase() (equivalent to String.regionMatches(true, …)). Those two paths did not use the same Unicode case fold:

Trie lookup (before): Character.toLowerCase(ch)
Matchers: upper-case, then lower-case (equalsIgnoreCase semantics)
For some Unicode characters these folds diverge (for example i / ı, s / ſ, and other BMP equivalents). The trie could route a request to a different branch than the matcher would treat as equal, so candidate policy evaluators returned from trie pre-filtering could be incomplete relative to full matcher evaluation.

This change updates getLookupChar() to use Character.toLowerCase(Character.toUpperCase(ch)) when ignoreCase is true, matching the matcher’s ignore-case behavior. Case-sensitive resources are unchanged.

How was this patch tested?

New unit tests (TestRangerResourceTrieCaseFolding):

Documents Unicode pairs where equalsIgnoreCase and plain toLowerCase differ
Confirms RangerDefaultResourceMatcher treats equivalent Unicode variants as matches
Verifies trie lookup returns the expected evaluators for case-variant resources at branch boundaries
Covers single-character resources, sibling-branch splits, wildcard + exact-resource combinations, ASCII regression, compressed trie nodes, and bidirectional lookup (i <--> ı)
Manual verification: Built ranger locally using mvn clean install; all targeted and related tests pass.

@maheshbandal15 maheshbandal15 self-assigned this Aug 21, 2026
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.

2 participants