-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Investigate improvements to all pattern matching #36062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Pinging @elastic/es-security |
This investigation should also consider an observation from @tvernum
This means that something like Additionally, one item to consider is the fact that certain patterns may overlap; |
This commit moves the implementation of wildcard pattern matching into a standalone utility class ("StringMatcher"). In general, we rely on lucene Automaton objects to implement pattern matching (wildcards and regexp) within Elasticsearch security - for example in Index name patterns within a role. The IndicesPermission class also has a special optimisation for exact string matches (that is raw index names that contain no wildcards) as using String.equals / Set.contains is more efficient for this common case. All of the above functionality has now been extracted into the StringMatcher class, and it is now used in several places where it may be more efficient that the previous use of raw Automaton objects. A future change will expand this StringMatcher class with additional optimisations for common use cases that are poorly handled within our existing automaton compilation process. Relates: elastic#36062
This commit moves the implementation of wildcard pattern matching into a standalone utility class ("StringMatcher"). In general, we rely on lucene Automaton objects to implement pattern matching (wildcards and regexp) within Elasticsearch security - for example in Index name patterns within a role. The IndicesPermission class also has a special optimisation for exact string matches (that is raw index names that contain no wildcards) as using String.equals / Set.contains is more efficient for this common case. All of the above functionality has now been extracted into the StringMatcher class, and it is now used in several places where it may be more efficient that the previous use of raw Automaton objects. A future change will expand this StringMatcher class with additional optimisations for common use cases that are poorly handled within our existing automaton compilation process. Relates: #36062
In #36017, a targeted improvement is made to the pattern matching for indices permissions to improve the exact match performance and building of permissions. @tvernum suggested that we can extract this logic into a
Patterns
class and update other places where pattern matching is done. Also, we can investigate the performance of other methods such asString#startsWith
andString#endsWith
in certain cases in place of aAutomaton
.The text was updated successfully, but these errors were encountered: