Skip to content

Commit 9009a30

Browse files
HIVE-28838: Remove sensitive jdbc properties from JdbcStorageHandler tables
1 parent 28abf17 commit 9009a30

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/conf/JdbcStorageConfigManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class JdbcStorageConfigManager {
4545
public static final String CONFIG_PWD_KEYSTORE = Constants.JDBC_KEYSTORE;
4646
public static final String CONFIG_PWD_KEY = Constants.JDBC_KEY;
4747
public static final String CONFIG_PWD_URI = Constants.JDBC_PASSWORD_URI;
48+
public static final String CONFIG_JDBC_USERNAME = Constants.JDBC_USERNAME;
49+
4850
private static final EnumSet<JdbcStorageConfig> DEFAULT_REQUIRED_PROPERTIES =
4951
EnumSet.of(JdbcStorageConfig.DATABASE_TYPE,
5052
JdbcStorageConfig.JDBC_URL,
@@ -66,7 +68,9 @@ public static void copyConfigurationToJob(Properties props, Map<String, String>
6668
if (!key.equals(CONFIG_PWD) &&
6769
!key.equals(CONFIG_PWD_KEYSTORE) &&
6870
!key.equals(CONFIG_PWD_KEY) &&
69-
!key.equals(CONFIG_PWD_URI)) {
71+
!key.equals(CONFIG_PWD_URI) &&
72+
!key.equals(CONFIG_JDBC_USERNAME)
73+
) {
7074
jobProps.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
7175
}
7276
}

ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package org.apache.hadoop.hive.ql.plan;
2020

2121
import static org.apache.commons.lang3.StringUtils.isNotBlank;
22+
import static org.apache.hadoop.hive.conf.Constants.JDBC_PASSWORD;
23+
import static org.apache.hadoop.hive.conf.Constants.JDBC_USERNAME;
2224
import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_LOCATION;
2325
import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.TABLE_IS_CTAS;
2426
import static org.apache.hive.common.util.HiveStringUtils.quoteComments;
@@ -1230,7 +1232,11 @@ public static Class<? extends AbstractSerDe> getDefaultSerDe() {
12301232
return LazySimpleSerDe.class;
12311233
}
12321234

1233-
private static final String[] FILTER_OUT_FROM_EXPLAIN = {TABLE_IS_CTAS};
1235+
private static final String[] FILTER_OUT_FROM_EXPLAIN = {
1236+
TABLE_IS_CTAS,
1237+
JDBC_USERNAME,
1238+
JDBC_PASSWORD
1239+
};
12341240

12351241
/**
12361242
* Get a Map of table or partition properties to be used in explain extended output.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--! qt:sysdb
2+
3+
select 1
4+
from sys.TBLS t
5+
join sys.DBS d on t.DB_ID = d.DB_ID
6+
limit 1;
7+
8+
explain extended
9+
select 1
10+
from sys.TBLS t
11+
join sys.DBS d on t.DB_ID = d.DB_ID
12+
limit 1;
13+
14+
show create table sys.DBS;
15+
16+
describe formatted sys.DBS;
17+
18+
create table if not exists ctas_dbs as select * from sys.DBS;
19+
20+
select 1
21+
from sys.TBLS t
22+
join ctas_dbs d on t.DB_ID = d.DB_ID
23+
limit 1;
24+
25+
explain extended
26+
select 1
27+
from sys.TBLS t
28+
join ctas_dbs d on t.DB_ID = d.DB_ID
29+
limit 1;
30+
31+
create table if not exists ctlt_dbs like sys.DBS;
32+
33+
insert into ctlt_dbs
34+
select * from sys.DBS;
35+
36+
select 1
37+
from sys.TBLS t
38+
join ctlt_dbs d on t.DB_ID = d.DB_ID
39+
limit 1;
40+
41+
explain extended
42+
select 1
43+
from sys.TBLS t
44+
join ctlt_dbs d on t.DB_ID = d.DB_ID
45+
limit 1;
Binary file not shown.

0 commit comments

Comments
 (0)