!658 【任务】分布式设备管理Fuzz测试整改

Merge pull request !658 from 王移波/master
This commit is contained in:
openharmony_ci
2022-07-15 09:23:48 +00:00
committed by Gitee
66 changed files with 2611 additions and 273 deletions
+13 -1
View File
@@ -15,14 +15,26 @@ group("fuzztest") {
testonly = true
deps = [
"devicemanagerimpl_fuzzer:fuzztest",
"authenticatedevice_fuzzer:fuzztest",
"devicediscovery_fuzzer:fuzztest",
"devicelist_fuzzer:fuzztest",
"devicemanagernotify_fuzzer:fuzztest",
"devicemanagernotify_fuzzer:fuzztest",
"devicemanagerservice_fuzzer:fuzztest",
"dmcredentialimpl_fuzzer:fuzztest",
"getfaparam_fuzzer:fuzztest",
"getudidbynetworkid_fuzzer:fuzztest",
"getuuidbynetworkid_fuzzer:fuzztest",
"initdevicemanager_fuzzer:fuzztest",
"ipcclientmanager_fuzzer:fuzztest",
"ipccmdregister_fuzzer:fuzztest",
"ipcserverclientproxy_fuzzer:fuzztest",
"ipcserverlistener_fuzzer:fuzztest",
"ipcserverstub_fuzzer:fuzztest",
"registerdevicemanagerfacallback_fuzzer:fuzztest",
"registerdevstatecallback_fuzzer:fuzztest",
"setuseroperation_fuzzer:fuzztest",
"unauthenticatedevice_fuzzer:fuzztest",
"unregisterdevicemanagerfacallback_fuzzer:fuzztest",
]
}
@@ -17,9 +17,9 @@ import("//build/test.gni")
import("//foundation/distributedhardware/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("DeviceManagerImplFuzzTest") {
ohos_fuzztest("AuthenticateDeviceFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/devicemanagerimpl_fuzzer"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/authenticatedevice_fuzzer"
include_dirs = [
"${utils_path}/include",
@@ -85,7 +85,7 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") {
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "device_manager_impl_fuzzer.cpp" ]
sources = [ "authenticate_device_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
@@ -96,7 +96,7 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") {
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"DeviceManagerImplFuzzTest\"",
"DH_LOG_TAG=\"AuthenticateDeviceFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
@@ -118,6 +118,6 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") {
group("fuzztest") {
testonly = true
deps = [ ":DeviceManagerImplFuzzTest" ]
deps = [ ":AuthenticateDeviceFuzzTest" ]
}
###############################################################################
@@ -0,0 +1,51 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "authenticate_device_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void AuthenticateDeviceFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string pkgName(reinterpret_cast<const char*>(data), size);
int32_t authType = *(reinterpret_cast<const int32_t*>(data));
DmDeviceInfo deviceInfo;
std::string extraString(reinterpret_cast<const char*>(data), size);
std::shared_ptr<AuthenticateCallback> callback = nullptr;
DeviceManager::GetInstance().AuthenticateDevice(pkgName,
authType, deviceInfo, extraString, callback);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::AuthenticateDeviceFuzzTest(data, size);
return 0;
}
@@ -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 AUTHENTICATE_DEVICE_FUZZ_TEST_H
#define AUTHENTICATE_DEVICE_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "authenticatedevice_fuzzer"
#endif // AUTHENTICATE_DEVICE_FUZZ_TEST_H
@@ -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
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("DeviceDiscoveryFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/devicediscovery_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "device_discovery_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"DeviceDiscoveryFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":DeviceDiscoveryFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,70 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "device_discovery_fuzzer.h"
const int nCapabiltyBufferSize = 65;
namespace OHOS {
namespace DistributedHardware {
class DeviceDiscoveryCallbackTest : public DiscoveryCallback {
public:
DeviceDiscoveryCallbackTest() : DiscoveryCallback() {}
virtual ~DeviceDiscoveryCallbackTest() {}
virtual void OnDiscoverySuccess(uint16_t subscribeId) override {}
virtual void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) override {}
virtual void OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) override {}
};
void DeviceDiscoveryFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
DmSubscribeInfo subInfo;
subInfo.subscribeId = *(reinterpret_cast<const uint16_t*>(data));
subInfo.mode = *(reinterpret_cast<const DmDiscoverMode*>(data));
subInfo.medium = *(reinterpret_cast<const DmExchangeMedium*>(data));
subInfo.freq = *(reinterpret_cast<const DmExchangeFreq*>(data));
subInfo.isSameAccount = *(reinterpret_cast<const bool*>(data));
subInfo.isWakeRemote = *(reinterpret_cast<const bool*>(data));
strncpy_s(subInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, (char*)data, nCapabiltyBufferSize);
std::string extra(reinterpret_cast<const char*>(data), size);
int16_t subscribeId = *(reinterpret_cast<const int16_t*>(data));
std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DeviceDiscoveryCallbackTest>();
int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(bundleName,
subInfo, extra, callback);
ret = DeviceManager::GetInstance().StopDeviceDiscovery(bundleName, subscribeId);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::DeviceDiscoveryFuzzTest(data, size);
return 0;
}
@@ -13,9 +13,9 @@
* limitations under the License.
*/
#ifndef DEVICE_MANAGER_IMPL_FUZZER_H
#define DEVICE_MANAGER_IMPL_FUZZER_H
#ifndef DEVICE_DISCOVERY_FUZZ_TEST_H
#define DEVICE_DISCOVERY_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "devicemanagerimpl_fuzzer"
#define FUZZ_PROJECT_NAME "devicediscovery_fuzzer"
#endif // DEVICE_MANAGER_IMPL_FUZZER_H
#endif // DEVICE_DISCOVERY_FUZZ_TEST_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
+123
View File
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("DeviceListFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/devicelist_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "device_list_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"DeviceListFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":DeviceListFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,50 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "device_list_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void DeviceListFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string extra(reinterpret_cast<const char*>(data), size);
std::vector<DmDeviceInfo> devList;
std::string bundleName(reinterpret_cast<const char*>(data), size);
DmDeviceInfo deviceInfo;
int32_t ret = DeviceManager::GetInstance().GetTrustedDeviceList(bundleName, extra, devList);
ret = DeviceManager::GetInstance().GetLocalDeviceInfo(bundleName, deviceInfo);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::DeviceListFuzzTest(data, size);
return 0;
}
@@ -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_LIST_FUZZ_TEST_H
#define DEVICE_LIST_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "devicelist_fuzzer"
#endif // DEVICE_LIST_FUZZ_TEST_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -1,259 +0,0 @@
/*
* 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 <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <securec.h>
#include <uv.h>
#include <string>
#include <iostream>
#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 "nlohmann/json.hpp"
#include "native_devicemanager_js.h"
#include "device_manager_impl_fuzzer.h"
const int nCapabiltyBufferSize = 65;
namespace OHOS {
namespace DistributedHardware {
class DeviceDiscoveryCallbackTest : public DiscoveryCallback {
public:
DeviceDiscoveryCallbackTest() : DiscoveryCallback() {}
virtual ~DeviceDiscoveryCallbackTest() {}
virtual void OnDiscoverySuccess(uint16_t subscribeId) override {}
virtual void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) override {}
virtual void OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) override {}
};
class DmInitCallbackTest : public DmInitCallback {
public:
DmInitCallbackTest() : DmInitCallback() {}
virtual ~DmInitCallbackTest() override {}
virtual void OnRemoteDied() override {}
};
class DeviceStateCallbackTest : public DeviceStateCallback {
public:
DeviceStateCallbackTest() : DeviceStateCallback() {}
virtual ~DeviceStateCallbackTest() override {}
virtual void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override {}
virtual void OnDeviceReady(const DmDeviceInfo &deviceInfo) override {}
virtual void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override {}
virtual void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override {}
};
class DeviceManagerFaCallbackTest : public DeviceManagerFaCallback {
public:
DeviceManagerFaCallbackTest() : DeviceManagerFaCallback() {}
virtual ~DeviceManagerFaCallbackTest() override {}
virtual void OnCall(const std::string &paramJson) override {}
};
void InitDeviceManagerFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string packName(reinterpret_cast<const char*>(data), size);
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::shared_ptr<DmInitCallbackTest> callback = std::make_shared<DmInitCallbackTest>();
int32_t ret = DeviceManager::GetInstance().InitDeviceManager(packName, callback);
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<const char*>(data), size);
std::vector<DmDeviceInfo> devList;
std::string bundleName(reinterpret_cast<const char*>(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<const char*>(data), size);
DmSubscribeInfo subInfo;
subInfo.subscribeId = *(reinterpret_cast<const uint16_t*>(data));
subInfo.mode = *(reinterpret_cast<const DmDiscoverMode*>(data));
subInfo.medium = *(reinterpret_cast<const DmExchangeMedium*>(data));
subInfo.freq = *(reinterpret_cast<const DmExchangeFreq*>(data));
subInfo.isSameAccount = *(reinterpret_cast<const bool*>(data));
subInfo.isWakeRemote = *(reinterpret_cast<const bool*>(data));
strncpy_s(subInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, (char*)data, nCapabiltyBufferSize);
std::string extra(reinterpret_cast<const char*>(data), size);
int16_t subscribeId = *(reinterpret_cast<const int16_t*>(data));
std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DeviceDiscoveryCallbackTest>();
int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(bundleName,
subInfo, extra, callback);
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<const char*>(data), size);
int32_t authType = *(reinterpret_cast<const int32_t*>(data));
DmDeviceInfo deviceInfo;
std::string extraString(reinterpret_cast<const char*>(data), size);
std::shared_ptr<AuthenticateCallback> callback = nullptr;
DeviceManager::GetInstance().AuthenticateDevice(pkgName,
authType, deviceInfo, extraString, callback);
}
void UnAuthenticateDeviceFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
DmDeviceInfo deviceInfo;
DeviceManager::GetInstance().UnAuthenticateDevice(bundleName, deviceInfo);
}
void RegisterDeviceManagerFaCallbackFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::string packageName(reinterpret_cast<const char*>(data), size);
std::shared_ptr<DeviceManagerFaCallbackTest> callback = std::make_shared<DeviceManagerFaCallbackTest>();
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<const char*>(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<const char*>(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<const char*>(data), size);
int32_t action = *(reinterpret_cast<const int32_t*>(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<const char*>(data), size);
std::string netWorkId(reinterpret_cast<const char*>(data), size);
std::string udid(reinterpret_cast<const char*>(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<const char*>(data), size);
std::string netWorkId(reinterpret_cast<const char*>(data), size);
std::string uuid(reinterpret_cast<const char*>(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<const char*>(data), size);
std::string extra(reinterpret_cast<const char*>(data), size);
int32_t ret = DeviceManager::GetInstance().RegisterDevStateCallback(bundleName,
extra);
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::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;
}
@@ -45,6 +45,7 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") {
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_path}/include/deviceinfo/",
"${servicesimpl_path}/include/devicestate",
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
"//foundation/communication/softbus_lite/interfaces/kits/transport",
@@ -13,6 +13,10 @@
* limitations under the License.
*/
#include <cstddef>
#include <cstdint>
#include <string>
#include <algorithm>
#include <chrono>
#include <cstddef>
@@ -31,11 +31,9 @@ void DeviceManagerServiceFuzzTest(const uint8_t* data, size_t size)
uint16_t subscribeId = *(reinterpret_cast<const uint16_t*>(data));
DmSubscribeInfo subscribeInfo;
std::vector<DmDeviceInfo> 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);
+123
View File
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("GetFaParamFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/getfaparam_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "get_fa_param_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"GetFaParamFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":GetFaParamFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,47 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "get_fa_param_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void GetFaParamFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string packName(reinterpret_cast<const char*>(data), size);
DmAuthParam authParam;
DeviceManager::GetInstance().GetFaParam(packName, authParam);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::GetFaParamFuzzTest(data, size);
return 0;
}
@@ -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 GET_FA_PARAM_FUZZ_TEST_H
#define GET_FA_PARAM_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "getfaparam_fuzzer"
#endif // GET_FA_PARAM_FUZZ_TEST_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("GetUdidByNetworkIdFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/getudidbynetworkid_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "get_udid_by_network_id_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"GetUdidByNetworkIdFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":GetUdidByNetworkIdFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,48 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "get_udid_by_network_id_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void GetUdidByNetworkIdFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string pkgName(reinterpret_cast<const char*>(data), size);
std::string netWorkId(reinterpret_cast<const char*>(data), size);
std::string udid(reinterpret_cast<const char*>(data), size);
DeviceManager::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::GetUdidByNetworkIdFuzzTest(data, size);
return 0;
}
@@ -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 GET_UDID_BY_NETWORK_ID_FUZZ_TEST_H
#define GET_UDID_BY_NETWORK_ID_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "getudidbynetworkid_fuzzer"
#endif // GET_UDID_BY_NETWORK_ID_FUZZ_TEST_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("GetUuidByNetworkIdFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/getuuidbynetworkid_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "get_uuid_by_network_id_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"GetUuidByNetworkIdFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":GetUuidByNetworkIdFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,48 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "get_uuid_by_network_id_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void GetUuidByNetworkIdFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string packName(reinterpret_cast<const char*>(data), size);
std::string netWorkId(reinterpret_cast<const char*>(data), size);
std::string uuid(reinterpret_cast<const char*>(data), size);
DeviceManager::GetInstance().GetUuidByNetworkId(packName, netWorkId, uuid);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::GetUuidByNetworkIdFuzzTest(data, size);
return 0;
}
@@ -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 GET_UUID_BY_NETWORK_ID_FUZZ_TEST_H
#define GET_UUID_BY_NETWORK_ID_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "getuuidbynetworkid_fuzzer"
#endif // GET_UUID_BY_NETWORK_ID_FUZZ_TEST_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -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.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/distributedhardware/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("InitDeviceManagerFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/initdevicemanager_fuzzer"
include_dirs = [
"${utils_path}/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",
"${common_path}/include",
"${common_path}/include/ipc",
"${common_path}/include/ipc/model",
"${utils_path}/include/ipc/standard",
"${servicesimpl_path}/include",
# "${servicesimpl_path}/include/dependency/timer",
# "${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
# "${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/dependency/hichain",
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
"//foundation/communication/dsoftbus/interfaces/kits/common",
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
"//foundation/distributedhardware/device_manager/test/unittest/mock",
# "//foundation/distributedhardware/device_manager/ext/profile/include",
"//base/security/device_auth/interfaces/innerkits",
# "${servicesimpl_path}/include/ability",
# "${servicesimpl_path}/include/config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "init_device_manager_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"InitDeviceManagerFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
# "bundle_framework:appexecfwk_base",
# "bundle_framework:appexecfwk_core",
# "eventhandler:libeventhandler",
# "hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
# "safwk:system_ability_fwk",
# "samgr_standard:samgr_proxy",
# "startup_l2:syspara",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":InitDeviceManagerFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,55 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "init_device_manager_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
class DmInitCallbackTest : public DmInitCallback {
public:
DmInitCallbackTest() : DmInitCallback() {}
virtual ~DmInitCallbackTest() override {}
virtual void OnRemoteDied() override {}
};
void InitDeviceManagerFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string packName(reinterpret_cast<const char*>(data), size);
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::shared_ptr<DmInitCallbackTest> callback = std::make_shared<DmInitCallbackTest>();
int32_t ret = DeviceManager::GetInstance().InitDeviceManager(packName, callback);
ret = DeviceManager::GetInstance().UnInitDeviceManager(packName);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::InitDeviceManagerFuzzTest(data, size);
return 0;
}
@@ -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 INIT_DEVICE_MANAGER_FUZZ_TEST_FUZZER_H
#define INIT_DEVICE_MANAGER_FUZZ_TEST_FUZZER_H
#define FUZZ_PROJECT_NAME "initdevicemanager_fuzzer"
#endif // INIT_DEVICE_MANAGER_FUZZ_TEST_FUZZER_H
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -47,13 +47,11 @@ void IpcServerStubFuzzTest(const uint8_t* data, size_t size)
std::shared_ptr<IpcReq> req = nullptr;
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
IpcServerStub::GetInstance().OnStart();
IpcServerStub::GetInstance().OnRemoteRequest(code, data1, reply, option);
IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, listener);
IpcServerStub::GetInstance().GetDmListener(pkgName);
IpcServerStub::GetInstance().SendCmd(code, req, rsp);
IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName);
IpcServerStub::GetInstance().OnStop();
}
}
}
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("RegisterDeviceManagerFaCallbackFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/registerdevicemanagerfacallback_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "register_device_manager_fa_callback_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"RegisterDeviceManagerFaCallbackFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":RegisterDeviceManagerFaCallbackFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,55 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "register_device_manager_fa_callback_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
class DeviceManagerFaCallbackTest : public DeviceManagerFaCallback {
public:
DeviceManagerFaCallbackTest() : DeviceManagerFaCallback() {}
virtual ~DeviceManagerFaCallbackTest() override {}
virtual void OnCall(const std::string &paramJson) override {}
};
void RegisterDeviceManagerFaCallbackFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::string packageName(reinterpret_cast<const char*>(data), size);
std::shared_ptr<DeviceManagerFaCallbackTest> callback = std::make_shared<DeviceManagerFaCallbackTest>();
DeviceManager::GetInstance().RegisterDeviceManagerFaCallback(packageName, callback);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::RegisterDeviceManagerFaCallbackFuzzTest(data, size);
return 0;
}
@@ -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 REGISTER_DEVICE_MANAGER_FA_CALLBACK_FUZZ_TEST_H
#define REGISTER_DEVICE_MANAGER_FA_CALLBACK_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "registerdevicemanagerfacallback_fuzzer"
#endif // REGISTER_DEVICE_MANAGER_FA_CALLBACK_FUZZ_TEST_H
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("RegisterDevStateCallbackFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/registerdevstatecallback_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "register_dev_state_callback_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"RegisterDevStateCallbackFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":RegisterDevStateCallbackFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,48 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "register_dev_state_callback_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void RegisterDevStateCallbackFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::string extra(reinterpret_cast<const char*>(data), size);
int32_t ret = DeviceManager::GetInstance().RegisterDevStateCallback(bundleName,
extra);
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::RegisterDevStateCallbackFuzzTest(data, size);
return 0;
}
@@ -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 REGISTER_DEV_STATE_CALLBACK_FUZZ_TEST_H
#define REGISTER_DEV_STATE_CALLBACK_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "registerdevstatecallback_fuzzer"
#endif // REGISTER_DEV_STATE_CALLBACK_FUZZ_TEST_H
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("SetUserOperationFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/setuseroperation_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "set_user_operation_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SetUserOperationFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":SetUserOperationFuzzTest" ]
}
###############################################################################
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,46 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "set_user_operation_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void SetUserOperationFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string pkgName(reinterpret_cast<const char*>(data), size);
int32_t action = *(reinterpret_cast<const int32_t*>(data));
DeviceManager::GetInstance().SetUserOperation(pkgName, action);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::SetUserOperationFuzzTest(data, size);
return 0;
}
@@ -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 SET_USER_OPERATION_FUZZ_TEST_H
#define SET_USER_OPERATION_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "setuseroperation_fuzzer"
#endif // SET_USER_OPERATION_FUZZ_TEST_H
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("UnAuthenticateDeviceFuzzTest") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/unauthenticatedevice_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "un_authenticate_device_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"UnAuthenticateDeviceFuzzTest\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":UnAuthenticateDeviceFuzzTest" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,47 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "un_authenticate_device_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void UnAuthenticateDeviceFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
DmDeviceInfo deviceInfo;
DeviceManager::GetInstance().UnAuthenticateDevice(bundleName, deviceInfo);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::UnAuthenticateDeviceFuzzTest(data, size);
return 0;
}
@@ -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 UN_AUTHENTICATE_DEVICE_FUZZ_TEST_H
#define UN_AUTHENTICATE_DEVICE_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "unauthenticatedevice_fuzzer"
#endif // UN_AUTHENTICATE_DEVICE_FUZZ_TEST_H
@@ -0,0 +1,123 @@
# 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/device_manager/device_manager.gni")
##############################fuzztest##########################################
ohos_fuzztest("UnRegisterDeviceManagerFaCallback") {
module_out_path = "device_manager/devicemanager"
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/unregisterdevicemanagerfacallback_fuzzer"
include_dirs = [
"${utils_path}/include",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/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",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/dependency/timer",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/dependency/softbus",
"${servicesimpl_path}/include/authentication",
"${servicesimpl_path}/include/adapter",
"${servicesimpl_path}/include",
"${servicesimpl_path}/include/ipc/standard",
"${servicesimpl_path}/include/discovery",
"${servicesimpl_path}/include/dependency/hichain",
"${servicesimpl_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/device_manager/test/unittest/mock",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch",
"//foundation/distributedhardware/device_manager/ext/profile/include",
"//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include",
"//foundation/distributedhardware/device_manager/ext/mini/common/include",
"//base/security/device_auth/interfaces/innerkits",
"${servicesimpl_path}/include/ability",
"${servicesimpl_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/arkui/napi/interfaces/inner_api/napi",
"//foundation/arkui/napi/interfaces/innerkits",
"//third_party/jsframework/runtime/main/extend",
"//third_party/jsframework/runtime/main/extend/systemplugin",
"//third_party/node/benchmark",
"//third_party/libuv/include",
"//foundation/distributedhardware/device_manager/interfaces/kits/js/include",
"//third_party/node/src",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/napi/interfaces/kits",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "un_register_device_manager_fa_call_back_fuzzer.cpp" ]
deps = [
"${utils_path}:devicemanagerutils",
"//foundation/arkui/napi:ace_napi",
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
"//utils/native/base:utils",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"UnRegisterDeviceManagerFaCallback\"",
"LOG_DOMAIN=0xD004100",
]
external_deps = [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"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",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":UnRegisterDeviceManagerFaCallback" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,45 @@
/*
* 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 <cstddef>
#include <cstdint>
#include <string>
#include "device_manager_impl.h"
#include "device_manager.h"
#include "device_manager_callback.h"
#include "un_register_device_manager_fa_call_back_fuzzer.h"
namespace OHOS {
namespace DistributedHardware {
void UnRegisterDeviceManagerFaCallbackFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
return;
}
std::string packName(reinterpret_cast<const char*>(data), size);
DeviceManager::GetInstance().UnRegisterDeviceManagerFaCallback(packName);
}
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DistributedHardware::UnRegisterDeviceManagerFaCallbackFuzzTest(data, size);
return 0;
}
@@ -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 UN_REGISTER_DEVICE_MANAGER_FA_CALL_BACK_FUZZ_TEST_H
#define UN_REGISTER_DEVICE_MANAGER_FA_CALL_BACK_FUZZ_TEST_H
#define FUZZ_PROJECT_NAME "unregisterdevicemanagerfacallback_fuzzer"
#endif // UN_REGISTER_DEVICE_MANAGER_FA_CALL_BACK_FUZZ_TEST_H