[Improvement](meta) hide password of show catalog xxx stmt and for es catalog (#15410)
* [Improvement](meta) hide password of show catalog xxx * hide es password in show create ctlg and show ctlg xx stmt
This commit is contained in:
@ -32,6 +32,7 @@ public class PrintableMap<K, V> {
|
||||
private String entryDelimiter = ",";
|
||||
|
||||
public static final Set<String> SENSITIVE_KEY;
|
||||
public static final String PASSWORD_MASK = "*XXX";
|
||||
|
||||
static {
|
||||
SENSITIVE_KEY = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
|
||||
@ -39,6 +40,7 @@ public class PrintableMap<K, V> {
|
||||
SENSITIVE_KEY.add("kerberos_keytab_content");
|
||||
SENSITIVE_KEY.add("bos_secret_accesskey");
|
||||
SENSITIVE_KEY.add("jdbc.password");
|
||||
SENSITIVE_KEY.add("elasticsearch.password");
|
||||
}
|
||||
|
||||
public PrintableMap(Map<K, V> map, String keyValueSeparator,
|
||||
@ -80,7 +82,7 @@ public class PrintableMap<K, V> {
|
||||
sb.append("\"");
|
||||
}
|
||||
if (hidePassword && SENSITIVE_KEY.contains(entry.getKey())) {
|
||||
sb.append("*XXX");
|
||||
sb.append(PASSWORD_MASK);
|
||||
} else {
|
||||
sb.append(entry.getValue());
|
||||
}
|
||||
|
||||
@ -396,7 +396,11 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
|
||||
rows.add(Arrays.asList("resource", catalog.getResource()));
|
||||
}
|
||||
for (Map.Entry<String, String> elem : catalog.getProperties().entrySet()) {
|
||||
rows.add(Arrays.asList(elem.getKey(), elem.getValue()));
|
||||
if (PrintableMap.SENSITIVE_KEY.contains(elem.getKey())) {
|
||||
rows.add(Arrays.asList(elem.getKey(), PrintableMap.PASSWORD_MASK));
|
||||
} else {
|
||||
rows.add(Arrays.asList(elem.getKey(), elem.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user