[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:
Yulei-Yang
2022-12-29 14:16:32 +08:00
committed by GitHub
parent 5b09d27d54
commit 7ab6ea684b
2 changed files with 8 additions and 2 deletions

View File

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

View File

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