From 6a2e8178cba048a59b7e9c987aa94627948a3c91 Mon Sep 17 00:00:00 2001 From: wangbin Date: Thu, 19 Jun 2025 10:43:05 +0800 Subject: [PATCH] Anonymized printing of sensitive information Signed-off-by: wangbin --- .../service/kvdb/kvdb_general_store.cpp | 10 ++++++---- .../service/kvdb/query_helper.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp index b2fab36ce..6c8f92afa 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_general_store.cpp @@ -467,16 +467,18 @@ void KVDBGeneralStore::SetEqualIdentifier(const std::string &appId, const std::s auto accountId = account.empty() ? AccountDelegate::GetInstance()->GetUnencryptedAccountId() : account; auto convertedIds = AppIdMappingConfigManager::GetInstance().Convert(appId, accountId); auto identifier = KvManager::GetKvStoreIdentifier(convertedIds.second, convertedIds.first, storeId); - ZLOGI("same account store:%{public}s, user:%{public}s, device:%{public}.10s, appId:%{public}s", + ZLOGI("same account store:%{public}s, user:%{public}s, device:%{public}s, appId:%{public}s", Anonymous::Change(storeId).c_str(), Anonymous::Change(convertedIds.second).c_str(), - DistributedData::Serializable::Marshall(sameAccountDevs).c_str(), convertedIds.first.c_str()); + Anonymous::Change(DistributedData::Serializable::Marshall(sameAccountDevs)).c_str(), + convertedIds.first.c_str()); delegate_->SetEqualIdentifier(identifier, sameAccountDevs); } if (!defaultAccountDevs.empty()) { auto convertedIds = AppIdMappingConfigManager::GetInstance().Convert(appId, defaultAccountId); auto identifier = KvManager::GetKvStoreIdentifier(convertedIds.second, convertedIds.first, storeId); - ZLOGI("no account store:%{public}s, device:%{public}.10s, appId:%{public}s", Anonymous::Change(storeId).c_str(), - DistributedData::Serializable::Marshall(defaultAccountDevs).c_str(), convertedIds.first.c_str()); + ZLOGI("no account store:%{public}s, device:%{public}s, appId:%{public}s", Anonymous::Change(storeId).c_str(), + Anonymous::Change(DistributedData::Serializable::Marshall(defaultAccountDevs)).c_str(), + convertedIds.first.c_str()); delegate_->SetEqualIdentifier(identifier, defaultAccountDevs); } } diff --git a/services/distributeddataservice/service/kvdb/query_helper.cpp b/services/distributeddataservice/service/kvdb/query_helper.cpp index f877df1f2..c1bd2d6c0 100644 --- a/services/distributeddataservice/service/kvdb/query_helper.cpp +++ b/services/distributeddataservice/service/kvdb/query_helper.cpp @@ -21,6 +21,7 @@ #include "kvstore_utils.h" #include "log_print.h" #include "types.h" +#include "utils/anonymous.h" namespace OHOS::DistributedKv { constexpr int QUERY_SKIP_SIZE = 1; constexpr int QUERY_WORD_SIZE = 2; @@ -559,7 +560,7 @@ bool QueryHelper::HandleInKeys(const std::vector &words, int &point const std::vector inKeys = GetStringList(words, inkeyOffSet, end); std::set> inDbKeys; for (const std::string &inKey : inKeys) { - ZLOGI("inKey=%{public}s", inKey.c_str()); + ZLOGI("inKey=%{public}s", DistributedData::Anonymous::Change(inKey).c_str()); std::vector dbKey; dbKey.assign(inKey.begin(), inKey.end()); inDbKeys.insert(dbKey); -- Gitee