You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ab...@apache.org on 2019/12/08 02:34:28 UTC
[ranger] branch master updated: RANGER-2666: Rename matchType and
matchScope enumerators to more descriptive names
This is an automated email from the ASF dual-hosted git repository.
abhay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new f6685bd RANGER-2666: Rename matchType and matchScope enumerators to more descriptive names
f6685bd is described below
commit f6685bd4af4dd9ef87c10c294709e3a1b37d4f50
Author: Abhay Kulkarni <ab...@apache.org>
AuthorDate: Sat Dec 7 18:13:15 2019 -0800
RANGER-2666: Rename matchType and matchScope enumerators to more descriptive names
---
.../policyengine/RangerPolicyEngineImpl.java | 2 +-
.../RangerDefaultPolicyEvaluator.java | 4 ++--
.../RangerDefaultPolicyResourceMatcher.java | 20 ++++++++---------
.../RangerPolicyResourceMatcher.java | 4 ++--
.../TestDefaultPolicyResourceMatcher.java | 4 ++--
.../test_defaultpolicyresourcematcher.json | 26 +++++++++++-----------
...faultpolicyresourcematcher_for_hive_policy.json | 4 ++--
7 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
index a55c62f..fefa465 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
@@ -269,7 +269,7 @@ public class RangerPolicyEngineImpl implements RangerPolicyEngine {
if (request.getResourceMatchingScope() == RangerAccessRequest.ResourceMatchingScope.SELF_OR_DESCENDANTS) {
isMatched = matchType != RangerPolicyResourceMatcher.MatchType.NONE;
} else {
- isMatched = matchType == RangerPolicyResourceMatcher.MatchType.SELF || matchType == RangerPolicyResourceMatcher.MatchType.ANCESTOR_WITH_WILDCARDS;
+ isMatched = matchType == RangerPolicyResourceMatcher.MatchType.SELF || matchType == RangerPolicyResourceMatcher.MatchType.SELF_AND_ALL_DESCENDANTS;
}
if (!isMatched) {
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java b/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
index 57ad717..59a0405 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
@@ -247,7 +247,7 @@ public class RangerDefaultPolicyEvaluator extends RangerAbstractPolicyEvaluator
} else if (request.getResourceMatchingScope() == RangerAccessRequest.ResourceMatchingScope.SELF_OR_DESCENDANTS) {
isMatched = matchType != RangerPolicyResourceMatcher.MatchType.NONE;
} else {
- isMatched = matchType == RangerPolicyResourceMatcher.MatchType.SELF || matchType == RangerPolicyResourceMatcher.MatchType.ANCESTOR_WITH_WILDCARDS;
+ isMatched = matchType == RangerPolicyResourceMatcher.MatchType.SELF || matchType == RangerPolicyResourceMatcher.MatchType.SELF_AND_ALL_DESCENDANTS;
}
if (isMatched) {
@@ -1260,4 +1260,4 @@ public class RangerDefaultPolicyEvaluator extends RangerAbstractPolicyEvaluator
return rangerConditionEvaluators;
}
-}
\ No newline at end of file
+}
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerDefaultPolicyResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerDefaultPolicyResourceMatcher.java
index d2fc5d3..9794881 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerDefaultPolicyResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerDefaultPolicyResourceMatcher.java
@@ -612,7 +612,7 @@ public class RangerDefaultPolicyResourceMatcher implements RangerPolicyResourceM
// More matchers than resource-values
if (resourceKeysSize > lastNonAnyMatcherIndex) {
// all remaining matchers which matched resource value of null are of type Any
- ret = MatchType.ANCESTOR_WITH_WILDCARDS;
+ ret = MatchType.SELF_AND_ALL_DESCENDANTS;
} else {
ret = MatchType.DESCENDANT;
}
@@ -727,23 +727,23 @@ public class RangerDefaultPolicyResourceMatcher implements RangerPolicyResourceM
final boolean ret;
switch (scope) {
case SELF: {
- ret = matchType == MatchType.SELF;
+ ret = matchType == MatchType.SELF || matchType == MatchType.SELF_AND_ALL_DESCENDANTS;
break;
}
- case SELF_OR_DESCENDANT: {
- ret = matchType == MatchType.SELF || matchType == MatchType.DESCENDANT;
- break;
- }
- case SELF_OR_ANCESTOR: {
- ret = matchType == MatchType.SELF || matchType == MatchType.ANCESTOR || matchType == MatchType.ANCESTOR_WITH_WILDCARDS;
+ case ANCESTOR: {
+ ret = matchType == MatchType.ANCESTOR;
break;
}
case DESCENDANT: {
ret = matchType == MatchType.DESCENDANT;
break;
}
- case ANCESTOR: {
- ret = matchType == MatchType.ANCESTOR || matchType == MatchType.ANCESTOR_WITH_WILDCARDS;
+ case SELF_OR_ANCESTOR: {
+ ret = matchType == MatchType.SELF || matchType == MatchType.SELF_AND_ALL_DESCENDANTS || matchType == MatchType.ANCESTOR;
+ break;
+ }
+ case SELF_OR_DESCENDANT: {
+ ret = matchType == MatchType.SELF || matchType == MatchType.SELF_AND_ALL_DESCENDANTS || matchType == MatchType.DESCENDANT;
break;
}
default: {
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerPolicyResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerPolicyResourceMatcher.java
index 6c1591a..7978e7f 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerPolicyResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyresourcematcher/RangerPolicyResourceMatcher.java
@@ -29,8 +29,8 @@ import org.apache.ranger.plugin.policyengine.RangerAccessResource;
import org.apache.ranger.plugin.resourcematcher.RangerResourceMatcher;
public interface RangerPolicyResourceMatcher {
- enum MatchScope { SELF, SELF_OR_DESCENDANT, SELF_OR_ANCESTOR, DESCENDANT, ANCESTOR, ANY, ANCESTOR_WITH_WILDCARDS };
- enum MatchType { NONE, SELF, DESCENDANT, ANCESTOR, ANCESTOR_WITH_WILDCARDS };
+ enum MatchScope { SELF, SELF_OR_DESCENDANT, SELF_OR_ANCESTOR, DESCENDANT, ANCESTOR, ANY, SELF_AND_ALL_DESCENDANTS}
+ enum MatchType { NONE, SELF, DESCENDANT, ANCESTOR, SELF_AND_ALL_DESCENDANTS}
void setServiceDef(RangerServiceDef serviceDef);
diff --git a/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestDefaultPolicyResourceMatcher.java b/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestDefaultPolicyResourceMatcher.java
index ab85399..8ea7105 100644
--- a/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestDefaultPolicyResourceMatcher.java
+++ b/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestDefaultPolicyResourceMatcher.java
@@ -145,8 +145,8 @@ public class TestDefaultPolicyResourceMatcher {
scope = RangerPolicyResourceMatcher.MatchScope.SELF_OR_ANCESTOR;
} else if (StringUtils.equalsIgnoreCase(oneTest.type, "ancestorMatch")) {
scope = RangerPolicyResourceMatcher.MatchScope.ANCESTOR;
- } else if (StringUtils.equalsIgnoreCase(oneTest.type, "ancestorWithWildcardsMatch")) {
- scope = RangerPolicyResourceMatcher.MatchScope.ANCESTOR_WITH_WILDCARDS;
+ } else if (StringUtils.equalsIgnoreCase(oneTest.type, "selfAndAllDescendants")) {
+ scope = RangerPolicyResourceMatcher.MatchScope.SELF_AND_ALL_DESCENDANTS;
} else if (StringUtils.equalsIgnoreCase(oneTest.type, "anyMatch")) {
scope = RangerPolicyResourceMatcher.MatchScope.ANY;
} else {
diff --git a/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher.json b/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher.json
index 8d4a680..86b0f12 100644
--- a/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher.json
+++ b/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher.json
@@ -215,7 +215,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -283,7 +283,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -293,7 +293,7 @@
,
{
"name": "MATCH for parent with wildcards ''",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {}
},
@@ -427,7 +427,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -561,7 +561,7 @@
,
{
"name": "MATCH for parent with wildcards ''",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {}
},
@@ -590,7 +590,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance:tax'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance","table": "tax"}
},
@@ -600,7 +600,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -610,7 +610,7 @@
,
{
"name": "MATCH for parent with wildcards ''",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {}
},
@@ -756,7 +756,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance:tax'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance","table": "tax"}
},
@@ -766,7 +766,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -797,7 +797,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance:tax'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance","table": "tax"}
},
@@ -807,7 +807,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance"}
},
@@ -917,7 +917,7 @@
,
{
"name": "MATCH for parent with wildcards 'finance:tax'",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"resource": {
"elements": {"database": "finance","table": "tax"}
},
diff --git a/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher_for_hive_policy.json b/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher_for_hive_policy.json
index 32df8b9..3396833 100644
--- a/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher_for_hive_policy.json
+++ b/agents-common/src/test/resources/resourcematcher/test_defaultpolicyresourcematcher_for_hive_policy.json
@@ -310,7 +310,7 @@
},
{
"name": "Ancestor with wildcards match for 'finance,hr,tmp*:tax,employee,tmp*:' policy",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"policy" : {
"service" : "any",
"name" : "test",
@@ -383,7 +383,7 @@
},
{
"name": "Ancestor with wildcards match for 'finance,hr,tmp*::' policy",
- "type": "ancestorWithWildcardsMatch",
+ "type": "selfAndAllDescendants",
"policy" : {
"service" : "any",
"name" : "test",