mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-08 14:39:10 +00:00
fix(cli): sanitize store_addrs in kvbackend build log (#8967)
* fix(cli): sanitize store_addrs in kvbackend build log Close #7525. The CLI's kvbackend construction log was printing raw store_addrs which could contain sensitive connection strings (e.g. PostgreSQL DSNs with passwords). Changes: - Add sanitize_store_addrs() helper that reuses common_meta::kv_backend::util::sanitize_connection_string(), consistent with MetasrvOptions and StartCommand patterns. - Replace raw store_addrs in the info! log with sanitized version. - Add unit tests covering MySQL URLs, PostgreSQL DSNs, etcd addresses, and empty store_addrs cases. Signed-off-by: qiang_liu Signed-off-by: qiang_liu <qiang_liu@trendmicro.com> Signed-off-by: LiuQhahah <liuqiang9596@gmail.com> * fix(cli): drop redundant sanitize tests per review sanitize_connection_string in common_meta already covers MySQL URLs, PostgreSQL DSNs and credential-free etcd addresses with its own tests. The added tests only exercised a trivial map+collect wrapper, so remove them per review nit. Signed-off-by: LiuQhahah <liuqiang9596@gmail.com> --------- Signed-off-by: qiang_liu Signed-off-by: qiang_liu <qiang_liu@trendmicro.com> Signed-off-by: LiuQhahah <liuqiang9596@gmail.com> Co-authored-by: dennis zhuang <killme2008@gmail.com>
This commit is contained in:
co-authored by
dennis zhuang
parent
307fe0a692
commit
ad5ccc98ec
@@ -125,6 +125,14 @@ impl StoreConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sanitize store addrs for logging (redacts passwords in connection strings).
|
||||
fn sanitize_store_addrs(&self) -> Vec<String> {
|
||||
self.store_addrs
|
||||
.iter()
|
||||
.map(|addr| common_meta::kv_backend::util::sanitize_connection_string(addr))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Builds a [`KvBackendRef`] from the store configuration.
|
||||
pub async fn build(&self) -> Result<KvBackendRef, BoxedError> {
|
||||
let max_txn_ops = self.max_txn_ops;
|
||||
@@ -134,7 +142,7 @@ impl StoreConfig {
|
||||
} else {
|
||||
common_telemetry::info!(
|
||||
"Building kvbackend with store addrs: {:?}, backend: {:?}",
|
||||
store_addrs,
|
||||
&self.sanitize_store_addrs(),
|
||||
self.backend
|
||||
);
|
||||
let kvbackend = match self.backend {
|
||||
|
||||
Reference in New Issue
Block a user