You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2015/10/29 05:24:55 UTC
hive git commit: HIVE-12282: beeline - update command printing in
verbose mode (Daniel Dai, reviewed by Thejas Nair, Lefty Leverenz)
Repository: hive
Updated Branches:
refs/heads/master 99a043a05 -> 63dc1fa61
HIVE-12282: beeline - update command printing in verbose mode (Daniel Dai, reviewed by Thejas Nair, Lefty Leverenz)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/63dc1fa6
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/63dc1fa6
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/63dc1fa6
Branch: refs/heads/master
Commit: 63dc1fa61d071b64664c5b7dfb700b9c18bcca50
Parents: 99a043a
Author: Daniel Dai <da...@hortonworks.com>
Authored: Wed Oct 28 21:24:42 2015 -0700
Committer: Daniel Dai <da...@hortonworks.com>
Committed: Wed Oct 28 21:24:42 2015 -0700
----------------------------------------------------------------------
.../java/org/apache/hive/beeline/BeeLine.java | 22 ++++++++++++++------
.../hive/beeline/TestBeelineArgParsing.java | 18 +++++++++++++++-
2 files changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/63dc1fa6/beeline/src/java/org/apache/hive/beeline/BeeLine.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
index 4e04997..377703f 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -151,6 +151,7 @@ public class BeeLine implements Closeable {
private static final String HIVE_VAR_PREFIX = "--hivevar";
private static final String HIVE_CONF_PREFIX = "--hiveconf";
+ static final String PASSWD_MASK = "[passwd stripped]";
private final Map<Object, Object> formats = map(new Object[] {
"vertical", new VerticalOutputFormat(this),
@@ -768,12 +769,9 @@ public class BeeLine implements Closeable {
*/
if (url != null) {
- String com = "!connect "
- + url + " "
- + (user == null || user.length() == 0 ? "''" : user) + " "
- + (pass == null || pass.length() == 0 ? "''" : pass) + " "
- + (driver == null ? "" : driver);
- debug("issuing: " + com);
+ String com = constructCmd(url, user, pass, driver, false);
+ String comForDebug = constructCmd(url, user, pass, driver, true);
+ debug("issuing: " + comForDebug);
dispatch(com);
}
@@ -796,6 +794,18 @@ public class BeeLine implements Closeable {
return code;
}
+ private String constructCmd(String url, String user, String pass, String driver, boolean stripPasswd) {
+ String com = "!connect "
+ + url + " "
+ + (user == null || user.length() == 0 ? "''" : user) + " ";
+ if (stripPasswd) {
+ com += PASSWD_MASK + " ";
+ } else {
+ com += (pass == null || pass.length() == 0 ? "''" : pass) + " ";
+ }
+ com += (driver == null ? "" : driver);
+ return com;
+ }
/**
* Obtains a password from the passed file path.
*/
http://git-wip-us.apache.org/repos/asf/hive/blob/63dc1fa6/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
----------------------------------------------------------------------
diff --git a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
index 06d6ffe..80c6e06 100644
--- a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
+++ b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
@@ -23,9 +23,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-
import java.io.File;
import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -244,4 +246,18 @@ public class TestBeelineArgParsing {
Assert.assertEquals(bl.findLocalDriver(connectionString).getClass().getName(), driverClazzName);
}
}
+
+ @Test
+ public void testBeelinePasswordMask() throws Exception {
+ TestBeeline bl = new TestBeeline();
+ File errFile = File.createTempFile("test", "tmp");
+ bl.setErrorStream(new PrintStream(new FileOutputStream(errFile)));
+ String args[] =
+ new String[] { "-u", "url", "-n", "name", "-p", "password", "-d", "driver",
+ "--autoCommit=true", "--verbose", "--truncateTable" };
+ bl.initArgs(args);
+ bl.close();
+ String errContents = new String(Files.readAllBytes(Paths.get(errFile.toString())));
+ Assert.assertTrue(errContents.contains(BeeLine.PASSWD_MASK));
+ }
}