You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by Rakesh Gupta <ra...@gmail.com> on 2024/07/09 12:46:51 UTC

Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/
-----------------------------------------------------------

(Updated July 9, 2024, 12:46 p.m.)


Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.


Summary (updated)
-----------------

RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.


Bugs: RANGER-4795
    https://issues.apache.org/jira/browse/RANGER-4795


Repository: ranger


Description (updated)
-------

There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 

Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.

Similar validation should be applied for data masking and row filter Policy.


Diffs (updated)
-----

  agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java d73d91b36 


Diff: https://reviews.apache.org/r/75004/diff/3/

Changes: https://reviews.apache.org/r/75004/diff/2-3/


Testing (updated)
-------

Verified while creating/updating Policy API fails, when users, groups, roles, data masking, and row filter fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.


Thanks,

Rakesh Gupta


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Rakesh Gupta <ra...@gmail.com>.

> On July 9, 2024, 2:38 p.m., Madhan Neethiraj wrote:
> > agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
> > Line 1002 (original), 1011 (patched)
> > <https://reviews.apache.org/r/75004/diff/3/?file=2289829#file2289829line1011>
> >
> >     Consider moving this to a static, to avoid instantiation on every call to isValidPolicyItem().
> >     
> >       private static final Set<String> INVALID_POLICY_ITEM_VALUES = new HashSet<>(Arrays.asList("null", "NULL", "Null", null, ""));
> >     
> >     
> >     Also, consider replacing the following with a call to invalidItems.contains(), as shown:
> >      - CollectionUtils.containsAny(policyItem.getUsers(),  INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getUsers())
> >      - CollectionUtils.containsAny(policyItem.getGroups(), INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getGroups())
> >      - CollectionUtils.containsAny(policyItem.getRoles(),  INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getRoles())

The contains method expects a String object, but policyItem.getUsers() returns a List<String>. This is not suitable, hence ignored.


- Rakesh


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/#review226644
-----------------------------------------------------------


On July 9, 2024, 12:46 p.m., Rakesh Gupta wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/75004/
> -----------------------------------------------------------
> 
> (Updated July 9, 2024, 12:46 p.m.)
> 
> 
> Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.
> 
> 
> Bugs: RANGER-4795
>     https://issues.apache.org/jira/browse/RANGER-4795
> 
> 
> Repository: ranger
> 
> 
> Description
> -------
> 
> There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 
> 
> Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.
> 
> Similar validation should be applied for data masking and row filter Policy.
> 
> 
> Diffs
> -----
> 
>   agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java d73d91b36 
> 
> 
> Diff: https://reviews.apache.org/r/75004/diff/3/
> 
> 
> Testing
> -------
> 
> Verified while creating/updating Policy API fails, when users, groups, roles, data masking, and row filter fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.
> 
> 
> Thanks,
> 
> Rakesh Gupta
> 
>


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Madhan Neethiraj <ma...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/#review226644
-----------------------------------------------------------




agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
Line 1002 (original), 1011 (patched)
<https://reviews.apache.org/r/75004/#comment314908>

    Consider moving this to a static, to avoid instantiation on every call to isValidPolicyItem().
    
      private static final Set<String> INVALID_POLICY_ITEM_VALUES = new HashSet<>(Arrays.asList("null", "NULL", "Null", null, ""));
    
    Also, consider replacing the following with a call to invalidItems.contains(), as shown:
     - CollectionUtils.containsAny(policyItem.getUsers(),  INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getUsers())
     - CollectionUtils.containsAny(policyItem.getGroups(), INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getGroups())
     - CollectionUtils.containsAny(policyItem.getRoles(),  INVALID_POLICY_ITEM_VALUES) => INVALID_POLICY_ITEM_VALUES.contains(policyItem.getRoles())



agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
Lines 1031 (patched)
<https://reviews.apache.org/r/75004/#comment314907>

    Empty row-filter should be allowed, as this used to exclude row-filter for specific users/groups/roles. Consider following items to allow the owner of a table to see all rows in the table, other users should only see rows having column status as 'ACTIVE':
    
    - users=[{OWNER}], rowFilterInfo.filterExpr=""
    - groups=[public], rowFilterInfo.filterExpr="status = 'ACTIVE'"


- Madhan Neethiraj


On July 9, 2024, 12:46 p.m., Rakesh Gupta wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/75004/
> -----------------------------------------------------------
> 
> (Updated July 9, 2024, 12:46 p.m.)
> 
> 
> Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.
> 
> 
> Bugs: RANGER-4795
>     https://issues.apache.org/jira/browse/RANGER-4795
> 
> 
> Repository: ranger
> 
> 
> Description
> -------
> 
> There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 
> 
> Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.
> 
> Similar validation should be applied for data masking and row filter Policy.
> 
> 
> Diffs
> -----
> 
>   agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java d73d91b36 
> 
> 
> Diff: https://reviews.apache.org/r/75004/diff/3/
> 
> 
> Testing
> -------
> 
> Verified while creating/updating Policy API fails, when users, groups, roles, data masking, and row filter fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.
> 
> 
> Thanks,
> 
> Rakesh Gupta
> 
>


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Dineshkumar Yadav <di...@outlook.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/#review227167
-----------------------------------------------------------


Ship it!




Ship It!

- Dineshkumar Yadav


On Jan. 6, 2025, 2:29 p.m., Rakesh Gupta wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/75004/
> -----------------------------------------------------------
> 
> (Updated Jan. 6, 2025, 2:29 p.m.)
> 
> 
> Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.
> 
> 
> Bugs: RANGER-4795
>     https://issues.apache.org/jira/browse/RANGER-4795
> 
> 
> Repository: ranger
> 
> 
> Description
> -------
> 
> There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 
> 
> Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.
> 
> Similar validation should be applied for data masking Policy.
> 
> 
> Diffs
> -----
> 
>   agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java 82ba483aa 
> 
> 
> Diff: https://reviews.apache.org/r/75004/diff/6/
> 
> 
> Testing
> -------
> 
> Verified while creating/updating Policy API fails, when users, groups, roles and data masking fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.
> 
> 
> Thanks,
> 
> Rakesh Gupta
> 
>


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Rakesh Gupta <ra...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/
-----------------------------------------------------------

(Updated Jan. 6, 2025, 2:29 p.m.)


Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.


Bugs: RANGER-4795
    https://issues.apache.org/jira/browse/RANGER-4795


Repository: ranger


Description
-------

There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 

Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.

Similar validation should be applied for data masking Policy.


Diffs (updated)
-----

  agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java 82ba483aa 


Diff: https://reviews.apache.org/r/75004/diff/6/

Changes: https://reviews.apache.org/r/75004/diff/5-6/


Testing
-------

Verified while creating/updating Policy API fails, when users, groups, roles and data masking fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.


Thanks,

Rakesh Gupta


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Rakesh Gupta <ra...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/
-----------------------------------------------------------

(Updated Jan. 6, 2025, 2:23 p.m.)


Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.


Changes
-------

Resolve merge conflicts


Bugs: RANGER-4795
    https://issues.apache.org/jira/browse/RANGER-4795


Repository: ranger


Description
-------

There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 

Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.

Similar validation should be applied for data masking Policy.


Diffs (updated)
-----

  agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java 82ba483aa 


Diff: https://reviews.apache.org/r/75004/diff/5/

Changes: https://reviews.apache.org/r/75004/diff/4-5/


Testing
-------

Verified while creating/updating Policy API fails, when users, groups, roles and data masking fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.


Thanks,

Rakesh Gupta


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Madhan Neethiraj <ma...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/#review226648
-----------------------------------------------------------


Ship it!




Ship It!

- Madhan Neethiraj


On July 10, 2024, 8:16 a.m., Rakesh Gupta wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/75004/
> -----------------------------------------------------------
> 
> (Updated July 10, 2024, 8:16 a.m.)
> 
> 
> Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.
> 
> 
> Bugs: RANGER-4795
>     https://issues.apache.org/jira/browse/RANGER-4795
> 
> 
> Repository: ranger
> 
> 
> Description
> -------
> 
> There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 
> 
> Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.
> 
> Similar validation should be applied for data masking Policy.
> 
> 
> Diffs
> -----
> 
>   agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java d73d91b36 
> 
> 
> Diff: https://reviews.apache.org/r/75004/diff/4/
> 
> 
> Testing
> -------
> 
> Verified while creating/updating Policy API fails, when users, groups, roles and data masking fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.
> 
> 
> Thanks,
> 
> Rakesh Gupta
> 
>


Re: Review Request 75004: RANGER-4795: Add validation in API to check emptiness on policyitem while creating policy.

Posted by Rakesh Gupta <ra...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75004/
-----------------------------------------------------------

(Updated July 10, 2024, 8:16 a.m.)


Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket shelar, Sailaja Polavarapu, and Velmurugan Periasamy.


Changes
-------

Addressed review comments.


Bugs: RANGER-4795
    https://issues.apache.org/jira/browse/RANGER-4795


Repository: ranger


Description (updated)
-------

There is an inconsistency between Ranger API and UI not doing the same validation for Policy creation. 

Policy creation API should fail when a policy with all empty values and along with  [""]  or  ["null"] in policyItem --> users, groups and roles.

Similar validation should be applied for data masking Policy.


Diffs (updated)
-----

  agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java d73d91b36 


Diff: https://reviews.apache.org/r/75004/diff/4/

Changes: https://reviews.apache.org/r/75004/diff/3-4/


Testing (updated)
-------

Verified while creating/updating Policy API fails, when users, groups, roles and data masking fields are all empty values or contain arrays with empty strings (e.g. [""]) within the policy items.


Thanks,

Rakesh Gupta