Repository: incubator-ranger
Updated Branches:
  refs/heads/ranger-0.6 37512c121 -> ffbb138d1


RANGER-1229:RangerResourceMatcher for Hdfs and Yarn resources does not 
correctly handle policy containing only one resource whose value is "*"

Signed-off-by: rmani <rm...@hortonworks.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/ffbb138d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/ffbb138d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/ffbb138d

Branch: refs/heads/ranger-0.6
Commit: ffbb138d1809d5c800a7f916c05ab5cd2a1581a6
Parents: 37512c1
Author: Abhay Kulkarni <akulka...@hortonworks.com>
Authored: Wed Nov 23 19:05:44 2016 -0800
Committer: rmani <rm...@hortonworks.com>
Committed: Wed Nov 23 22:00:58 2016 -0800

----------------------------------------------------------------------
 .../RangerAbstractResourceMatcher.java          |  2 +-
 .../RangerPathResourceMatcher.java              |  2 +-
 .../test_resourcematcher_path.json              | 38 +++++++++++++++++++-
 3 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/ffbb138d/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
index 574f2eb..4a96fd7 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
@@ -267,7 +267,7 @@ public abstract class RangerAbstractResourceMatcher 
implements RangerResourceMat
        ResourceMatcher getMatcher(String policyValue) {
                final int len = policyValue != null ? policyValue.length() : 0;
 
-               if (len == 0) {
+               if (len == 0 || (optWildCard && 
policyValue.equals(WILDCARD_ASTERISK))) {
                        return null;
                }
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/ffbb138d/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
index d508f3f..97df061 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
@@ -92,7 +92,7 @@ public class RangerPathResourceMatcher extends 
RangerDefaultResourceMatcher {
 
                final int len = policyValue != null ? policyValue.length() : 0;
 
-               if (len == 0) {
+               if (len == 0 || (optWildCard && 
policyValue.equals(WILDCARD_ASTERISK))) {
                        return null;
                }
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/ffbb138d/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
----------------------------------------------------------------------
diff --git 
a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
 
b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
index 25b0eb7..e55ddc1 100644
--- 
a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
+++ 
b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
@@ -1,6 +1,42 @@
 {
   "testCases":[
-       {
+         {
+                 "name":"value=*; isRecursive=false; wildCard=true; 
ignoreCase=true",
+                 "resourceDef":{
+                         
"matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+                         "matcherOptions":{"wildCard":true, "ignoreCase":true}
+                 },
+                 "policyResource":{
+                         "values": ["*"],
+                         "isRecursive":false
+                 },
+                 "tests":[
+                         { "name":"exact-path","input":"*", "result":true},
+                         { "name":"child-path","input":"/path1", 
"result":true},
+                         { "name":"grand-child-path","input":"/path1/path2", 
"result":true},
+                         { "name":"no-slash-path","input":"path1", 
"result":true}
+                 ]
+         }
+         ,
+         {
+                 "name":"value=*; isRecursive=true; wildCard=true; 
ignoreCase=true",
+                 "resourceDef":{
+                         
"matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+                         "matcherOptions":{"wildCard":true, "ignoreCase":true}
+                 },
+                 "policyResource":{
+                         "values": ["*"],
+                         "isRecursive":true
+                 },
+                 "tests":[
+                         { "name":"exact-path","input":"*", "result":true},
+                         { "name":"child-path","input":"/path1", 
"result":true},
+                         { "name":"grand-child-path","input":"/path1/path2", 
"result":true},
+                         { "name":"no-slash-path","input":"path1", 
"result":true}
+                 ]
+         }
+  ,
+         {
       "name":"value=/; isRecursive=false; wildCard=true; ignoreCase=true",
       "resourceDef":{
            
"matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",

Reply via email to