From 19ae15fb1010ba5f043cd8e26e1593c579c88341 Mon Sep 17 00:00:00 2001 From: jiangminsen Date: Tue, 20 Feb 2024 16:31:34 +0800 Subject: [PATCH] =?UTF-8?q?dbms=E6=B7=BB=E5=8A=A0=E6=8E=A5=E7=BB=AD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=89=93=E5=8D=B0db=E4=B8=AD=E8=AE=BE?= =?UTF-8?q?=E5=A4=87udid=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangminsen --- .../dbms/include/distributed_data_storage.h | 2 +- .../dbms/src/distributed_data_storage.cpp | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/services/dbms/include/distributed_data_storage.h b/services/dbms/include/distributed_data_storage.h index 623243d..cae44d8 100644 --- a/services/dbms/include/distributed_data_storage.h +++ b/services/dbms/include/distributed_data_storage.h @@ -55,7 +55,7 @@ private: bool InnerSaveStorageDistributeInfo(const DistributedBundleInfo &distributedBundleInfo); std::map GetAllOldDistributionBundleInfo( const std::vector &bundleNames); - + static std::string AnonymizeUdid(const std::string& udid); private: static std::mutex mutex_; static std::shared_ptr instance_; diff --git a/services/dbms/src/distributed_data_storage.cpp b/services/dbms/src/distributed_data_storage.cpp index 15f8e93..b045548 100644 --- a/services/dbms/src/distributed_data_storage.cpp +++ b/services/dbms/src/distributed_data_storage.cpp @@ -15,6 +15,7 @@ #include "distributed_data_storage.h" +#include #include #include "account_manager_helper.h" @@ -29,12 +30,16 @@ namespace AppExecFwk { namespace { const std::string BMS_KV_BASE_DIR = "/data/service/el1/public/database/"; const int32_t EL1 = 1; +const int32_t START_INDEX = 0; const int32_t MAX_TIMES = 600; // 1min +const int32_t UDID_LENGTH = 64; // the length of udid +const int32_t PRINTF_LENGTH = 8; // print length of udid const int32_t SLEEP_INTERVAL = 100 * 1000; // 100ms const int32_t FLAGS = BundleFlag::GET_BUNDLE_WITH_ABILITIES | ApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE | AbilityInfoFlag::GET_ABILITY_INFO_WITH_DISABLE; const uint32_t DEVICE_UDID_LENGTH = 65; +const std::string EMPTY_DEVICE_ID = ""; } // namespace std::shared_ptr DistributedDataStorage::instance_ = nullptr; @@ -223,9 +228,13 @@ int32_t DistributedDataStorage::GetDistributedBundleName(const std::string &netw APP_LOGE("dataManager_ GetEntries error: %{public}d", status); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; } + std::set udidSet; for (auto entry : allEntries) { std::string key = entry.key.ToString(); std::string value = entry.value.ToString(); + if (key.length() > UDID_LENGTH) { + udidSet.insert(key.substr(START_INDEX, UDID_LENGTH)); + } if (key.find(udid) == std::string::npos) { continue; } @@ -237,9 +246,22 @@ int32_t DistributedDataStorage::GetDistributedBundleName(const std::string &netw } APP_LOGE("get distributed bundleName no matching data: %{private}s %{private}s %{private}d", networkId.c_str(), udid.c_str(), accessTokenId); + for (std::string udidItem : udidSet) { + APP_LOGW("dbms db has keyItem :%{public}s", AnonymizeUdid(udidItem).c_str()); + } return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; } +std::string DistributedDataStorage::AnonymizeUdid(const std::string& udid) +{ + if (udid.length() < PRINTF_LENGTH) { + return EMPTY_DEVICE_ID; + } + std::string anonUdid = udid.substr(START_INDEX, PRINTF_LENGTH); + anonUdid.append("******"); + return anonUdid; +} + std::string DistributedDataStorage::DeviceAndNameToKey( const std::string &udid, const std::string &bundleName) const { -- Gitee