RANGER-4762:Prevent duplicate values for resource while validating policy#308
Closed
fateh288 wants to merge 3 commits intoapache:masterfrom
Closed
RANGER-4762:Prevent duplicate values for resource while validating policy#308fateh288 wants to merge 3 commits intoapache:masterfrom
fateh288 wants to merge 3 commits intoapache:masterfrom
Conversation
…a policy
Previously: Via REST, policy creation possible when duplicate values specified for a resource as a list e.g. for a resource, multiple dbs can be mentioned like db:[test_db1,test_db1] and this policy is considered different from a policy already created for the resource [test_db1]
After this patch: Error is thrown for duplicate resource values like [test_db1,test_db1] - {"statusCode":1,"msgDesc":"(0) Validation failure: error code[3056], reason[Values for the resource=database contained a duplicate value=test_db1. Ensure all values for a resource are unique], field[resource-values], subfield[database], type[semantically incorrect] "}
…cate values for a resource
Use removeIf() which uses iterator to remove blank values which avoid creation of full hashset and also allows breaking from the loop while finding duplicates. Reorganize code into if-else format while checking for empty resource values - improves readability
kulkabhay
approved these changes
Apr 2, 2024
Contributor
Author
|
The changes have been merged : ffda775 |
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.
Previously: Via REST, policy creation possible when duplicate values specified for a resource as a list e.g. for a resource, multiple dbs can be mentioned like db:[test_db1,test_db1] and this policy is considered different from a policy already created for the resource [test_db1]
The same scenario is already prevented by Ranger UI as it prevents duplicate values for a resource (in a given policy)
What changes were proposed in this pull request?
After this patch: Error is thrown for duplicate resource values like [test_db1,test_db1] - {"statusCode":1,"msgDesc":"(0) Validation failure: error code[3056], reason[Values for the resource=database contained a duplicate value=test_db1. Ensure all values for a resource are unique], field[resource-values], subfield[database], type[semantically incorrect] "}
How was this patch tested?
Unit tests added for the scenario
Manually tested via REST end points for policy creation that duplicate resource values for a resource throws above error.