ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject [11/28] ranger git commit: RANGER-2180: Handle token replacement correctly when token is not defined in the request context
Date Tue, 04 Sep 2018 12:58:21 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/87fccb54
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/87fccb54
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/87fccb54

Branch: refs/heads/ranger-1.1
Commit: 87fccb548a7c8499ca8d71bc6f306a4c93dd2f0a
Parents: ae728a7
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Thu Aug 2 08:26:28 2018 -0700
Committer: Mehul Parikh <mehul@apache.org>
Committed: Tue Sep 4 11:35:37 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/87fccb54/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/87fccb54/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/87fccb54/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