From 6465d77f8d958c56575f235d6ca5a66668778c78 Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Mon, 18 Apr 2022 21:07:06 +0800 Subject: [PATCH 1/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- bundle.json | 4 +- test/BUILD.gn | 5 +- test/fuzztest/BUILD.gn | 28 ++ .../devicemanagerimpl_fuzzer/BUILD.gn | 133 +++++++++ .../devicemanagerimpl_fuzzer/corpus/init | 13 + .../device_manager_impl_fuzzer.cpp | 252 ++++++++++++++++++ .../device_manager_impl_fuzzer.h | 21 ++ .../devicemanagerimpl_fuzzer/project.xml | 25 ++ .../devicemanagernotify_fuzzer/BUILD.gn | 102 +++++++ .../devicemanagernotify_fuzzer/corpus/init | 13 + .../device_manager_notify_fuzzer.cpp | 96 +++++++ .../device_manager_notify_fuzzer.h | 21 ++ .../devicemanagernotify_fuzzer/project.xml | 25 ++ .../devicemanagerservice_fuzzer/BUILD.gn | 102 +++++++ .../devicemanagerservice_fuzzer/corpus/init | 13 + .../device_manager_service_fuzzer.cpp | 61 +++++ .../device_manager_service_fuzzer.h | 21 ++ .../devicemanagerservice_fuzzer/project.xml | 25 ++ .../fuzztest/ipcclientmanager_fuzzer/BUILD.gn | 148 ++++++++++ .../ipcclientmanager_fuzzer/corpus/init | 13 + .../ipc_client_manager_fuzzer.cpp | 52 ++++ .../ipc_client_manager_fuzzer.h | 21 ++ .../ipcclientmanager_fuzzer/project.xml | 25 ++ test/fuzztest/ipccmdregister_fuzzer/BUILD.gn | 148 ++++++++++ .../ipccmdregister_fuzzer/corpus/init | 13 + .../ipc_cmd_register_fuzzer.cpp | 73 +++++ .../ipc_cmd_register_fuzzer.h | 21 ++ .../ipccmdregister_fuzzer/project.xml | 25 ++ .../ipcserverclientproxy_fuzzer/BUILD.gn | 147 ++++++++++ .../ipcserverclientproxy_fuzzer/corpus/init | 13 + .../ipc_server_client_proxy_fuzzer.cpp | 53 ++++ .../ipc_server_client_proxy_fuzzer.h | 21 ++ .../ipcserverclientproxy_fuzzer/project.xml | 25 ++ .../ipcserverlistener_fuzzer/BUILD.gn | 147 ++++++++++ .../ipcserverlistener_fuzzer/corpus/init | 13 + .../ipc_server_listener_fuzzer.cpp | 49 ++++ .../ipc_server_listener_fuzzer.h | 21 ++ .../ipcserverlistener_fuzzer/project.xml | 25 ++ test/fuzztest/ipcserverstub_fuzzer/BUILD.gn | 147 ++++++++++ .../fuzztest/ipcserverstub_fuzzer/corpus/init | 13 + .../ipc_server_stub_fuzzer.cpp | 66 +++++ .../ipc_server_stub_fuzzer.h | 21 ++ .../fuzztest/ipcserverstub_fuzzer/project.xml | 25 ++ .../nativedevicemanagerjs_fuzzer/BUILD.gn | 147 ++++++++++ .../nativedevicemanagerjs_fuzzer/corpus/init | 13 + .../native_devicemanager_js_fuzzer.cpp | 95 +++++++ .../native_devicemanager_js_fuzzer.h | 21 ++ .../nativedevicemanagerjs_fuzzer/project.xml | 25 ++ 48 files changed, 2582 insertions(+), 4 deletions(-) create mode 100644 test/fuzztest/BUILD.gn create mode 100644 test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn create mode 100644 test/fuzztest/devicemanagerimpl_fuzzer/corpus/init create mode 100644 test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp create mode 100644 test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.h create mode 100644 test/fuzztest/devicemanagerimpl_fuzzer/project.xml create mode 100644 test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn create mode 100644 test/fuzztest/devicemanagernotify_fuzzer/corpus/init create mode 100644 test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.cpp create mode 100644 test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.h create mode 100644 test/fuzztest/devicemanagernotify_fuzzer/project.xml create mode 100644 test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn create mode 100644 test/fuzztest/devicemanagerservice_fuzzer/corpus/init create mode 100644 test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.cpp create mode 100644 test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.h create mode 100644 test/fuzztest/devicemanagerservice_fuzzer/project.xml create mode 100644 test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn create mode 100644 test/fuzztest/ipcclientmanager_fuzzer/corpus/init create mode 100644 test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.cpp create mode 100644 test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.h create mode 100644 test/fuzztest/ipcclientmanager_fuzzer/project.xml create mode 100644 test/fuzztest/ipccmdregister_fuzzer/BUILD.gn create mode 100644 test/fuzztest/ipccmdregister_fuzzer/corpus/init create mode 100644 test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.cpp create mode 100644 test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.h create mode 100644 test/fuzztest/ipccmdregister_fuzzer/project.xml create mode 100644 test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn create mode 100644 test/fuzztest/ipcserverclientproxy_fuzzer/corpus/init create mode 100644 test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.cpp create mode 100644 test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.h create mode 100644 test/fuzztest/ipcserverclientproxy_fuzzer/project.xml create mode 100644 test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn create mode 100644 test/fuzztest/ipcserverlistener_fuzzer/corpus/init create mode 100644 test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.cpp create mode 100644 test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.h create mode 100644 test/fuzztest/ipcserverlistener_fuzzer/project.xml create mode 100644 test/fuzztest/ipcserverstub_fuzzer/BUILD.gn create mode 100644 test/fuzztest/ipcserverstub_fuzzer/corpus/init create mode 100644 test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp create mode 100644 test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.h create mode 100644 test/fuzztest/ipcserverstub_fuzzer/project.xml create mode 100644 test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn create mode 100644 test/fuzztest/nativedevicemanagerjs_fuzzer/corpus/init create mode 100644 test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.cpp create mode 100644 test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.h create mode 100644 test/fuzztest/nativedevicemanagerjs_fuzzer/project.xml diff --git a/bundle.json b/bundle.json index b6d72ecff..2cfcfd484 100644 --- a/bundle.json +++ b/bundle.json @@ -64,9 +64,7 @@ } } ], - "test": [ - "//foundation/distributedhardware/devicemanager/test:test" - ] + "test": [ "//foundation/distributedhardware/devicemanager/test:test" ] } } } diff --git a/test/BUILD.gn b/test/BUILD.gn index 87552dc68..95b10dcae 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -16,6 +16,9 @@ group("test") { deps = [] if (support_jsapi) { - deps += [ "unittest:unittest" ] + deps += [ + "unittest:unittest", + "fuzztest:fuzztest" + ] } } diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn new file mode 100644 index 000000000..e57c94b3a --- /dev/null +++ b/test/fuzztest/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2022 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. + +group("fuzztest") { + testonly = true + + deps = [ + "devicemanagerimpl_fuzzer:fuzztest", + "devicemanagernotify_fuzzer:fuzztest", + "devicemanagerservice_fuzzer:fuzztest", + "ipcclientmanager_fuzzer:fuzztest", + "ipccmdregister_fuzzer:fuzztest", + "ipcserverclientproxy_fuzzer:fuzztest", + "ipcserverlistener_fuzzer:fuzztest", + "ipcserverstub_fuzzer:fuzztest", + "nativedevicemanagerjs_fuzzer:fuzztest", + ] +} \ No newline at end of file diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn new file mode 100644 index 000000000..b5cc8ca33 --- /dev/null +++ b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn @@ -0,0 +1,133 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DeviceManagerImplFuzzTest") { + module_out_path = "devicemanager/devicemanagerimpl_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/devicemanagerimpl_fuzzer" + + include_dirs = [ + "${utils_path}/include", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include/ipc/standard", + "${services_path}/include", + "${services_path}/include/dependency/timer", + "${services_path}/include/discovery", + "${services_path}/include/dependency/softbus", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo/", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "device_manager_impl_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "${utils_path}:devicemanagerutils", + "//foundation/ace/napi:ace_napi", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DeviceManagerImplFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DeviceManagerImplFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/corpus/init b/test/fuzztest/devicemanagerimpl_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/devicemanagerimpl_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp b/test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp new file mode 100644 index 000000000..b5bcdbaeb --- /dev/null +++ b/test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2022 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 +#include +#include +#include +#include +#include +#include +#include "device_manager_impl.h" +#include "device_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "device_manager_callback.h" +#include "dm_app_image_info.h" +#include "dm_device_info.h" +#include "dm_native_event.h" +#include "dm_subscribe_info.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" +#include "nlohmann/json.hpp" +#include "native_devicemanager_js.h" +#include "device_manager_impl_fuzzer.h" + +const int nCapabiltyBufferSize = 65; + +namespace OHOS { +namespace DistributedHardware { +void InitDeviceManagerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string packName(reinterpret_cast(data), size); + std::string bundleName(reinterpret_cast(data), size); + napi_env env; + std::shared_ptr initCallback = std::make_shared(env, bundleName); + + int32_t ret = DeviceManager::GetInstance().InitDeviceManager(packName, initCallback); + ret = DeviceManager::GetInstance().UnInitDeviceManager(packName); +} + +void DeviceListFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string extra(reinterpret_cast(data), size); + std::vector devList; + std::string bundleName(reinterpret_cast(data), size); + DmDeviceInfo deviceInfo; + + int32_t ret = DeviceManager::GetInstance().GetTrustedDeviceList(bundleName, extra, devList); + ret = DeviceManager::GetInstance().GetLocalDeviceInfo(bundleName, deviceInfo); +} + +void DeviceDiscoveryFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string bundleName(reinterpret_cast(data), size); + + DmSubscribeInfo subInfo; + subInfo.subscribeId = *(reinterpret_cast(data)); + subInfo.mode = *(reinterpret_cast(data)); + subInfo.medium = *(reinterpret_cast(data)); + subInfo.freq = *(reinterpret_cast(data)); + subInfo.isSameAccount = *(reinterpret_cast(data)); + subInfo.isWakeRemote = *(reinterpret_cast(data)); + strncpy_s(subInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, (char*)data, nCapabiltyBufferSize); + napi_env env; + std::string extra(reinterpret_cast(data), size); + int16_t subscribeId = *(reinterpret_cast(data)); + std::shared_ptr discoverCallback = + std::make_shared(env, bundleName); + + int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(bundleName, + subInfo, extra, discoverCallback); + ret = DeviceManager::GetInstance().StopDeviceDiscovery(bundleName, subscribeId); +} + +void AuthenticateDeviceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string pkgName(reinterpret_cast(data), size); + int32_t authType = *(reinterpret_cast(data)); + DmDeviceInfo deviceInfo; + std::string extraString(reinterpret_cast(data), size); + napi_env env; + std::shared_ptr authCallback = + std::make_shared(env, pkgName); + + DeviceManager::GetInstance().AuthenticateDevice(pkgName, + authType, deviceInfo, extraString, authCallback); +} + +void UnAuthenticateDeviceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string bundleName(reinterpret_cast(data), size); + std::string deviceId(reinterpret_cast(data), size); + + DeviceManager::GetInstance().UnAuthenticateDevice(bundleName, deviceId); +} + +void VerifyAuthenticationFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string bundleName(reinterpret_cast(data), size); + std::string authParam(reinterpret_cast(data), size); + napi_env env; + std::shared_ptr verifyCallback = + std::make_shared(env, bundleName); + + DeviceManager::GetInstance().VerifyAuthentication(bundleName, authParam, verifyCallback); +} + +void RegisterDeviceManagerFaCallbackFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string bundleName(reinterpret_cast(data), size); + std::string packageName(reinterpret_cast(data), size); + napi_env env; + auto callback = std::make_shared(env, bundleName); + + DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packageName, callback); +} + +void UnRegisterDeviceManagerFaCallbackFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string packName(reinterpret_cast(data), size); + DeviceManager::GetInstance().UnRegisterDeviceManagerFaCallback(packName); +} + +void GetFaParamFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string packName(reinterpret_cast(data), size); + DmAuthParam authParam; + + DeviceManager::GetInstance().GetFaParam(packName, authParam); +} + +void SetUserOperationFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + int32_t action = *(reinterpret_cast(data)); + + DeviceManager::GetInstance().SetUserOperation(pkgName, action); +} + +void GetUdidByNetworkIdFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string pkgName(reinterpret_cast(data), size); + std::string netWorkId(reinterpret_cast(data), size); + std::string udid(reinterpret_cast(data), size); + + DeviceManager::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); +} + +void GetUuidByNetworkIdFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string packName(reinterpret_cast(data), size); + std::string netWorkId(reinterpret_cast(data), size); + std::string uuid(reinterpret_cast(data), size); + + DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid); +} + +void RegisterDevStateCallbackFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string bundleName(reinterpret_cast(data), size); + napi_env env; + auto callback = std::make_shared(env, bundleName); + std::string extra(reinterpret_cast(data), size); + + int32_t ret = DeviceManager::GetInstance().RegisterDevStateCallback(bundleName, + extra, callback); + ret = DeviceManager::GetInstance().UnRegisterDevStateCallback(bundleName); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::InitDeviceManagerFuzzTest(data, size); + OHOS::DistributedHardware::DeviceListFuzzTest(data, size); + OHOS::DistributedHardware::RegisterDevStateCallbackFuzzTest(data, size); + OHOS::DistributedHardware::DeviceDiscoveryFuzzTest(data, size); + OHOS::DistributedHardware::AuthenticateDeviceFuzzTest(data, size); + OHOS::DistributedHardware::UnAuthenticateDeviceFuzzTest(data, size); + OHOS::DistributedHardware::VerifyAuthenticationFuzzTest(data, size); + OHOS::DistributedHardware::RegisterDeviceManagerFaCallbackFuzzTest(data, size); + OHOS::DistributedHardware::UnRegisterDeviceManagerFaCallbackFuzzTest(data, size); + OHOS::DistributedHardware::GetFaParamFuzzTest(data, size); + OHOS::DistributedHardware::SetUserOperationFuzzTest(data, size); + OHOS::DistributedHardware::GetUdidByNetworkIdFuzzTest(data, size); + OHOS::DistributedHardware::GetUuidByNetworkIdFuzzTest(data, size); + + return 0; +} diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.h b/test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.h new file mode 100644 index 000000000..2e4d1d838 --- /dev/null +++ b/test/fuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 DEVICE_MANAGER_IMPL_FUZZER_H +#define DEVICE_MANAGER_IMPL_FUZZER_H + +#define FUZZ_PROJECT_NAME "devicemanagerimpl_fuzzer" + +#endif // DEVICE_MANAGER_IMPL_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/project.xml b/test/fuzztest/devicemanagerimpl_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/devicemanagerimpl_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn new file mode 100644 index 000000000..6e239e70d --- /dev/null +++ b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DeviceManagerNotifyFuzzTest") { + module_out_path = "devicemanager/devicemanagernotify_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/devicemanagernotify_fuzzer" + + include_dirs = [ + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include", + "${services_path}/include/dependency/timer", + "${services_path}/include/discovery", + "${services_path}/include/dependency/softbus", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo/", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "device_manager_notify_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DeviceManagerNotifyFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DeviceManagerNotifyFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/devicemanagernotify_fuzzer/corpus/init b/test/fuzztest/devicemanagernotify_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/devicemanagernotify_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.cpp b/test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.cpp new file mode 100644 index 000000000..eb45fa70e --- /dev/null +++ b/test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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 +#include +#include +#include +#include "ipc_client_manager.h" +#include "ipc_set_useroperation_req.h" +#include "ipc_rsp.h" +#include "ipc_def.h" +#include "device_manager_notify.h" +#include "dm_device_info.h" +#include "ipc_client_stub.h" +#include "ipc_register_listener_req.h" +#include "ipc_remote_broker.h" +#include "iremote_object.h" +#include "iservice_registry.h" +#include "dm_constants.h" +#include "system_ability_definition.h" +#include "device_manager_notify_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void DeviceManagerNotifyUnRegisterFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + std::string deviceId(reinterpret_cast(data), size); + uint16_t subscribeId = *(reinterpret_cast(data)); + + DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(pkgName); + DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); + DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); + DeviceManagerNotify::GetInstance().UnRegisterVerifyAuthenticationCallback(pkgName); + DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); + DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId); + DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId); + DeviceManagerNotify::GetInstance().OnFaCall(pkgName, deviceId); +} +void DeviceManagerNotifyDeviceStatusFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string pkgName(reinterpret_cast(data), size); + std::string deviceId(reinterpret_cast(data), size); + std::string authPara(reinterpret_cast(data), size); + std::string token(reinterpret_cast(data), size); + uint16_t subscribeId = *(reinterpret_cast(data)); + int32_t resultCode = *(reinterpret_cast(data)); + int32_t flag = *(reinterpret_cast(data)); + int32_t failedReason = *(reinterpret_cast(data)); + uint32_t status = *(reinterpret_cast(data)); + uint32_t reason = *(reinterpret_cast(data)); + DmDeviceInfo deviceInfo; + + DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, deviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, deviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, deviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, deviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, deviceInfo); + + DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason); + DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId); + DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason); + DeviceManagerNotify::GetInstance().OnVerifyAuthResult(pkgName, deviceId, resultCode, flag); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DeviceManagerNotifyUnRegisterFuzzTest(data, size); + OHOS::DistributedHardware::DeviceManagerNotifyDeviceStatusFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.h b/test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.h new file mode 100644 index 000000000..35bbace98 --- /dev/null +++ b/test/fuzztest/devicemanagernotify_fuzzer/device_manager_notify_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 DEVICE_MANAGER_NOTIFY_FUZZER_H +#define DEVICE_MANAGER_NOTIFY_FUZZER_H + +#define FUZZ_PROJECT_NAME "devicemanagernotify_fuzzer" + +#endif // DEVICE_MANAGER_NOTIFY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/devicemanagernotify_fuzzer/project.xml b/test/fuzztest/devicemanagernotify_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/devicemanagernotify_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn new file mode 100644 index 000000000..486974013 --- /dev/null +++ b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DeviceManagerServiceFuzzTest") { + module_out_path = "devicemanager/devicemanagerservice_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/devicemanagerservice_fuzzer" + + include_dirs = [ + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include", + "${services_path}/include/dependency/timer", + "${services_path}/include/discovery", + "${services_path}/include/dependency/softbus", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo/", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "device_manager_service_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DeviceManagerServiceFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DeviceManagerServiceFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/devicemanagerservice_fuzzer/corpus/init b/test/fuzztest/devicemanagerservice_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/devicemanagerservice_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.cpp b/test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.cpp new file mode 100644 index 000000000..78bf587cd --- /dev/null +++ b/test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 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 +#include "device_manager_service.h" +#include "device_manager_service_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void DeviceManagerServiceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + std::string extra(reinterpret_cast(data), size); + int32_t authType = *(reinterpret_cast(data)); + uint16_t subscribeId = *(reinterpret_cast(data)); + DmSubscribeInfo subscribeInfo; + std::vector deviceList; + DmDeviceInfo info; + DmAuthParam authParam; + + int32_t ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); + ret = DeviceManagerService::GetInstance().GetLocalDeviceInfo(info); + ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); + ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, pkgName, pkgName); + ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, pkgName, pkgName); + ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, pkgName, extra); + ret = DeviceManagerService::GetInstance().VerifyAuthentication(pkgName); + ret = DeviceManagerService::GetInstance().GetFaParam(pkgName, authParam); + ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, extra); + ret = DeviceManagerService::GetInstance().SetUserOperation(pkgName, authType); + ret = DeviceManagerService::GetInstance().RegisterDevStateCallback(pkgName, extra); + ret = DeviceManagerService::GetInstance().UnRegisterDevStateCallback(pkgName, extra); + ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DeviceManagerServiceFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.h b/test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.h new file mode 100644 index 000000000..346817263 --- /dev/null +++ b/test/fuzztest/devicemanagerservice_fuzzer/device_manager_service_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 DEVICE_MANAGER_SERVICE_FUZZER_H +#define DEVICE_MANAGER_SERVICE_FUZZER_H + +#define FUZZ_PROJECT_NAME "devicemanagerservice_fuzzer" + +#endif // DEVICE_MANAGER_SERVICE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/devicemanagerservice_fuzzer/project.xml b/test/fuzztest/devicemanagerservice_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/devicemanagerservice_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn new file mode 100644 index 000000000..babfb1539 --- /dev/null +++ b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn @@ -0,0 +1,148 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("IpcClientManagerFuzzTest") { + module_out_path = "devicemanager/ipcclientmanager_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/ipcclientmanager_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "ipc_client_manager_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"IpcClientManagerFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] + +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":IpcClientManagerFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/ipcclientmanager_fuzzer/corpus/init b/test/fuzztest/ipcclientmanager_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/ipcclientmanager_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.cpp b/test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.cpp new file mode 100644 index 000000000..39bf2b417 --- /dev/null +++ b/test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 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 +#include +#include +#include +#include "ipc_client_manager.h" +#include "ipc_client_manager_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void IpcClientManagerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + int32_t cmdCode = *(reinterpret_cast(data)); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + req->SetPkgName(pkgName); + + std::shared_ptr instance = std::make_shared(); + int32_t ret = instance->Init(pkgName); + ret = instance->UnInit(pkgName); + ret = instance->SendRequest(cmdCode, req, rsp); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::IpcClientManagerFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.h b/test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.h new file mode 100644 index 000000000..46ab9c81c --- /dev/null +++ b/test/fuzztest/ipcclientmanager_fuzzer/ipc_client_manager_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 IPC_CLIENT_MANAGER_FUZZER_H +#define IPC_CLIENT_MANAGER_FUZZER_H + +#define FUZZ_PROJECT_NAME "ipcclientmanager_fuzzer" + +#endif // IPC_CLIENT_MANAGER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ipcclientmanager_fuzzer/project.xml b/test/fuzztest/ipcclientmanager_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/ipcclientmanager_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn new file mode 100644 index 000000000..7db9431c1 --- /dev/null +++ b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn @@ -0,0 +1,148 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("IpcCmdRegisterFuzzTest") { + module_out_path = "devicemanager/ipccmdregister_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/ipccmdregister_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice/include/ipc/lite", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "ipc_cmd_register_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"IpcCmdRegisterFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":IpcCmdRegisterFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/ipccmdregister_fuzzer/corpus/init b/test/fuzztest/ipccmdregister_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/ipccmdregister_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.cpp b/test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.cpp new file mode 100644 index 000000000..b8fa8300c --- /dev/null +++ b/test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2021 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 +#include +#include +#include +#include "ipc_cmd_register.h" +#include "ipc_client_manager.h" +#include "ipc_register_listener_req.h" +#include "ipc_get_trustdevice_rsp.h" +#include "ipc_get_info_by_network_rsp.h" +#include "ipc_get_info_by_network_req.h" +#include "ipc_get_trustdevice_req.h" +#include "ipc_start_discovery_req.h" +#include "ipc_stop_discovery_req.h" +#include "ipc_get_dmfaparam_rsp.h" +#include "ipc_register_dev_state_callback_req.h" +#include "ipc_set_useroperation_req.h" +#include "ipc_verify_authenticate_req.h" +#include "ipc_unauthenticate_device_req.h" +#include "ipc_authenticate_device_req.h" +#include "ipc_get_local_device_info_rsp.h" +#include "device_manager_notify.h" +#include "ipc_req.h" +#include "dm_device_info.h" +#include "dm_constants.h" +#include "ipc_def.h" +#include "dm_log.h" +#include "ipc_server_listenermgr.h" +#include "ipc_rsp.h" +#include "ipc_cmd_register_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void IpcCmdRegisterFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + int32_t cmdCode = *(reinterpret_cast(data)); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + MessageParcel data1; + MessageParcel reply1; + + int32_t ret = IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data1); + ret = IpcCmdRegister::GetInstance().ReadResponse(cmdCode, data1, rsp); + ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data1, reply1); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::IpcCmdRegisterFuzzTest(data, size); + + return 0; +} diff --git a/test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.h b/test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.h new file mode 100644 index 000000000..4e2e06d2b --- /dev/null +++ b/test/fuzztest/ipccmdregister_fuzzer/ipc_cmd_register_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 IPC_CMD_REGISTER_FUZZER_H +#define IPC_CMD_REGISTER_FUZZER_H + +#define FUZZ_PROJECT_NAME "ipccmdregister_fuzzer" + +#endif // IPC_CMD_REGISTER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ipccmdregister_fuzzer/project.xml b/test/fuzztest/ipccmdregister_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/ipccmdregister_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn new file mode 100644 index 000000000..5260fdbe0 --- /dev/null +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn @@ -0,0 +1,147 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("IpcServerClientProxyFuzzTest") { + module_out_path = "devicemanager/ipcserverclientproxy_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/ipcserverclientproxy_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "ipc_server_client_proxy_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"IpcServerClientProxyFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":IpcServerClientProxyFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/corpus/init b/test/fuzztest/ipcserverclientproxy_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.cpp b/test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.cpp new file mode 100644 index 000000000..fc4b171f2 --- /dev/null +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 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 +#include +#include +#include +#include "ipc_server_client_proxy.h" +#include "ipc_server_client_proxy_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void IpcServerClientProxyFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + int32_t cmdCode = *(reinterpret_cast(data)); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + sptr remoteObject = nullptr; + + auto instance = new IpcServerClientProxy(remoteObject); + if (instance != nullptr) { + instance->SendCmd(cmdCode, req, rsp); + delete instance; + } +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::IpcServerClientProxyFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.h b/test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.h new file mode 100644 index 000000000..05c7d3d6c --- /dev/null +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/ipc_server_client_proxy_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 IPC_SERVER_CLIENT_PROXY_FUZZER_H +#define IPC_SERVER_CLIENT_PROXY_FUZZER_H + +#define FUZZ_PROJECT_NAME "ipcserverclientproxy_fuzzer" + +#endif // IPC_SERVER_CLIENT_PROXY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/project.xml b/test/fuzztest/ipcserverclientproxy_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn new file mode 100644 index 000000000..643eed105 --- /dev/null +++ b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn @@ -0,0 +1,147 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("IpcServerListenerFuzzTest") { + module_out_path = "devicemanager/ipcserverlistener_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/ipcserverlistener_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "ipc_server_listener_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"IpcServerListenerFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":IpcServerListenerFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/ipcserverlistener_fuzzer/corpus/init b/test/fuzztest/ipcserverlistener_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/ipcserverlistener_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.cpp b/test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.cpp new file mode 100644 index 000000000..c4e8ff62b --- /dev/null +++ b/test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 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 +#include +#include +#include +#include "ipc_server_listener.h" +#include "ipc_server_listener_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void IpcServerListenerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + int32_t cmdCode = *(reinterpret_cast(data)); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + + std::shared_ptr ipcServerListener = std::make_shared(); + int32_t ret = ipcServerListener->SendRequest(cmdCode, req, rsp); + ret = ipcServerListener->SendAll(cmdCode, req, rsp); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::IpcServerListenerFuzzTest(data, size); + + return 0; +} diff --git a/test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.h b/test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.h new file mode 100644 index 000000000..4c80252e8 --- /dev/null +++ b/test/fuzztest/ipcserverlistener_fuzzer/ipc_server_listener_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 IPC_SERVER_LISTENER_FUZZER_H +#define IPC_SERVER_LISTENER_FUZZER_H + +#define FUZZ_PROJECT_NAME "ipcserverlistener_fuzzer" + +#endif // IPC_SERVER_LISTENER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ipcserverlistener_fuzzer/project.xml b/test/fuzztest/ipcserverlistener_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/ipcserverlistener_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn new file mode 100644 index 000000000..c92764a40 --- /dev/null +++ b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn @@ -0,0 +1,147 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("IpcServerStubFuzzTest") { + module_out_path = "devicemanager/ipcserverstub_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/ipcserverstub_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "ipc_server_stub_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"IpcServerStubFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":IpcServerStubFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/ipcserverstub_fuzzer/corpus/init b/test/fuzztest/ipcserverstub_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/ipcserverstub_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp b/test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp new file mode 100644 index 000000000..b05ae5c91 --- /dev/null +++ b/test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 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 +#include + +#include "ipc_client_stub.h" +#include "dm_device_info.h" +#include "ipc_server_stub.h" +#include "device_manager_impl.h" +#include "dm_constants.h" +#include "if_system_ability_manager.h" +#include "ipc_cmd_register.h" +#include "ipc_skeleton.h" +#include "ipc_types.h" +#include "iservice_registry.h" +#include "string_ex.h" +#include "system_ability_definition.h" +#include "ipc_server_stub_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void IpcServerStubFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + uint32_t code = *(reinterpret_cast(data)); + MessageParcel data1; + MessageParcel reply; + MessageOption option; + std::string pkgName(reinterpret_cast(data), size); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + sptr listener = data1.ReadRemoteObject(); + + int32_t ret = IpcServerStub::GetInstance().OnRemoteRequest(code, data1, reply, option); + ret = IpcServerStub::GetInstance().SendCmd(code, req, rsp); + ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener); + ret = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName); + sptr ipcPtr = IpcServerStub::GetInstance().GetDmListener(pkgName); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::IpcServerStubFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.h b/test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.h new file mode 100644 index 000000000..7d9f7876f --- /dev/null +++ b/test/fuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 IPC_SERVER_STUB_FUZZER_H +#define IPC_SERVER_STUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "ipcserverstub_fuzzer" + +#endif // IPC_SERVER_STUB_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ipcserverstub_fuzzer/project.xml b/test/fuzztest/ipcserverstub_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/ipcserverstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn b/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn new file mode 100644 index 000000000..fed59ca75 --- /dev/null +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn @@ -0,0 +1,147 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/devicemanager/devicemanager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { + module_out_path = "devicemanager/nativedevicemanagerjs_fuzzer" + fuzz_config_file = "//foundation/distributedhardware/devicemanager/test/fuzztest/nativedevicemanagerjs_fuzzer" + + include_dirs = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp/include", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js/include", + "//third_party/node/src", + "//foundation/ace/napi/native_engine", + "//foundation/ace/napi/interfaces/kits", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "//third_party/json/include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include/dependency/timer", + "${services_path}/include/dependency/softbus", + "${services_path}/include/authentication", + "${services_path}/include/adapter", + "${services_path}/include", + "${services_path}/include/ipc/standard", + "${services_path}/include/discovery", + "${services_path}/include/dependency/hichain", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/softbus_lite/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedhardware/devicemanager/test/unittest/mock", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + "//foundation/distributedhardware/devicemanager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr", + "//foundation/distributedhardware/devicemanager/ext/profile/include", + "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/distributedhardware/devicemanager/ext/mini/common/include", + "//base/security/deviceauth/interfaces/innerkits", + "${services_path}/include/ability", + "${services_path}/include/config", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite", + "//foundation/ace/napi/interfaces/innerkits/napi", + "//foundation/ace/napi/interfaces/innerkits", + "//third_party/jsframework/runtime/main/extend", + "//foundation/windowmanager/interfaces/kits", + "//third_party/jsframework/runtime/main/extend/systemplugin", + "//third_party/node/benchmark", + "//foundation/windowmanager/interfaces/kits/napi/screen_runtime", + "//third_party/libuv/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "native_devicemanager_js_fuzzer.cpp" ] + + deps = [ + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/aafwk/standard/services/abilitymgr:abilityms", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"NativeDevicemanagerJsFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] + + public_deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest", + "//utils/native/base:utils", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":NativeDevicemanagerJsFuzzTest" ] +} +############################################################################### \ No newline at end of file diff --git a/test/fuzztest/nativedevicemanagerjs_fuzzer/corpus/init b/test/fuzztest/nativedevicemanagerjs_fuzzer/corpus/init new file mode 100644 index 000000000..59aefb51c --- /dev/null +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2020-2021 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/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.cpp b/test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.cpp new file mode 100644 index 000000000..e9ac34f92 --- /dev/null +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022 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 "native_devicemanager_js.h" +#include "device_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "device_manager_callback.h" +#include "dm_app_image_info.h" +#include "dm_device_info.h" +#include "dm_native_event.h" +#include "dm_subscribe_info.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" +#include "nlohmann/json.hpp" +#include "native_devicemanager_js_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void NativeDeviceManagerStaticFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + napi_env env = *(reinterpret_cast(data)); + napi_callback_info info = *(reinterpret_cast(data)); + std::string buldleName(reinterpret_cast(data), size); + DeviceManagerNapi *deviceManagerNapiPtr = DeviceManagerNapi::GetDeviceManagerNapi(buldleName); + if (deviceManagerNapiPtr == nullptr) { + return; + } + + napi_value result = deviceManagerNapiPtr->CreateDeviceManager(env, info); + result = deviceManagerNapiPtr->GetTrustedDeviceListSync(env, info); + result = deviceManagerNapiPtr->AuthenticateDevice(env, info); + result = deviceManagerNapiPtr->VerifyAuthInfo(env, info); + result = deviceManagerNapiPtr->JsOn(env, info); + result = deviceManagerNapiPtr->JsOff(env, info); + result = deviceManagerNapiPtr->ReleaseDeviceManager(env, info); +} + +void NativeDeviceManagerOnFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string buldleName(reinterpret_cast(data), size); + std::string token(reinterpret_cast(data), size); + int32_t reason = *(reinterpret_cast(data)); + uint16_t subscribeId = *(reinterpret_cast(data)); + DmNapiDevStateChangeAction action = *(reinterpret_cast(data)); + DmDeviceInfo deviceInfo = *(reinterpret_cast(data)); + + uv_work_t *work = new (std::nothrow) uv_work_t; + std::unique_ptr jsCallback_; + jsCallback_ = std::make_unique(buldleName, 0, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback_.get()); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + delete work; + + DeviceManagerNapi *deviceManagerNapiPtr = DeviceManagerNapi::GetDeviceManagerNapi(buldleName); + if (deviceManagerNapiPtr == nullptr) { + return; + } + deviceManagerNapiPtr->OnDeviceStateChange(action, callback->deviceInfo_); + deviceManagerNapiPtr->OnDeviceFound(subscribeId, callback->deviceInfo_); + deviceManagerNapiPtr->OnDiscoveryFailed(subscribeId, reason); + deviceManagerNapiPtr->OnAuthResult(buldleName, token, reason, reason); + deviceManagerNapiPtr->OnVerifyResult(buldleName, reason, reason); + deviceManagerNapiPtr->OnDmfaCall(buldleName); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::NativeDeviceManagerStaticFuzzTest(data, size); + OHOS::DistributedHardware::NativeDeviceManagerOnFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.h b/test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.h new file mode 100644 index 000000000..89ec6f7ed --- /dev/null +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/native_devicemanager_js_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 NATIVE_DEVICEMANAGER_JS_FUZZER_H +#define NATIVE_DEVICEMANAGER_JS_FUZZER_H + +#define FUZZ_PROJECT_NAME "nativedevicemanagerjs_fuzzer" + +#endif // NATIVE_DEVICEMANAGER_JS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/nativedevicemanagerjs_fuzzer/project.xml b/test/fuzztest/nativedevicemanagerjs_fuzzer/project.xml new file mode 100644 index 000000000..27c26d11b --- /dev/null +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file -- Gitee From eb3a5407890377d0ad100c4ac892451c7dd3ed12 Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Mon, 18 Apr 2022 22:15:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- test/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 95b10dcae..a3b75ab34 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -16,9 +16,9 @@ group("test") { deps = [] if (support_jsapi) { - deps += [ + deps += [ + "fuzztest:fuzztest", "unittest:unittest", - "fuzztest:fuzztest" ] } } -- Gitee From fc8d27b4861073ca962f07fff50712affedef476 Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Mon, 18 Apr 2022 23:34:06 +0800 Subject: [PATCH 3/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index a3b75ab34..d48d6a0dd 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -21,4 +21,4 @@ group("test") { "unittest:unittest", ] } -} +} \ No newline at end of file -- Gitee From e35f770ce30901c2640e622bc74ac9ddbe699b4f Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Mon, 18 Apr 2022 23:46:00 +0800 Subject: [PATCH 4/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index d48d6a0dd..a3b75ab34 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -21,4 +21,4 @@ group("test") { "unittest:unittest", ] } -} \ No newline at end of file +} -- Gitee From 6f686944eeee2778e71b184bbfae65be2d3138b0 Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Tue, 19 Apr 2022 10:05:37 +0800 Subject: [PATCH 5/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- test/fuzztest/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index e57c94b3a..aa8aa90ff 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -14,7 +14,7 @@ group("fuzztest") { testonly = true - deps = [ + deps = [ "devicemanagerimpl_fuzzer:fuzztest", "devicemanagernotify_fuzzer:fuzztest", "devicemanagerservice_fuzzer:fuzztest", @@ -25,4 +25,4 @@ group("fuzztest") { "ipcserverstub_fuzzer:fuzztest", "nativedevicemanagerjs_fuzzer:fuzztest", ] -} \ No newline at end of file +} -- Gitee From 66b020eece4e60d00068e867b9de5605556c9c4b Mon Sep 17 00:00:00 2001 From: "@shi-xiaoxiao-iris" Date: Tue, 19 Apr 2022 10:24:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?FUZZ=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @shi-xiaoxiao-iris --- .../devicemanagerimpl_fuzzer/BUILD.gn | 15 +++++++------ .../devicemanagernotify_fuzzer/BUILD.gn | 5 ++--- .../devicemanagerservice_fuzzer/BUILD.gn | 5 ++--- .../fuzztest/ipcclientmanager_fuzzer/BUILD.gn | 18 +++++++--------- test/fuzztest/ipccmdregister_fuzzer/BUILD.gn | 17 +++++++-------- .../ipcserverclientproxy_fuzzer/BUILD.gn | 19 ++++++++--------- .../ipcserverlistener_fuzzer/BUILD.gn | 17 +++++++-------- test/fuzztest/ipcserverstub_fuzzer/BUILD.gn | 21 +++++++++---------- .../nativedevicemanagerjs_fuzzer/BUILD.gn | 19 ++++++++--------- 9 files changed, 63 insertions(+), 73 deletions(-) diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn index b5cc8ca33..4a669037b 100644 --- a/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("DeviceManagerImplFuzzTest") { @@ -97,11 +96,11 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { sources = [ "device_manager_impl_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", "${utils_path}:devicemanagerutils", "//foundation/ace/napi:ace_napi", "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager", "//utils/native/base:utils", ] @@ -112,15 +111,15 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] } @@ -130,4 +129,4 @@ group("fuzztest") { deps = [ ":DeviceManagerImplFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn index 6e239e70d..81c5b2a5f 100644 --- a/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("DeviceManagerNotifyFuzzTest") { @@ -99,4 +98,4 @@ group("fuzztest") { deps = [ ":DeviceManagerNotifyFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn index 486974013..ada13c730 100644 --- a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("DeviceManagerServiceFuzzTest") { @@ -99,4 +98,4 @@ group("fuzztest") { deps = [ ":DeviceManagerServiceFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn index babfb1539..52efb6e4b 100644 --- a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("IpcClientManagerFuzzTest") { @@ -93,8 +92,6 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { sources = [ "ipc_client_manager_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -102,6 +99,8 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] defines = [ @@ -111,9 +110,6 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -122,11 +118,14 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -136,7 +135,6 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "//third_party/googletest:gtest", "//utils/native/base:utils", ] - } ############################################################################### @@ -145,4 +143,4 @@ group("fuzztest") { deps = [ ":IpcClientManagerFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn index 7db9431c1..02ed42753 100644 --- a/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn +++ b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("IpcCmdRegisterFuzzTest") { @@ -94,8 +93,6 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { sources = [ "ipc_cmd_register_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -103,6 +100,8 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] defines = [ @@ -112,9 +111,6 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -123,11 +119,14 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -145,4 +144,4 @@ group("fuzztest") { deps = [ ":IpcCmdRegisterFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn index 5260fdbe0..330bffd6b 100644 --- a/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("IpcServerClientProxyFuzzTest") { @@ -93,8 +92,6 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { sources = [ "ipc_server_client_proxy_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -102,6 +99,8 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] defines = [ @@ -111,9 +110,6 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -122,11 +118,14 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -135,7 +134,7 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "//third_party/googletest:gmock", "//third_party/googletest:gtest", "//utils/native/base:utils", - ] + ] } ############################################################################### @@ -144,4 +143,4 @@ group("fuzztest") { deps = [ ":IpcServerClientProxyFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn index 643eed105..804d2b453 100644 --- a/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("IpcServerListenerFuzzTest") { @@ -93,8 +92,6 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { sources = [ "ipc_server_listener_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -102,6 +99,8 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] defines = [ @@ -111,9 +110,6 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -122,11 +118,14 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -144,4 +143,4 @@ group("fuzztest") { deps = [ ":IpcServerListenerFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn index c92764a40..dabc2a15f 100644 --- a/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("IpcServerStubFuzzTest") { @@ -93,8 +92,6 @@ ohos_fuzztest("IpcServerStubFuzzTest") { sources = [ "ipc_server_stub_fuzzer.cpp" ] deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -102,8 +99,10 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] - + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"IpcServerStubFuzzTest\"", @@ -111,9 +110,6 @@ ohos_fuzztest("IpcServerStubFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -122,11 +118,14 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -135,7 +134,7 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "//third_party/googletest:gmock", "//third_party/googletest:gtest", "//utils/native/base:utils", - ] + ] } ############################################################################### @@ -144,4 +143,4 @@ group("fuzztest") { deps = [ ":IpcServerStubFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### diff --git a/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn b/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn index fed59ca75..1659eca5b 100644 --- a/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn +++ b/test/fuzztest/nativedevicemanagerjs_fuzzer/BUILD.gn @@ -14,8 +14,7 @@ #####################hydra-fuzz################### import("//build/config/features.gni") import("//build/test.gni") -import( - "//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") ##############################fuzztest########################################## ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { @@ -92,9 +91,7 @@ ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { ] sources = [ "native_devicemanager_js_fuzzer.cpp" ] - deps = [ - "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", + deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", @@ -102,6 +99,8 @@ ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", ] defines = [ @@ -111,9 +110,6 @@ ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { ] external_deps = [ - "ipc:ipc_core", - "samgr_standard:samgr_proxy", - "startup_l2:syspara", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ces_standard:cesfwk_core", @@ -122,11 +118,14 @@ ohos_fuzztest("NativeDevicemanagerJsFuzzTest") { "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] - public_deps = [ + public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", @@ -144,4 +143,4 @@ group("fuzztest") { deps = [ ":NativeDevicemanagerJsFuzzTest" ] } -############################################################################### \ No newline at end of file +############################################################################### -- Gitee