You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/19 05:10:51 UTC
[doris] 17/21: [fix](multi-catalog) hidden password for show create jdbc catalog (#15145)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit afbe5ba198f198550185fb474f9fa021e49cc406
Author: xueweizhang <zx...@163.com>
AuthorDate: Sat Dec 17 17:20:17 2022 +0800
[fix](multi-catalog) hidden password for show create jdbc catalog (#15145)
when show create catalog of jdbc, it will show 'jdbc.password' plain text. fix it like other code that hidden password.
---
.../org/apache/doris/common/util/PrintableMap.java | 1 +
.../org/apache/doris/datasource/CatalogMgr.java | 2 +-
.../query_p0/show/test_show_create_catalog.out | 4 ++
.../query_p0/show/test_show_create_catalog.groovy | 46 ++++++++++++++++++++++
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PrintableMap.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PrintableMap.java
index 5f6412bf96..571fa92975 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PrintableMap.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PrintableMap.java
@@ -38,6 +38,7 @@ public class PrintableMap<K, V> {
SENSITIVE_KEY.add("password");
SENSITIVE_KEY.add("kerberos_keytab_content");
SENSITIVE_KEY.add("bos_secret_accesskey");
+ SENSITIVE_KEY.add("jdbc.password");
}
public PrintableMap(Map<K, V> map, String keyValueSeparator,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
index f3b9299bc8..8ea37fd245 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
@@ -387,7 +387,7 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
.append("`");
if (catalog.getProperties().size() > 0) {
sb.append(" PROPERTIES (\n");
- sb.append(new PrintableMap<>(catalog.getProperties(), "=", true, true, false));
+ sb.append(new PrintableMap<>(catalog.getProperties(), "=", true, true, true));
sb.append("\n);");
}
diff --git a/regression-test/data/query_p0/show/test_show_create_catalog.out b/regression-test/data/query_p0/show/test_show_create_catalog.out
new file mode 100644
index 0000000000..92fa98548a
--- /dev/null
+++ b/regression-test/data/query_p0/show/test_show_create_catalog.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+test_show_create_mysql_jdbc_catalog CREATE CATALOG `test_show_create_mysql_jdbc_catalog` PROPERTIES (\n"jdbc.password" = "*XXX",\n"jdbc.driver_class" = "com.mysql.cj.jdbc.Driver",\n"jdbc.user" = "root",\n"jdbc.jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false",\n"jdbc.driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar",\n"type" = "jdbc"\n);
+
diff --git a/regression-test/suites/query_p0/show/test_show_create_catalog.groovy b/regression-test/suites/query_p0/show/test_show_create_catalog.groovy
new file mode 100644
index 0000000000..a30adab3c5
--- /dev/null
+++ b/regression-test/suites/query_p0/show/test_show_create_catalog.groovy
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_show_create_catalog", "query") {
+ String catalog_name = "test_show_create_mysql_jdbc_catalog";
+ try {
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ String mysql_port = context.config.otherConfigs.get("mysql_57_port");
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ sql """admin set frontend config ("enable_multi_catalog" = "true")"""
+
+ sql """drop catalog if exists ${catalog_name} """
+
+ // if use 'com.mysql.cj.jdbc.Driver' here, it will report: ClassNotFound
+ sql """ CREATE CATALOG ${catalog_name} PROPERTIES (
+ "type"="jdbc",
+ "jdbc.user"="root",
+ "jdbc.password"="123456",
+ "jdbc.jdbc_url" = "jdbc:mysql://127.0.0.1:${mysql_port}/doris_test?useSSL=false",
+ "jdbc.driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar",
+ "jdbc.driver_class" = "com.mysql.cj.jdbc.Driver");
+ """
+
+ qt_select "show create catalog `${catalog_name}`"
+
+ }
+ } finally {
+
+ try_sql("DROP CATALOG IF EXISTS `${catalog_name}`")
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org