Open
Conversation
498804c to
d81c9cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The goal is to modernize privilege pattern matching system to provide more flexible identifier handling while maintaining strict pattern ordering to prevent wrong matches.
Flexible Identifier Pattern
Previous Approach:
New Approach:
_SYS_STATISTICS,my-schema,role.namewithout quotingReusable Pattern Constants
In key points:
Pattern Ordering Strategy (Reconsidered)
Patterns are ordered from most specific to most permissive to prevent false matches:
USERGROUP OPERATOR ON USERGROUP <name>- Multi-word specific keywordsUSAGE ON CLIENTSIDE ENCRYPTION COLUMN KEY <name>- Long keyword sequence<priv> ON REMOTE SOURCE <name>- Specific object type with keyword<priv> ON SCHEMA <name>- Specific object type with keyword<priv> ON <schema>.<object>- Dot separator provides uniquenessSTRUCTURED PRIVILEGE <name>- Specific keyword sequence<priv> ON <object>- Generic with ON keyword<priv>- System privilege (no ON keyword) - Most permissive, MUST be lastWith this ordering, we can ensure that more specific patterns match first, preventing the generic system privilege pattern from consuming privilege strings that should match more specific types.
Non-Greedy Privilege Name Matching
By way of using the
*?(non-greedy) quantifier, we prevent the privilege name from consuming theWITH GRANT OPTIONorWITH ADMIN OPTIONsuffixes.Examples
Identifiers are not quoted in the privilege specification. Just for reference, quoting only happens when constructing SQL commands (to prevent SQL injection in the easiest way possible):
Backward Compatibility and Testing
The hardest challenge is in ensuring the full backward compatibility:
"my schema"MY_SCHEMA_SYS_STATISTICS,my-schemaStill, all existing tests pass with the new patterns.