mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-19 18:13:32 -04:00
@@ -18,6 +18,7 @@ group("fuzztest") {
|
||||
"devicemanagerimpl_fuzzer:fuzztest",
|
||||
"devicemanagernotify_fuzzer:fuzztest",
|
||||
"devicemanagerservice_fuzzer:fuzztest",
|
||||
"dmcredentialimpl_fuzzer:fuzztest",
|
||||
"ipcclientmanager_fuzzer:fuzztest",
|
||||
"ipccmdregister_fuzzer:fuzztest",
|
||||
"ipcserverclientproxy_fuzzer:fuzztest",
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# 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("DMCredentialImplFuzzTest") {
|
||||
module_out_path = "device_manager/devicemanager"
|
||||
fuzz_config_file = "//foundation/distributedhardware/device_manager/test/fuzztest/dmcredentialimpl_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/softbus",
|
||||
"${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",
|
||||
"//base/security/device_auth/interfaces/innerkits",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "dm_credential_impl_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DMCredentialImplFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
external_deps = [ "ipc:ipc_core" ]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":DMCredentialImplFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
@@ -0,0 +1,13 @@
|
||||
# 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
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 "dm_credential_impl_fuzzer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class CredentialCallbackFuzzTest : public CredentialCallback {
|
||||
public:
|
||||
virtual ~CredentialCallbackFuzzTest() {}
|
||||
virtual void OnCredentialResult(int32_t &action, const std::string &credentialResult) override {}
|
||||
};
|
||||
|
||||
void DeviceManagerCredentialFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
return;
|
||||
}
|
||||
std::string szData(reinterpret_cast<const char*>(data), size);
|
||||
std::shared_ptr<CredentialCallbackFuzzTest> callback = std::make_shared<CredentialCallbackFuzzTest>();
|
||||
std::string returnJsonStr;
|
||||
|
||||
DeviceManager::GetInstance().RequestCredential(szData, szData, returnJsonStr);
|
||||
DeviceManager::GetInstance().ImportCredential(szData, szData);
|
||||
DeviceManager::GetInstance().DeleteCredential(szData, szData);
|
||||
DeviceManager::GetInstance().RegisterCredentialCallback(szData, callback);
|
||||
DeviceManager::GetInstance().UnRegisterCredentialCallback(szData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DistributedHardware::DeviceManagerCredentialFuzzTest(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 DM_CREDENTIAL_IMPL_FUZZER_H
|
||||
#define DM_CREDENTIAL_IMPL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dmcredentialimpl_fuzzer"
|
||||
|
||||
#endif // DM_CREDENTIAL_IMPL_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>
|
||||
Reference in New Issue
Block a user