ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject [09/27] ranger git commit: RANGER-2180: Handle token replacement correctly when token is not defined in the request context
Date Thu, 30 Aug 2018 10:58:19 GMT
RANGER-2180: Handle token replacement correctly when token is not defined in the request context


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

Branch: refs/heads/ranger-1
Commit: 641e5ce4407106deee226d73b5b75c8318a01ea9
Parents: dccae70
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Thu Aug 2 08:26:28 2018 -0700
Committer: Mehul Parikh <mehul@apache.org>
Committed: Wed Aug 29 14:20:39 2018 +0530

----------------------------------------------------------------------
 .../org/apache/ranger/plugin/util/StringTokenReplacer.java     | 6 ++----
 .../resourcematcher/test_resourcematcher_dynamic.json          | 4 ++--
 .../test_resourcematcher_wildcards_as_delimiters.json          | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/641e5ce4/agents-common/src/main/java/org/apache/ranger/plugin/util/StringTokenReplacer.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/util/StringTokenReplacer.java
b/agents-common/src/main/java/org/apache/ranger/plugin/util/StringTokenReplacer.java
index 2ec809c..ace04d6 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/util/StringTokenReplacer.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/util/StringTokenReplacer.java
@@ -73,9 +73,7 @@ public class StringTokenReplacer {
                         if (replaced != null) {
                             ret.append(replaced.toString());
                         } else {
-                            ret = null;
-                            token = null;
-                            break;
+                            ret.append(startChar).append(token).append(endChar);
                         }
                     } else {
                         ret.append(startChar).append(token).append(endChar);
@@ -91,6 +89,6 @@ public class StringTokenReplacer {
             ret.append(startChar).append(token);
         }
 
-        return ret != null ? ret.toString() : null;
+        return ret.toString();
     }  
 }

http://git-wip-us.apache.org/repos/asf/ranger/blob/641e5ce4/agents-common/src/test/resources/resourcematcher/test_resourcematcher_dynamic.json
----------------------------------------------------------------------
diff --git a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_dynamic.json
b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_dynamic.json
index 5237d47..db19f76 100644
--- a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_dynamic.json
+++ b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_dynamic.json
@@ -15,7 +15,7 @@
 			  ,
 			  { "name":"exact-path","input":"/abcw", "evalContext": {"token:somestuff": "somethingelse"},
"result":false}
 			  ,
-			  { "name":"exact-path","input":"/abc%xyz%w", "evalContext": {"token:somestuff": "somethingelse"},
"result":false}
+			  { "name":"exact-path","input":"/abc%xyz%w", "evalContext": {"token:somestuff": "somethingelse"},
"result":true}
 			  ,
 			  { "name":"exact-path","input":"/abc%xyz%w", "evalContext": {"token:somestuff": "somethingelse",
"token:xyz":"abcd"}, "result":false}
 			  ,
@@ -39,7 +39,7 @@
 			  ,
 			  { "name":"hdfs-agent-test-11","input":"/tmp/tmpdir4/", "evalContext": {"token:FILENAME":
""}, "result":true}
 			  ,
-			  { "name":"hdfs-agent-test-12","input":"/tmp/tmpdir4/%FILENAME%", "evalContext": {"token:USER":
"admin"}, "result":false}
+			  { "name":"hdfs-agent-test-12","input":"/tmp/tmpdir4/%FILENAME%", "evalContext": {"token:USER":
"admin"}, "result":true}
 			  ,
 			  { "name":"hdfs-agent-test-13","input":"/tmp/tmpdir5/data-file.txt", "evalContext": {"token:BASE_FILENAME":
"data-file"}, "result":true}
 			  ,

http://git-wip-us.apache.org/repos/asf/ranger/blob/641e5ce4/agents-common/src/test/resources/resourcematcher/test_resourcematcher_wildcards_as_delimiters.json
----------------------------------------------------------------------
diff --git a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_wildcards_as_delimiters.json
b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_wildcards_as_delimiters.json
index c907f41..8e791d6 100644
--- a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_wildcards_as_delimiters.json
+++ b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_wildcards_as_delimiters.json
@@ -17,7 +17,7 @@
 			  ,
 			  { "name":"exact-path","input":"/abcw", "evalContext": {"token:somestuff": "somethingelse"},
"result":false}
 			  ,
-			  { "name":"exact-path","input":"/abc*xyz?w", "evalContext": {"token:somestuff": "somethingelse"},
"result":false}
+			  { "name":"exact-path","input":"/abc*xyz?w", "evalContext": {"token:somestuff": "somethingelse"},
"result":true}
 			  ,
 			  { "name":"exact-path","input":"/abcabcdw", "evalContext": {"token:somestuff": "somethingelse",
"token:xyz":"abcd"}, "result":true}
 			  ,


Mime
View raw message