[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.
This commit is contained in:
xueweizhang
2022-12-17 17:20:17 +08:00
committed by GitHub
parent 56cd1faeaf
commit 6aba948df0
4 changed files with 52 additions and 1 deletions

View File

@ -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,

View File

@ -398,7 +398,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);");
}

View File

@ -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);

View File

@ -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}`")
}
}