You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by rm...@apache.org on 2016/11/24 05:54:08 UTC
incubator-ranger git commit: RANGER-1229:RangerResourceMatcher for
Hdfs and Yarn resources does not correctly handle policy containing only one
resource whose value is "*"
Repository: incubator-ranger
Updated Branches:
refs/heads/master ccd0badd9 -> 62160bb81
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/62160bb8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/62160bb8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/62160bb8
Branch: refs/heads/master
Commit: 62160bb81c964fc829b6916f9054faefd1ddfa63
Parents: ccd0bad
Author: Abhay Kulkarni <ak...@hortonworks.com>
Authored: Wed Nov 23 19:05:44 2016 -0800
Committer: rmani <rm...@hortonworks.com>
Committed: Wed Nov 23 21:53:06 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/62160bb8/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 38260ec..67353ca 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
@@ -294,7 +294,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/62160bb8/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 7bf30f3..5f61bd8 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
@@ -102,7 +102,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/62160bb8/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 e1730dd..c67ff45 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",