diff --git a/test/commonfuzztest/BUILD.gn b/test/commonfuzztest/BUILD.gn index 6ee840205255accc6ca995acf1e1c6db6b117767..3827ec98f2bb4f58821fc4ccfd77d2f6170c6d7f 100644 --- a/test/commonfuzztest/BUILD.gn +++ b/test/commonfuzztest/BUILD.gn @@ -31,6 +31,8 @@ group("fuzztest") { "generateencrypteduuid_fuzzer:fuzztest", "getdeviceinfo_fuzzer:fuzztest", "hichainconnector_fuzzer:fuzztest", + "jsonobjectcjson_fuzzer:fuzztest", + "jsonobjectnlohmannjson_fuzzer:fuzztest", "ondatareceived_fuzzer:fuzztest", "ondatareceivedv2_fuzzer:fuzztest", "onerror_fuzzer:fuzztest", diff --git a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp index aa4d0fd09e8431d8c8d9ea1f5dcda1ee8c8fe8c0..0b1103234ecf676347497848a63548f495a5cae1 100644 --- a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp +++ b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp @@ -32,11 +32,19 @@ void AuthAclFuzzTest(const uint8_t* data, size_t size) FuzzedDataProvider fdp(data, size); int32_t sessionId = fdp.ConsumeIntegral(); std::string result = fdp.ConsumeRandomLengthString(); - std::shared_ptr authSink = std::make_shared(); - std::shared_ptr authSrc = std::make_shared(); + std::shared_ptr authSink = std::make_shared(); + std::shared_ptr authSrc = std::make_shared(); authSink->GetStateType(); authSrc->GetStateType(); + + std::shared_ptr context = std::make_shared(); + context->accesser.dmVersion = DM_VERSION_5_1_0; + context->accesser.isCommonFlag = true; + authSink->VerifyCertificate(context); + context->accesser.isCommonFlag = false; + authSink->VerifyCertificate(context); + authSink->VerifyCertificate(nullptr); } } } diff --git a/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp b/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp index 4f5e040fc21ccf52b21c41c0f30a38a739ceb433..df8f7027ae254006ef23ff03837de4bc80bcf4d2 100644 --- a/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp +++ b/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp @@ -41,7 +41,7 @@ void AuthCredentialFuzzTest(const uint8_t* data, size_t size) context->isAppCredentialVerified = false; context->accesser.bindLevel = SERVICE; std::shared_ptr authFirst = std::make_shared(); - std::shared_ptr authSecond = std::make_shared(); + std::shared_ptr authSecond = std::make_shared(); std::shared_ptr authThird = std::make_shared(); std::shared_ptr authForth = std::make_shared(); std::shared_ptr authFifth = std::make_shared(); @@ -54,6 +54,7 @@ void AuthCredentialFuzzTest(const uint8_t* data, size_t size) context->accesser.isGenerateLnnCredential = false; authFirst->GetStateType(); authSecond->GetStateType(); + authSecond->GenerateCertificate(context); authThird->GetStateType(); authForth->GetStateType(); authFifth->GetStateType(); diff --git a/test/commonfuzztest/authenticatedevice_fuzzer/authenticate_device_fuzzer.cpp b/test/commonfuzztest/authenticatedevice_fuzzer/authenticate_device_fuzzer.cpp index a0b1e8738cf53e4627cc68c76c8be27d6e67ac7a..0303783dea9f30ecbbe53d00b3949ad8e3bb10e2 100644 --- a/test/commonfuzztest/authenticatedevice_fuzzer/authenticate_device_fuzzer.cpp +++ b/test/commonfuzztest/authenticatedevice_fuzzer/authenticate_device_fuzzer.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -86,6 +87,12 @@ public: void OnCall(const std::string ¶mJson) override {} }; +class DeviceScreenStatusCallbackTest : public DeviceScreenStatusCallback { +public: + virtual ~DeviceScreenStatusCallbackTest() {} + void OnDeviceScreenStatus(const DmDeviceInfo &deviceInfo) override {} +}; + std::string g_returnStr; std::string g_reqJsonStr = R"( { @@ -216,6 +223,7 @@ void AuthenticateDeviceFirstFuzzTest(const uint8_t* data, size_t size) DeviceManager::GetInstance().RegisterDevStatusCallback(str, str, g_statusCallback); DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(str, g_Uicallback); std::string emptyStr = ""; + DeviceManager::GetInstance().RegisterDevStateCallback(emptyStr, str, g_stateCallback); DeviceManager::GetInstance().AuthenticateDevice(str, g_authType, g_deviceInfo, emptyStr, g_callbackk); DeviceManager::GetInstance().UnAuthenticateDevice(str, g_deviceInfo); std::string pkgName = "pkgName"; @@ -278,6 +286,7 @@ void AuthenticateDeviceThirdFuzzTest(const uint8_t* data, size_t size) DeviceManager::GetInstance().UnBindDevice(str, g_deviceInfo.deviceId); DeviceManager::GetInstance().UnRegisterDeviceManagerFaCallback(str); DeviceManager::GetInstance().UnRegisterDevStateCallback(str); + DeviceManager::GetInstance().UnRegisterDevStateCallback(emptyStr); DeviceManager::GetInstance().UnRegisterDevStatusCallback(str); std::map authParam; authParam[DM_AUTHENTICATION_TYPE] = str; @@ -332,6 +341,7 @@ void AuthenticateDeviceFourthFuzzTest(const uint8_t* data, size_t size) DeviceManagerImpl::GetInstance().RemovePublishCallback("test"); DeviceManagerImpl::GetInstance().RegisterPinHolderCallback(str, nullptr); DeviceManagerImpl::GetInstance().GetDeviceSecurityLevel(str, emptyStr, indexTwo); + DeviceManagerImpl::GetInstance().GetDeviceSecurityLevel(str, str, indexTwo); DeviceManagerImpl::GetInstance().IsSameAccount(emptyStr); } @@ -371,19 +381,42 @@ void AuthenticateDeviceFifthFuzzTest(const uint8_t* data, size_t size) DeviceManagerImpl::GetInstance().BindDevice(str, 1, emptyStr, emptyStr, nullptr); DeviceManagerImpl::GetInstance().UnBindDevice(str, emptyStr); DeviceManagerImpl::GetInstance().GetNetworkTypeByNetworkId(str, emptyStr, indexTwo); + DeviceManagerImpl::GetInstance().GetNetworkTypeByNetworkId(str, str, indexTwo); DeviceManagerImpl::GetInstance().ImportAuthCode(emptyStr, emptyStr); + DeviceManagerImpl::GetInstance().ImportAuthCode(str, str); + std::string authCode = "123456"; + DeviceManagerImpl::GetInstance().ImportAuthCode(str, authCode); DeviceManagerImpl::GetInstance().ExportAuthCode(g_returnStr); +} + +void AuthenticateDeviceSixthFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + AddPermission(); + FuzzedDataProvider fdp(data, size); + std::string str = fdp.ConsumeRandomLengthString(); + + std::string emptyStr = ""; + int32_t indexTwo = 2; std::map discoverParam; DeviceManagerImpl::GetInstance().StartDiscovering(str, discoverParam, discoverParam, nullptr); DeviceManagerImpl::GetInstance().StopDiscovering(str, discoverParam); DeviceManagerImpl::GetInstance().RegisterDiscoveryCallback(str, discoverParam, discoverParam, nullptr); DeviceManagerImpl::GetInstance().UnRegisterDiscoveryCallback(str); + DeviceManagerImpl::GetInstance().UnRegisterDiscoveryCallback(emptyStr); DeviceManagerImpl::GetInstance().StartAdvertising(str, discoverParam, nullptr); + DeviceManagerImpl::GetInstance().StartAdvertising(str, discoverParam, g_publishCallback); DeviceManagerImpl::GetInstance().StopAdvertising(str, discoverParam); DeviceManagerImpl::GetInstance().SetDnPolicy(str, discoverParam); DeviceManagerImpl::GetInstance().RegisterDeviceScreenStatusCallback(emptyStr, nullptr); DeviceManagerImpl::GetInstance().UnRegisterDeviceScreenStatusCallback(emptyStr); + std::shared_ptr callback = std::make_shared(); + DeviceManagerImpl::GetInstance().RegisterDeviceScreenStatusCallback(str, callback); + DeviceManagerImpl::GetInstance().UnRegisterDeviceScreenStatusCallback(str); DeviceManagerImpl::GetInstance().GetDeviceScreenStatus(emptyStr, emptyStr, indexTwo); + DeviceManagerImpl::GetInstance().GetDeviceScreenStatus(str, str, indexTwo); } } } @@ -397,5 +430,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::DistributedHardware::AuthenticateDeviceThirdFuzzTest(data, size); OHOS::DistributedHardware::AuthenticateDeviceFourthFuzzTest(data, size); OHOS::DistributedHardware::AuthenticateDeviceFifthFuzzTest(data, size); + OHOS::DistributedHardware::AuthenticateDeviceSixthFuzzTest(data, size); return 0; } diff --git a/test/commonfuzztest/authpinauth_fuzzer/auth_pin_auth_fuzzer.cpp b/test/commonfuzztest/authpinauth_fuzzer/auth_pin_auth_fuzzer.cpp index 57f4b469bab442b6b26c4d20634da0dd810abb3e..9c40d6255357cc018660bbd6b4c82b22213f4a5b 100644 --- a/test/commonfuzztest/authpinauth_fuzzer/auth_pin_auth_fuzzer.cpp +++ b/test/commonfuzztest/authpinauth_fuzzer/auth_pin_auth_fuzzer.cpp @@ -49,10 +49,13 @@ void AuthPinAuthFuzzTest(const uint8_t* data, size_t size) auth2->GetStateType(); int32_t credType = fdp.ConsumeIntegral(); auth3->GetCredIdByCredType(context, credType); + context->pinNegotiateStarted = false; + auth3->ProcessPinBind(context); context->isAppCredentialVerified = true; context->accesser.isGenerateLnnCredential = false; context->listener = std::make_shared(); auth4->ShowStartAuthDialog(context); + auth4->Action(context); auth5->GetStateType(); auth6->GetStateType(); auth7->GetStateType(); diff --git a/test/commonfuzztest/dmfreezeprocess_fuzzer/dm_freeze_process_fuzzer.cpp b/test/commonfuzztest/dmfreezeprocess_fuzzer/dm_freeze_process_fuzzer.cpp index b839f6b471d00cdbecfa13d1a93b394289f7b33c..da9dccfd883cd02f7dea18e068feaf1ec49e03e3 100644 --- a/test/commonfuzztest/dmfreezeprocess_fuzzer/dm_freeze_process_fuzzer.cpp +++ b/test/commonfuzztest/dmfreezeprocess_fuzzer/dm_freeze_process_fuzzer.cpp @@ -58,6 +58,8 @@ void DmFreezeProcessFuzzTest(const uint8_t *data, size_t size) FreezeProcess::GetInstance().ConvertJsonToBindFailedEvents(result, bindFailedEvents); bundleName = fdp.ConsumeRandomLengthString(); deviceType = fdp.ConsumeIntegral(); + freezeStateObj.startFreezeTimeStamp = fdp.ConsumeIntegral(); + FreezeProcess::GetInstance().freezeStateCache_ = freezeStateObj; FreezeProcess::GetInstance().CleanBindFailedEvents(reservedDataTimeStamp); FreezeProcess::GetInstance().CleanFreezeState(reservedDataTimeStamp); FreezeProcess::GetInstance().ConvertDeviceFreezeStateToJson(freezeStateObj, result); @@ -74,6 +76,8 @@ void DmFreezeProcessFuzzTest(const uint8_t *data, size_t size) nowTime = MAX_FREEZE_TIME; FreezeProcess::GetInstance().CalculateNextFreezeTime(nowTime, nextTime); FreezeProcess::GetInstance().DeleteFreezeRecord(); + FreezeProcess::GetInstance().UpdateFreezeRecord(); + FreezeProcess::GetInstance().ConvertBindFailedEventsToJson(bindFailedEvents, result); } } } diff --git a/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp b/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp index 4e8f148016301f3633103deaeeb7e2483a0e9075..856d739cf6f38a9f4bf2fcb0fda03eff49b97494 100644 --- a/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp +++ b/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp @@ -72,6 +72,16 @@ void AddGroupInfo(std::vector &groupList) groupList.push_back(groupInfo2); } +void GenerateJsonObject(JsonObject &jsonObject, FuzzedDataProvider &fdp) +{ + jsonObject[FIELD_GROUP_NAME] = fdp.ConsumeRandomLengthString(); + jsonObject[FIELD_GROUP_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[FIELD_GROUP_OWNER] = fdp.ConsumeRandomLengthString(); + jsonObject[FIELD_GROUP_TYPE] = fdp.ConsumeIntegral(); + jsonObject[FIELD_GROUP_VISIBILITY] = fdp.ConsumeIntegral(); + jsonObject[FIELD_USER_ID] = fdp.ConsumeRandomLengthString(); +} + void AddAclInfo(std::vector> &delACLInfoVec, std::vector &userIdVec) { int32_t key = 12; @@ -349,6 +359,13 @@ void HiChainConnectorSixthFuzzTest(const uint8_t* data, size_t size) std::vector fieldDeviceList = {"deviceList"}; jsonDeviceList[FIELD_DEVICE_LIST] = fieldDeviceList; hichainConnector->ParseRemoteCredential(groupType, userId, jsonDeviceList, params, osAccountUserId); + FuzzedDataProvider fdp(data, size); + int32_t userIdInt = fdp.ConsumeIntegral(); + std::string groupId = fdp.ConsumeRandomLengthString(); + hichainConnector->DeleteGroupExt(userIdInt, groupId); + GroupInfo groupInfo; + GenerateJsonObject(jsonObj, fdp); + FromJson(jsonObj, groupInfo); } void HiChainConnectorSevenhFuzzTest(const uint8_t* data, size_t size) diff --git a/test/commonfuzztest/jsonobjectcjson_fuzzer/BUILD.gn b/test/commonfuzztest/jsonobjectcjson_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6de065e0a25b7e7ed7094e1244b54418cc028e89 --- /dev/null +++ b/test/commonfuzztest/jsonobjectcjson_fuzzer/BUILD.gn @@ -0,0 +1,65 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../device_manager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("JsonObjectCjsonFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = + "${devicemanager_path}/test/commonfuzztest/jsonobjectcjson_fuzzer" + + include_dirs = [ + "${common_path}/include", + "${devicemanager_path}/json/include", + ] + + cflags = [ + "-g", + "-O0", + "-Dprivate=public", + "-Dprotected=public", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "json_object_cjson_fuzzer.cpp", + "${devicemanager_path}/json/src/json_object_cjson.cpp", + ] + + deps = [] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"JsonObjectCjsonFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] + + external_deps = [ + "c_utils:utils", + "cJSON:cjson", + "hilog:libhilog", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":JsonObjectCjsonFuzzTest" ] +} +############################################################################### diff --git a/test/commonfuzztest/jsonobjectcjson_fuzzer/corpus/init b/test/commonfuzztest/jsonobjectcjson_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..8f37f09254457133cae0f828d0a5faee7dcbd779 --- /dev/null +++ b/test/commonfuzztest/jsonobjectcjson_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.cpp b/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4e5a73d0fe66415628fc05823819e9b270da054e --- /dev/null +++ b/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.cpp @@ -0,0 +1,349 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "json_object_cjson_fuzzer.h" +#include "json_object.h" + +namespace OHOS { +namespace DistributedHardware { + +void ToJsonDoubleFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + double value = fdp.ConsumeFloatingPoint(); + + ToJson(itemObject, value); +} +void ToJsonUint8FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(uint8_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + + uint8_t value = fdp.ConsumeIntegral(); + + ToJson(itemObject, value); +} + +void ToJsonInt16FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + int16_t value = fdp.ConsumeIntegral(); + + ToJson(itemObject, value); +} + +void ToJsonUint16FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(uint16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + uint16_t value = fdp.ConsumeIntegral(); + + ToJson(itemObject, value); +} + +void ToJsonUint64FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(uint64_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + uint64_t value = fdp.ConsumeIntegral(); + + ToJson(itemObject, value); +} + +void FromJsonDoubleFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double) + sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + double result = fdp.ConsumeFloatingPoint(); + + double testValue = fdp.ConsumeFloatingPoint(); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonBoolFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(bool) + sizeof(bool)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + bool result = fdp.ConsumeBool(); + + bool testValue = fdp.ConsumeBool(); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonUint8FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(uint8_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + uint8_t result = fdp.ConsumeIntegral(); + + int32_t testValue = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonInt16FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(int16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + int16_t result = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + + int32_t testValue = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonUint16FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(uint16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + uint16_t result = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + + int32_t testValue = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonInt32FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(int32_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + int32_t result = fdp.ConsumeIntegral(); + + int32_t testValue = fdp.ConsumeIntegral(); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void ToStringFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + + JsonItemObject object; + + ToString(object); +} + +void IsArrayFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + object.IsArray(); +} + +void IsObjectFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + object.IsObject(); +} + +void JsonItemObjectAssignmentFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject sourceObj; + JsonItemObject targetObj = sourceObj; +} + +void PushBackDoubleFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + + double value = fdp.ConsumeFloatingPoint(); + object.PushBack(value); +} + +void PushBackInt64FuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int64_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + + int64_t value = fdp.ConsumeIntegral(); + object.PushBack(value); +} + +void PushBackJsonItemObjectFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + JsonItemObject objectTemp; + object.PushBack(objectTemp); +} + +void AddItemToArrayFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + JsonItemObject objectTemp; + object.AddItemToArray(objectTemp); +} + +void GetToBoolFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(bool)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + bool value = fdp.ConsumeBool(); + object.GetTo(value); +} + +void InitArrayFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + object.InitArray(); +} + +void EraseFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size == 0) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + std::string key = fdp.ConsumeRandomLengthString(); + object.Erase(key); +} + +void DuplicateFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonObject object; + JsonObject objectTemp; + object.Duplicate(objectTemp); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ToJsonDoubleFuzzTest(data, size); + OHOS::DistributedHardware::ToJsonUint8FuzzTest(data, size); + OHOS::DistributedHardware::ToJsonInt16FuzzTest(data, size); + OHOS::DistributedHardware::ToJsonUint16FuzzTest(data, size); + OHOS::DistributedHardware::ToJsonUint64FuzzTest(data, size); + OHOS::DistributedHardware::FromJsonDoubleFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonBoolFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonUint8FuzzTest(data, size); + OHOS::DistributedHardware::FromJsonInt16FuzzTest(data, size); + OHOS::DistributedHardware::FromJsonUint16FuzzTest(data, size); + OHOS::DistributedHardware::FromJsonInt32FuzzTest(data, size); + OHOS::DistributedHardware::ToStringFuzzTest(data, size); + OHOS::DistributedHardware::IsArrayFuzzTest(data, size); + OHOS::DistributedHardware::IsObjectFuzzTest(data, size); + OHOS::DistributedHardware::JsonItemObjectAssignmentFuzzTest(data, size); + OHOS::DistributedHardware::PushBackDoubleFuzzTest(data, size); + OHOS::DistributedHardware::PushBackInt64FuzzTest(data, size); + OHOS::DistributedHardware::PushBackJsonItemObjectFuzzTest(data, size); + OHOS::DistributedHardware::AddItemToArrayFuzzTest(data, size); + OHOS::DistributedHardware::GetToBoolFuzzTest(data, size); + OHOS::DistributedHardware::InitArrayFuzzTest(data, size); + OHOS::DistributedHardware::EraseFuzzTest(data, size); + OHOS::DistributedHardware::DuplicateFuzzTest(data, size); + + return 0; +} diff --git a/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.h b/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..587aa32b01eca84919f27c6d85c3da340a956d59 --- /dev/null +++ b/test/commonfuzztest/jsonobjectcjson_fuzzer/json_object_cjson_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JSON_OBJECT_CJSON_FUZZER_H +#define JSON_OBJECT_CJSON_FUZZER_H + +#define FUZZ_PROJECT_NAME "jsonobjectcjson_fuzzer" + +#endif // JSON_OBJECT_CJSON_FUZZER_H \ No newline at end of file diff --git a/test/commonfuzztest/jsonobjectcjson_fuzzer/project.xml b/test/commonfuzztest/jsonobjectcjson_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/commonfuzztest/jsonobjectcjson_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..50b03acb40dcbf2e0db069977d6a0760958e03f3 --- /dev/null +++ b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../device_manager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("JsonObjectNlohmannjsonFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = + "${devicemanager_path}/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer" + + include_dirs = [ + "${common_path}/include", + "${devicemanager_path}/json/include", + ] + + cflags = [ + "-g", + "-O0", + "-Dprivate=public", + "-Dprotected=public", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "json_object_nlohmannjson_fuzzer.cpp", + "${devicemanager_path}/json/src/json_object_nlohmannjson.cpp", + ] + + deps = [] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"JsonObjectNlohmannjsonFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] + + external_deps = [ + "c_utils:utils", + "cJSON:cjson", + "hilog:libhilog", + "json:nlohmann_json_static" + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":JsonObjectNlohmannjsonFuzzTest" ] +} +############################################################################### diff --git a/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..8f37f09254457133cae0f828d0a5faee7dcbd779 --- /dev/null +++ b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..253272058a134bc90f22af648dc5159f23b4bb73 --- /dev/null +++ b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "json_object_nlohmannjson_fuzzer.h" +#include "json_object.h" + +namespace OHOS { +namespace DistributedHardware { + +void ToJsonDoubleNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + double value = fdp.ConsumeFloatingPoint(); + + ToJson(itemObject, value); +} + +void ToJsonInt16NLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + int16_t value = fdp.ConsumeIntegral(); + + ToJson(itemObject, value); +} + +void FromJsonDoubleNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double) + sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + double result = fdp.ConsumeFloatingPoint(); + + double testValue = fdp.ConsumeFloatingPoint(); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonBoolNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(bool) + sizeof(bool)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + bool result = fdp.ConsumeBool(); + + bool testValue = fdp.ConsumeBool(); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonUint8NLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(uint8_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + uint8_t result = fdp.ConsumeIntegral(); + + int32_t testValue = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void FromJsonInt16NLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int32_t) + sizeof(int16_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + + JsonItemObject itemObject; + int16_t result = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + + int32_t testValue = fdp.ConsumeIntegralInRange( + std::numeric_limits::min(), + std::numeric_limits::max()); + ToJson(itemObject, testValue); + FromJson(itemObject, result); +} + +void IsNumberNLFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject object; + object.IsNumber(); +} + +void JsonItemObjectAssignmentNLFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + JsonItemObject sourceObj; + JsonItemObject targetObj = sourceObj; +} + +void PushBackDoubleNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + + double value = fdp.ConsumeFloatingPoint(); + object.PushBack(value); +} + +void PushBackInt64NLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(int64_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + + int64_t value = fdp.ConsumeIntegral(); + object.PushBack(value); +} + +void PushBackStringNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size == 0) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + + std::string value = fdp.ConsumeRandomLengthString(); + object.PushBack(value); +} + +void GetToDoubleNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(double)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + double value = fdp.ConsumeFloatingPoint(); + object.GetTo(value); +} + +void GetToUint32NLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(uint32_t)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + uint32_t value = fdp.ConsumeIntegral(); + object.GetTo(value); +} + +void GetToBoolNLFuzzTest(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < sizeof(bool)) { + return; + } + + FuzzedDataProvider fdp(data, size); + JsonItemObject object; + bool value = fdp.ConsumeBool(); + object.GetTo(value); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ToJsonDoubleNLFuzzTest(data, size); + OHOS::DistributedHardware::ToJsonInt16NLFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonDoubleNLFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonBoolNLFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonUint8NLFuzzTest(data, size); + OHOS::DistributedHardware::FromJsonInt16NLFuzzTest(data, size); + OHOS::DistributedHardware::IsNumberNLFuzzTest(data, size); + OHOS::DistributedHardware::JsonItemObjectAssignmentNLFuzzTest(data, size); + OHOS::DistributedHardware::PushBackDoubleNLFuzzTest(data, size); + OHOS::DistributedHardware::PushBackInt64NLFuzzTest(data, size); + OHOS::DistributedHardware::PushBackStringNLFuzzTest(data, size); + OHOS::DistributedHardware::GetToDoubleNLFuzzTest(data, size); + OHOS::DistributedHardware::GetToUint32NLFuzzTest(data, size); + OHOS::DistributedHardware::GetToBoolNLFuzzTest(data, size); + + return 0; +} diff --git a/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f01aa303128607316fce5c4eea657b05a20f3498 --- /dev/null +++ b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JSON_OBJECT_NLOHMANNJSON_FUZZER_H +#define JSON_OBJECT_NLOHMANNJSON_FUZZER_H + +#define FUZZ_PROJECT_NAME "jsonobjectnlohmannjson_fuzzer" + +#endif // JSON_OBJECT_NLOHMANNJSON_FUZZER_H \ No newline at end of file diff --git a/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/commonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp index a42e4514577d312ed45213ae09d403e627c36cd7..a9285a436dff8d5a6e95c3bed5813bb12cdd8f90 100755 --- a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp +++ b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp @@ -27,6 +27,17 @@ namespace OHOS { namespace DistributedHardware { namespace {} +class DevTrustChangeCallbackTest : public DevTrustChangeCallback { +public: + virtual ~DevTrustChangeCallbackTest() {} + void OnDeviceTrustChange(const std::string &udid, const std::string &uuid, DmAuthForm authForm) override {} +}; + +class CredentialAuthStatusCallbackTest : public CredentialAuthStatusCallback { +public: + virtual ~CredentialAuthStatusCallbackTest() {} + void OnCredentialAuthStatus(const std::string &deviceList, uint16_t deviceTypeId, int32_t errcode) override {} +}; void StopAuthenticateDeviceTest(const uint8_t *data, size_t size) { @@ -69,6 +80,8 @@ void RegDevTrustChangeCallbackTest(const uint8_t *data, size_t size) std::shared_ptr callback = nullptr; std::string pkgName = fdp.ConsumeRandomLengthString(); DeviceManagerImpl::GetInstance().RegDevTrustChangeCallback(pkgName, callback); + callback = std::make_shared(); + DeviceManagerImpl::GetInstance().RegDevTrustChangeCallback(pkgName, callback); } void GetNetworkIdByUdidTest(const uint8_t *data, size_t size) @@ -92,6 +105,10 @@ void RegisterCredentialAuthStatusCallbackTest(const uint8_t *data, size_t size) std::string pkgName = fdp.ConsumeRandomLengthString(); std::shared_ptr callback = nullptr; DeviceManagerImpl::GetInstance().RegisterCredentialAuthStatusCallback(pkgName, callback); + callback = std::make_shared(); + DeviceManagerImpl::GetInstance().RegisterCredentialAuthStatusCallback(pkgName, callback); + DeviceManagerImpl::GetInstance().UnRegisterCredentialAuthStatusCallback(pkgName); + DeviceManagerImpl::GetInstance().UnRegisterCredentialAuthStatusCallback(""); } void GetAllTrustedDeviceListTest(const uint8_t *data, size_t size) @@ -136,9 +153,9 @@ void GetDeviceIconInfoTest(const uint8_t *data, size_t size) } FuzzedDataProvider fdp(data, size); std::string pkgName = fdp.ConsumeRandomLengthString(); - DmDeviceProfileInfoFilterOptions filterOptions; - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().GetDeviceProfileInfoList(pkgName, filterOptions, callback); + DmDeviceIconInfoFilterOptions filterOptions; + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().GetDeviceIconInfo(pkgName, filterOptions, callback); } void PutDeviceProfileInfoListTest(const uint8_t *data, size_t size) @@ -223,6 +240,16 @@ void GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(const uint8_t *data, DeviceManagerImpl::GetInstance().GetLocalServiceInfoByBundleNameAndPinExchangeType(bundleName, maxNameLength, info); } +void GetErrorCodeTest(const uint8_t *data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t errCode = fdp.ConsumeIntegral(); + DeviceManagerImpl::GetInstance().GetErrCode(errCode); +} + void UnRegisterPinHolderCallbackTest(const uint8_t *data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -251,6 +278,7 @@ void DeviceManagerImplFuzzTest(const uint8_t *data, size_t size) DmAccessCallee callee; DMIpcCmdInterfaceCode ipcCode = REGISTER_DEVICE_MANAGER_LISTENER; DeviceManagerImpl::GetInstance().GetLocalDeviceName(pkgName, deviceName); + DeviceManagerImpl::GetInstance().GetLocalDeviceName(pkgName); DeviceManagerImpl::GetInstance().UnBindDevice(pkgName, deviceId, extra); DeviceManagerImpl::GetInstance().UnRegisterSinkBindCallback(pkgName); DeviceManagerImpl::GetInstance().RegisterLocalServiceInfo(localServiceInfo); @@ -290,5 +318,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) OHOS::DistributedHardware::GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(data, size); OHOS::DistributedHardware::UnRegisterPinHolderCallbackTest(data, size); OHOS::DistributedHardware::DeviceManagerImplFuzzTest(data, size); + OHOS::DistributedHardware::GetErrorCodeTest(data, size); return 0; } diff --git a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp index 631ee616cc28032942e7e75d3a9132422dd92c90..a60faf0ed9999f644ab3acc1e801c26f6401c299 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp +++ b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp @@ -118,6 +118,7 @@ void GenerateJsonObject(JsonObject &jsonObject, FuzzedDataProvider &fdp) jsonObject[TAG_PEER_BUNDLE_NAME_V2] = fdp.ConsumeRandomLengthString(); jsonObject[DM_TAG_LOGICAL_SESSION_ID] = fdp.ConsumeIntegral(); jsonObject[TAG_PEER_DISPLAY_ID] = fdp.ConsumeIntegral(); + jsonObject[DM_BUSINESS_ID] = fdp.ConsumeRandomLengthString(); } void ActionFuzzTest() @@ -187,6 +188,34 @@ void AuthConfirmFuzzTestNext(JsonObject &jsonObject, FuzzedDataProvider &fdp) authSinkNegotiateStateMachine_->ShareAclCompare(context_, accesser, accessee); authSinkNegotiateStateMachine_->Point2PointAclCompare(context_, accesser, accessee); authSinkNegotiateStateMachine_->LnnAclCompare(context_, accesser, accessee); + authSrcPinInputState_->ShowStartAuthDialog(context_); + authSrcPinInputState_->Action(context_); + context_->importAuthCode = "123456"; + context_->importPkgName = "pkgName"; + authSinkStatePinAuthComm_->IsAuthCodeReady(context_); + authSinkStatePinAuthComm_->IsPinCodeValid(context_->importAuthCode); +} + +void AuthConfirmFuzzTestThird(FuzzedDataProvider &fdp) +{ + std::string businessId = fdp.ConsumeRandomLengthString(); + std::string businessValue = fdp.ConsumeRandomLengthString(); + authSinkNegotiateStateMachine_->IsAntiDisturbanceMode(businessId); + authSinkNegotiateStateMachine_->IsAntiDisturbanceMode(""); + authSinkNegotiateStateMachine_->ParseAndCheckAntiDisturbanceMode(businessId, businessValue); + businessId = "test_business_id"; + businessValue = "{\"business_id\":\"test_business_id\",\"is_in_anti_disturbance_mode\":true}"; + authSinkNegotiateStateMachine_->ParseAndCheckAntiDisturbanceMode(businessId, businessValue); + authSrcNegotiateStateMachine_->GetStateType(); + authSrcPinAuthStartState_->GetStateType(); + authSinkPinAuthDoneState_->GetStateType(); + authSrcReverseUltrasonicStartState_->GetStateType(); + authSrcForwardUltrasonicStartState_->GetStateType(); + authSinkReverseUltrasonicStartState_->GetStateType(); + authSinkForwardUltrasonicDoneState_->GetStateType(); + authSrcPinNegotiateStartState_->ProcessCredAuth(context_); + int32_t credType = fdp.ConsumeIntegral(); + authSrcPinNegotiateStartState_->GetCredIdByCredType(context_, credType); } void AuthConfirmFuzzTest(const uint8_t* data, size_t size) @@ -238,6 +267,7 @@ void AuthConfirmFuzzTest(const uint8_t* data, size_t size) authSrcConfirmState_->GetSrcAclInfo(context_, jsonObject, jsonObjectTwo); ActionFuzzTest(); AuthConfirmFuzzTestNext(jsonObject, fdp); + AuthConfirmFuzzTestThird(fdp); } } } diff --git a/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp b/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp index fae170d20d49895f6fe47976e6891ac86066cf40..59472857323ef04f2ad53636ba84f3e46a2e997a 100644 --- a/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp +++ b/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp @@ -148,6 +148,8 @@ void CheckAuthParamVaildFuzzTest(FuzzedDataProvider &fdp) std::string extra = fdp.ConsumeRandomLengthString(); int32_t authType = fdp.ConsumeIntegral(); authManager->CheckAuthParamVaild(pkgName, authType, deviceId, extra); + authType = 1; + authManager->CheckAuthParamVaild(pkgName, authType, deviceId, extra); } void ParseHmlInfoInJsonObjectFuzzTest(FuzzedDataProvider &fdp) @@ -167,6 +169,7 @@ void ParseJsonObjectFuzzTest(FuzzedDataProvider &fdp) jsonObject[TAG_APP_THUMBNAIL2] = fdp.ConsumeRandomLengthString(); jsonObject[PARAM_CLOSE_SESSION_DELAY_SECONDS] = fdp.ConsumeRandomLengthString(); jsonObject[TAG_PEER_PKG_NAME] = fdp.ConsumeRandomLengthString(); + jsonObject[DM_BUSINESS_ID] = fdp.ConsumeRandomLengthString(); authManager->ParseJsonObject(jsonObject); } @@ -183,6 +186,10 @@ void GetAuthParamFuzzTest(FuzzedDataProvider &fdp) std::string deviceId = fdp.ConsumeRandomLengthString(); std::string extra = fdp.ConsumeRandomLengthString(); authManager->GetAuthParam(pkgName, authType, deviceId, extra); + JsonObject jsonObject; + jsonObject[TAG_BIND_LEVEL] = fdp.ConsumeIntegral(); + extra = jsonObject.Dump(); + authManager->GetAuthParam(pkgName, authType, deviceId, extra); } void InitAuthStateFuzzTest(FuzzedDataProvider &fdp) @@ -208,12 +215,16 @@ void AuthDeviceErrorFuzzTest(FuzzedDataProvider &fdp) int64_t requestId = fdp.ConsumeIntegral(); int32_t errorCode = fdp.ConsumeIntegral(); authManager->AuthDeviceError(requestId, errorCode); + authSinkManager->AuthDeviceError(requestId, errorCode); + requestId = context_->requestId; + authManager->AuthDeviceError(requestId, errorCode); } void AuthDeviceFinishFuzzTest(FuzzedDataProvider &fdp) { int64_t requestId = fdp.ConsumeIntegral(); authManager->AuthDeviceFinish(requestId); + authSinkManager->AuthDeviceFinish(requestId); } void GetPinCodeFuzzTest(FuzzedDataProvider &fdp) @@ -250,6 +261,10 @@ void BindTargetFuzzTest(FuzzedDataProvider &fdp) int sessionId = fdp.ConsumeIntegral(); uint64_t logicalSessionId = fdp.ConsumeIntegral(); authManager->BindTarget(pkgName, targetId, bindParam, sessionId, logicalSessionId); + bindParam[PARAM_KEY_AUTH_TYPE] = "1"; + authManager->BindTarget(pkgName, targetId, bindParam, sessionId, logicalSessionId); + authManager->GetBindTargetParams(pkgName, targetId, bindParam); + authManager->SetBindTargetParams(targetId); } void OnSessionClosedFuzzTest(FuzzedDataProvider &fdp) @@ -277,6 +292,10 @@ void OnUserOperationFuzzTest(FuzzedDataProvider &fdp) int32_t action = fdp.ConsumeIntegral(); std::string params = fdp.ConsumeRandomLengthString(); authSinkManager->OnUserOperation(action, params); + action = USER_OPERATION_TYPE_AUTH_CONFIRM_TIMEOUT; + authSinkManager->OnUserOperation(action, params); + action = USER_OPERATION_TYPE_CANCEL_PINCODE_DISPLAY; + authSinkManager->OnUserOperation(action, params); } void OnSessionOpenedFuzzTest(FuzzedDataProvider &fdp) @@ -285,6 +304,7 @@ void OnSessionOpenedFuzzTest(FuzzedDataProvider &fdp) int32_t sessionSide = fdp.ConsumeIntegral(); int32_t result = fdp.ConsumeIntegral(); authManager->OnSessionOpened(sessionId, sessionSide, result); + authSinkManager->OnSessionOpened(sessionId, sessionSide, result); } void OnSrcSessionClosedFuzzTest(FuzzedDataProvider &fdp) @@ -307,6 +327,10 @@ void OnSrcUserOperationFuzzTest(FuzzedDataProvider &fdp) int32_t action = fdp.ConsumeIntegral(); std::string params = fdp.ConsumeRandomLengthString(); authManager->OnUserOperation(action, params); + action = USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT; + authManager->OnUserOperation(action, params); + action = USER_OPERATION_TYPE_DONE_PINCODE_INPUT; + authManager->OnUserOperation(action, params); } void AuthDeviceTransmitFuzzTest(FuzzedDataProvider &fdp) @@ -343,6 +367,15 @@ void AuthSinkDeviceRequestFuzzTest(FuzzedDataProvider &fdp) authManager->GetBindCallerInfo(); } +void HandleBusinessEventsFuzzTest(FuzzedDataProvider &fdp) +{ + std::string businessId = fdp.ConsumeRandomLengthString(); + int action = fdp.ConsumeIntegral(); + authManager->HandleBusinessEvents(businessId, action); + authManager->ClearSoftbusSessionCallback(); + authManager->PrepareSoftbusSessionCallback(); +} + void AuthManagerFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -388,6 +421,7 @@ void AuthManagerFuzzTest(const uint8_t* data, size_t size) AuthSinkDeviceTransmitFuzzTest(fdp); AuthSinkDeviceSessionKeyFuzzTest(fdp); AuthSinkDeviceRequestFuzzTest(fdp); + HandleBusinessEventsFuzzTest(fdp); } } } diff --git a/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp b/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp index 73a030896499aef157bc126129a446879c062779..84d93153e323e67274dcde0353417777b6614c80 100644 --- a/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp +++ b/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp @@ -57,6 +57,27 @@ void GenerateJsonObject(JsonObject &jsonObject, FuzzedDataProvider &fdp) jsonObject[TAG_PEER_BUNDLE_NAME_V2] = fdp.ConsumeRandomLengthString(); jsonObject[DM_TAG_LOGICAL_SESSION_ID] = fdp.ConsumeIntegral(); jsonObject[TAG_PEER_DISPLAY_ID] = fdp.ConsumeIntegral(); + jsonObject[TAG_TRANSMIT_SK_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_TRANSMIT_SK_TIMESTAMP] = fdp.ConsumeIntegral(); + jsonObject[TAG_TRANSMIT_CREDENTIAL_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_DMVERSION] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_LNN_SK_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_LNN_SK_TIMESTAMP] = fdp.ConsumeIntegral(); + jsonObject[TAG_LNN_CREDENTIAL_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_MSG_TYPE] = fdp.ConsumeIntegral(); + jsonObject[TAG_SYNC] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_ACCESS] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_DEVICE_VERSION] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_DEVICE_NAME] = fdp.ConsumeRandomLengthString(); + jsonObject[TAG_NETWORKID_ID] = fdp.ConsumeRandomLengthString(); +} + +void AuthContextFuzzTest(FuzzedDataProvider &fdp) +{ + DmAuthSide side = DmAuthSide::DM_AUTH_LOCAL_SIDE; + DmAuthScope scope = DmAuthScope::DM_AUTH_SCOPE_INVALID; + std::string publicKey = fdp.ConsumeRandomLengthString(); + context_->SetPublicKey(side, scope, publicKey); } void AuthMessageProcessorFuzzTestNext(JsonObject &jsonObject) @@ -101,6 +122,13 @@ void AuthMessageProcessorFuzzTestNext(JsonObject &jsonObject) dmAuthMessageProcessor_ -> CreateMessageReverseUltrasonicStart(context_, jsonObject); dmAuthMessageProcessor_ -> CreateMessageForwardUltrasonicNegotiate(context_, jsonObject); dmAuthMessageProcessor_ -> CreateMessageReverseUltrasonicDone(context_, jsonObject); + dmAuthMessageProcessor_ -> CheckLogicalSessionId(jsonObject, context_); + std::string message = jsonObject.Dump(); + dmAuthMessageProcessor_ -> ParseMessage(context_, message); + DmAccessControlTable table; + FromJson(jsonObject, table); + DmAccessToSync sync; + FromJson(jsonObject, sync); } void AuthMessageProcessorFuzzTest(const uint8_t* data, size_t size) @@ -150,6 +178,7 @@ void AuthMessageProcessorFuzzTest(const uint8_t* data, size_t size) dmAuthMessageProcessor_ -> SetTransmitAccessControlList(context_, accesser, accessee); dmAuthMessageProcessor_ -> SetLnnAccessControlList(context_, accesser, accessee); AuthMessageProcessorFuzzTestNext(jsonObject); + AuthContextFuzzTest(fdp); } } } diff --git a/test/servicesfuzztest/devicelist_fuzzer/device_list_fuzzer.cpp b/test/servicesfuzztest/devicelist_fuzzer/device_list_fuzzer.cpp index 264b6eb843ff7b9a80ccd6a1780b4169d7e12aac..30ed2397b1bea2f99a507e42924f783292610d3b 100644 --- a/test/servicesfuzztest/devicelist_fuzzer/device_list_fuzzer.cpp +++ b/test/servicesfuzztest/devicelist_fuzzer/device_list_fuzzer.cpp @@ -38,6 +38,8 @@ void DeviceListFuzzTest(const uint8_t* data, size_t size) std::make_shared(std::make_shared()); DeviceManager::GetInstance().GetTrustedDeviceList(bundleName, extra, devList); DeviceManager::GetInstance().GetLocalDeviceInfo(bundleName, deviceInfo); + bundleName = ""; + DeviceManager::GetInstance().GetTrustedDeviceList(bundleName, extra, devList); } } } diff --git a/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp b/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp index 69148d8ab6578812c3444d6ad218fa45f3b13632..c0092282cb6a3b91b8dce0cee8ae5d4449a18378 100644 --- a/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp +++ b/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp @@ -25,6 +25,7 @@ #include "device_name_manager.h" #include "dm_constants.h" +#include "dm_datashare_common_event.h" namespace OHOS { namespace DistributedHardware { @@ -115,6 +116,10 @@ void DeviceNameManagerSecondFuzzTest(const uint8_t* data, size_t size) std::shared_ptr deviceNameMgr = std::make_shared(); deviceNameMgr->UnInit(); deviceNameMgr->GetUserDefinedDeviceName(); + deviceNameMgr_->GetSystemRegion(); + DmDataShareCommonEventManager eventManager; + eventManager.eventValidFlag_ = true; + eventManager.UnsubscribeDataShareCommonEvent(); } } // namespace DistributedHardware } // namespace OHOS diff --git a/test/servicesfuzztest/dmcommtool_fuzzer/dm_comm_tool_fuzzer.cpp b/test/servicesfuzztest/dmcommtool_fuzzer/dm_comm_tool_fuzzer.cpp index f8d04a6bd24777c55fb35bdd0d39b4ac1ab85418..d38acab88cc0f41a8f52efe517b4d2635a6488f0 100644 --- a/test/servicesfuzztest/dmcommtool_fuzzer/dm_comm_tool_fuzzer.cpp +++ b/test/servicesfuzztest/dmcommtool_fuzzer/dm_comm_tool_fuzzer.cpp @@ -59,6 +59,10 @@ void DmCommToolFuzzTest(const uint8_t* data, size_t size) dmCommToolPtr_->ProcessResponseUserIdsEvent(innerCommMsg); dmCommToolPtr_->ProcessReceiveCommonEvent(innerCommMsg); dmCommToolPtr_->ProcessResponseCommonEvent(innerCommMsg); + dmCommToolPtr_->ProcessReceiveUninstAppEvent(innerCommMsg); + dmCommToolPtr_->ProcessReceiveUnBindAppEvent(innerCommMsg); + dmCommToolPtr_->ProcessReceiveRspAppUninstallEvent(innerCommMsg); + dmCommToolPtr_->ProcessReceiveRspAppUnbindEvent(innerCommMsg); dmCommToolPtr_->GetDMTransportPtr(); dmCommToolPtr_->GetEventHandler(); } @@ -87,6 +91,15 @@ void DmCommToolFirstFuzzTest(const uint8_t* data, size_t size) std::string commonEventType; EventCallback eventCallback; dmCommToolPtr_->StartCommonEvent(commonEventType, eventCallback); + dmCommToolPtr_->Init(); + int32_t userId = fdp.ConsumeIntegral(); + int32_t tokenId = fdp.ConsumeIntegral(); + dmCommToolPtr_->SendUninstAppObj(userId, tokenId, rmtNetworkId); + dmCommToolPtr_->RspAppUninstall(rmtNetworkId, socketId); + dmCommToolPtr_->RspAppUnbind(rmtNetworkId, socketId); + std::string udid = fdp.ConsumeRandomLengthString(); + dmCommToolPtr_->SendUnBindAppObj(userId, tokenId, msg, rmtNetworkId, udid); + dmCommToolPtr_->StopSocket(rmtNetworkId); } } } diff --git a/test/servicesfuzztest/dmtransportmsg_fuzzer/dm_transport_msg_fuzzer.cpp b/test/servicesfuzztest/dmtransportmsg_fuzzer/dm_transport_msg_fuzzer.cpp index ec35472c82779c9d0a370cf48d2a14098b3dcc79..eac32294cd435d6fa0a4869885fa0afddbb23414 100644 --- a/test/servicesfuzztest/dmtransportmsg_fuzzer/dm_transport_msg_fuzzer.cpp +++ b/test/servicesfuzztest/dmtransportmsg_fuzzer/dm_transport_msg_fuzzer.cpp @@ -97,22 +97,30 @@ void DmTransPortMsgFirstFuzzTest(const uint8_t* data, size_t size) std::string msg(reinterpret_cast(data), size); std::string remoteUdid(reinterpret_cast(data), size); const char* jsonString = R"({ - "MsgType": "0", - "userId": "12345", "accountId": "a******3", - "peerUdids": ["u******1", "u******2"], - "peerUdid": "p******d", - "accountName": "t******t", - "syncUserIdFlag": 1, - "userIds": [ - {"type": 1, "userId": 111}, - {"type": 0, "userId": 222} - ] + "userId": 123, + "tokenId": 123456, + "extra": "extra", + "udid": "p******d", })"; cJSON* jsonObject = nullptr; LogoutAccountMsg accountInfo; ToJson(jsonObject, accountInfo); FromJson(jsonObject, accountInfo); + UninstAppMsg uninstAppMsg; + ToJson(jsonObject, uninstAppMsg); + FromJson(jsonObject, uninstAppMsg); + UnBindAppMsg unBindAppMsg; + ToJson(jsonObject, unBindAppMsg); + FromJson(jsonObject, unBindAppMsg); + + jsonObject = cJSON_Parse(jsonString); + ToJson(jsonObject, accountInfo); + FromJson(jsonObject, accountInfo); + ToJson(jsonObject, uninstAppMsg); + FromJson(jsonObject, uninstAppMsg); + ToJson(jsonObject, unBindAppMsg); + FromJson(jsonObject, unBindAppMsg); cJSON_Delete(jsonObject); } } diff --git a/test/servicesfuzztest/initdevicemanager_fuzzer/init_device_manager_fuzzer.cpp b/test/servicesfuzztest/initdevicemanager_fuzzer/init_device_manager_fuzzer.cpp index a55ca54c463ab5dd6fbceb9dab1689969b901f6d..a51309f62a91bb2499b6777aeaeb566c7cca2d73 100644 --- a/test/servicesfuzztest/initdevicemanager_fuzzer/init_device_manager_fuzzer.cpp +++ b/test/servicesfuzztest/initdevicemanager_fuzzer/init_device_manager_fuzzer.cpp @@ -41,6 +41,10 @@ void InitDeviceManagerFuzzTest(const uint8_t* data, size_t size) DeviceManager::GetInstance().InitDeviceManager(packName, callback); DeviceManager::GetInstance().UnInitDeviceManager(packName); + packName = ""; + callback = nullptr; + DeviceManager::GetInstance().InitDeviceManager(packName, callback); + DeviceManager::GetInstance().UnInitDeviceManager(packName); } } } diff --git a/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp b/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp index 384c7e6012b552a885049ea23dc2c32c46098d29..f1d294c57cc2fe7a0a68cca2cf970e91bf2e5af8 100644 --- a/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp +++ b/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp @@ -125,6 +125,11 @@ void SoftBusConnectorSecondFuzzTest(const uint8_t* data, size_t size) memcpy_s(nodeBasicInfo.networkId, sizeof(nodeBasicInfo.networkId), "networkId", sizeof("networkId")); memcpy_s(nodeBasicInfo.deviceName, sizeof(nodeBasicInfo.deviceName), "deviceName", sizeof("deviceName")); softbusConnector->ConvertNodeBasicInfoToDmDevice(nodeBasicInfo, dmDeviceInfo); + DevUserInfo localUserInfo; + DevUserInfo remoteUserInfo; + std::string remoteAclList = fdp.ConsumeRandomLengthString(); + softbusConnector->SyncLocalAclListProcess(localUserInfo, remoteUserInfo, remoteAclList); + softbusConnector->GetAclListHash(localUserInfo, remoteUserInfo, remoteAclList); } } } diff --git a/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp b/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp index 9df6f8cdc50bfc013fe330e613e6b8d09cabff27..57c6d3e99c45218d9e475a2915c86e998c0eb081 100644 --- a/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp +++ b/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp @@ -75,6 +75,8 @@ void SoftBusSessionFuzzTest(const uint8_t* data, size_t size) softbusSession->SendHeartbeatData(sessionId, str); softbusSession->OnSessionClosed(result); softbusSession->UnRegisterSessionCallback(); + bool isEnable = fdp.ConsumeBool(); + softbusSession->OpenAuthSessionWithPara(str, sessionId, isEnable); } } } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index b533b2e49bcbcb25f65a09f9c7df111d74186e46..c4d1ba8fe5106a23dc36a67e65a175e117e5a6a1 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -46,7 +46,6 @@ if (defined(ohos_lite)) { "${common_path}/src/dfx/lite/dm_hisysevent.cpp", "${common_path}/src/dfx/lite/dm_hitrace.cpp", "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "${common_path}/src/dm_error_message.cpp", "${common_path}/src/ipc/lite/ipc_cmd_register.cpp", "src/appInfo/lite/app_manager.cpp", @@ -129,7 +128,6 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", @@ -210,7 +208,6 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", diff --git a/utils/src/kvadapter/kv_adapter.cpp b/utils/src/kvadapter/kv_adapter.cpp index a654945668e24ed5eb8664f961784775f6942128..7c7495bb009b072b23740a4f4b11a139859d7ad8 100644 --- a/utils/src/kvadapter/kv_adapter.cpp +++ b/utils/src/kvadapter/kv_adapter.cpp @@ -24,7 +24,6 @@ #include "data_query.h" #include "dm_anonymous.h" -#include "dm_constants.h" #include "dm_error_type.h" #include "dm_log.h" #include "ffrt.h" @@ -42,6 +41,9 @@ namespace { constexpr int32_t MAX_INIT_RETRY_TIMES = 20; constexpr int32_t INIT_RETRY_SLEEP_INTERVAL = 200 * 1000; // 200ms constexpr uint32_t DM_OSTYPE_PREFIX_LEN = 16; + const char* PEER_UDID = "peer_udid"; + const char* PEER_OSTYPE = "peer_os_type"; + const char* TIME_STAMP = "timestamp"; } int32_t KVAdapter::Init()