From 8f4f5f0ff630c457b6eaaa026d907dc8ace5e1bb Mon Sep 17 00:00:00 2001 From: asfasdff Date: Fri, 3 Dec 2021 15:18:51 +0800 Subject: [PATCH 1/5] CodeCheck Signed-off-by: asfasdff --- .../distributeddataservice/app/src/kvstore_meta_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp index 8bdc49d6e..d2eda9eb3 100755 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp @@ -647,7 +647,7 @@ void KvStoreMetaManager::ReKey(const std::string &deviceAccountId, const std::st WriteSecretKeyToMeta(GetMetaKey(deviceAccountId, "default", bundleName, storeId, "KEY"), key); Status status = kvStoreimpl->ReKey(key); if (status == Status::SUCCESS) { - int securityLevel; + int securityLevel = SecurityLevel::NO_LABEL; GetSecurityLevelByBundleName(bundleName, securityLevel); WriteSecretKeyToFile(GetSecretKeyFile(deviceAccountId, bundleName, storeId, securityLevel), key); } @@ -666,7 +666,7 @@ void KvStoreMetaManager::ReKey(const std::string &deviceAccountId, const std::st WriteSecretKeyToMeta(GetMetaKey(deviceAccountId, "default", bundleName, storeId, "SINGLE_KEY"), key); Status status = kvStoreImpl->ReKey(key); if (status == Status::SUCCESS) { - int securityLevel = SecurityLevel::NO_LABEL; + int securityLevel; GetSecurityLevelByBundleName(bundleName, securityLevel); WriteSecretKeyToFile(GetSecretSingleKeyFile(deviceAccountId, bundleName, storeId, securityLevel), key); } -- Gitee From caed4a6f498a76974177cae857ddfefe72567c3e Mon Sep 17 00:00:00 2001 From: asfasdff Date: Mon, 6 Dec 2021 16:46:56 +0800 Subject: [PATCH 2/5] CodeCheck fix Signed-off-by: asfasdff --- .../app/src/kvstore_meta_manager.cpp | 16 ++++++---------- .../app/src/kvstore_meta_manager.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp index d2eda9eb3..c403bd9b4 100755 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp @@ -546,8 +546,7 @@ Status KvStoreMetaManager::RemoveSecretKey(const std::string &deviceAccountId, c status = Status::DB_ERROR; } - int securityLevel = SecurityLevel::NO_LABEL; - GetSecurityLevelByBundleName(bundleName, securityLevel); + int securityLevel = GetSecurityLevelByBundleName(bundleName); std::string secretKeyFile = GetSecretKeyFile(deviceAccountId, bundleName, storeId, securityLevel); bool rmFile = RemoveFile(secretKeyFile); if (!rmFile) { @@ -647,8 +646,7 @@ void KvStoreMetaManager::ReKey(const std::string &deviceAccountId, const std::st WriteSecretKeyToMeta(GetMetaKey(deviceAccountId, "default", bundleName, storeId, "KEY"), key); Status status = kvStoreimpl->ReKey(key); if (status == Status::SUCCESS) { - int securityLevel = SecurityLevel::NO_LABEL; - GetSecurityLevelByBundleName(bundleName, securityLevel); + int securityLevel = GetSecurityLevelByBundleName(bundleName); WriteSecretKeyToFile(GetSecretKeyFile(deviceAccountId, bundleName, storeId, securityLevel), key); } key.assign(key.size(), 0); @@ -666,8 +664,7 @@ void KvStoreMetaManager::ReKey(const std::string &deviceAccountId, const std::st WriteSecretKeyToMeta(GetMetaKey(deviceAccountId, "default", bundleName, storeId, "SINGLE_KEY"), key); Status status = kvStoreImpl->ReKey(key); if (status == Status::SUCCESS) { - int securityLevel; - GetSecurityLevelByBundleName(bundleName, securityLevel); + int securityLevel = GetSecurityLevelByBundleName(bundleName); WriteSecretKeyToFile(GetSecretSingleKeyFile(deviceAccountId, bundleName, storeId, securityLevel), key); } key.assign(key.size(), 0); @@ -1241,16 +1238,15 @@ bool KvStoreMetaManager::GetFullMetaData(std::map &entrie return true; } -bool KvStoreMetaManager::GetSecurityLevelByBundleName(const std::string &bundleName, int &securityLevel) +int KvStoreMetaManager::GetSecurityLevelByBundleName(const std::string &bundleName) { KvStoreMetaData kvStoreMetaData; auto getKvStoreMetaBMeta = GetKvStoreMetaByType(KvStoreMetaData::BUNDLE_NAME, bundleName, kvStoreMetaData); if (!getKvStoreMetaBMeta) { ZLOGE("getkvstore meta by type failed"); - return false; + return SecurityLevel::NO_LABEL; } - securityLevel = kvStoreMetaData.securityLevel; - return true; + return kvStoreMetaData.securityLevel; } bool KvStoreMetaManager::GetKvStoreMetaByType(const std::string &name, const std::string &val, diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.h b/services/distributeddataservice/app/src/kvstore_meta_manager.h index 0d05b68ee..58bf8178a 100755 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.h +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.h @@ -273,7 +273,7 @@ private: Status GetStategyMeta(const std::string &key, std::map> &strategies); - bool GetSecurityLevelByBundleName(const std::string &bundleName, int &securityLevel); + int GetSecurityLevelByBundleName(const std::string &bundleName); bool GetKvStoreMetaByType(const std::string &name, const std::string &val, KvStoreMetaData &metaData); -- Gitee From a865040e0fbcfe14af201582963664fbd84e9156 Mon Sep 17 00:00:00 2001 From: asfasdff Date: Wed, 8 Dec 2021 15:02:06 +0800 Subject: [PATCH 3/5] Sensitive word modification Signed-off-by: asfasdff --- .../distributeddb/src/distributeddb_nb_batch_crud_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_batch_crud_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_batch_crud_test.cpp index 0d1662649..a3c46b856 100755 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_batch_crud_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_batch_crud_test.cpp @@ -2429,7 +2429,7 @@ HWTEST_F(DistributeddbNbBatchCrudTest, TransactionObserver003, TestSize.Level1) } /** - * @tc.steps: step2. start the transaction and putBatch (k3, v3), (k4, v4), ..., (k8, v8) to db. + * @tc.steps: step2. start the transaction and putBatch (k3, v3), (k4, v4), ..., (k8, value8) to db. * @tc.expected: step2. start transaction and putBatch successfully. */ EXPECT_EQ(g_nbBatchCrudDelegate->StartTransaction(), OK); @@ -2448,7 +2448,7 @@ HWTEST_F(DistributeddbNbBatchCrudTest, TransactionObserver003, TestSize.Level1) /** * @tc.steps: step3. commit the transaction and check the observers. * @tc.expected: step3. commit succeed and all of the observers received one insert notify, callbacklist of which - * contains (k4, v4), ..., (k8, v8), all observer received one update notify, callbacklist of which contains + * contains (k4, v4), ..., (k8, value8), all observer received one update notify, callbacklist of which contains * (k2, v3), all observers received one insert notify, callback of which contains (k1, v1), (k3, v3), (k9, v9). */ EXPECT_EQ(g_nbBatchCrudDelegate->Commit(), OK); -- Gitee From ab736022aeb4c03700de799c359a22a60ebc217c Mon Sep 17 00:00:00 2001 From: asfasdff Date: Mon, 13 Dec 2021 10:20:18 +0800 Subject: [PATCH 4/5] "com.huawei" clean up Signed-off-by: asfasdff --- .../adapter/permission/src/permission_validator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp index 575f1b7f4..1563c0717 100755 --- a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp +++ b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp @@ -34,8 +34,8 @@ std::set PermissionValidator::systemServiceList_ = { // initialize auto launch enabled applications white list. std::set PermissionValidator::autoLaunchEnableList_ = { "providers.calendar", - "com.huawei.contacts.sync", - "com.huawei.ohos.totemweather" + "contacts.sync", + "ohos.totemweather" }; // check whether the client process have enough privilege to share data with the other devices. -- Gitee From 2ec8e2ff069457dc2c8685da08a8b1500e84fa77 Mon Sep 17 00:00:00 2001 From: asfasdff Date: Mon, 13 Dec 2021 11:09:15 +0800 Subject: [PATCH 5/5] clean up Signed-off-by: asfasdff --- .../adapter/permission/src/permission_validator.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp index 1563c0717..ed6f14b85 100755 --- a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp +++ b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp @@ -33,9 +33,6 @@ std::set PermissionValidator::systemServiceList_ = { // initialize auto launch enabled applications white list. std::set PermissionValidator::autoLaunchEnableList_ = { - "providers.calendar", - "contacts.sync", - "ohos.totemweather" }; // check whether the client process have enough privilege to share data with the other devices. -- Gitee