Skip to content

Commit

Permalink
Truncate batch.desc and hive.batch.desc to shorter length. Do not inc…
Browse files Browse the repository at this point in the history
…lude where clause which may leak user information.
  • Loading branch information
dcfocus committed May 3, 2019
1 parent fa6e707 commit 861bc2a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ql/src/java/org/apache/hadoop/hive/ql/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -538,13 +539,19 @@ public void run() {
conf.set("mapreduce.workflow.name", queryStr);

String timeStamp = Long.toString(System.currentTimeMillis());
conf.set("batch.desc", queryStr + '_' + timeStamp);
conf.set("hive.batch.desc", queryStr + '_' + timeStamp);
int filterInd = queryStr.toLowerCase().indexOf("where");
String appId = "hive_" + timeStamp + queryStr.substring(0, Math.min(filterInd, 80))
.replace("select", "")
.replace("from", "")
.replace("with", "");
conf.set("batch.desc", appId.replaceAll("\\s+","_"));
conf.set("hive.batch.desc", appId.replaceAll("\\s+","_"));
conf.set("hive.flow.submitted.timestamp", timeStamp);
conf.set("mapreduce.framework.name", "yarn");
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] bytes = digest.digest(queryStr.getBytes(StandardCharsets.UTF_8));
String querySignature = new String(bytes, StandardCharsets.UTF_8);
conf.set("hive.query.signature", querySignature.replaceAll("[^a-zA-Z0-9]+","_"));
conf.set("hive.signature", querySignature.replaceAll("[^a-zA-Z0-9]+","_"));

// initialize FetchTask right here
if (plan.getFetchTask() != null) {
Expand Down

0 comments on commit 861bc2a

Please sign in to comment.