mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
@@ -18,6 +18,8 @@ group("fuzztest") {
|
||||
"dinputconfigdh_fuzzer:fuzztest",
|
||||
"dinputinitsink_fuzzer:fuzztest",
|
||||
"dinputinitsource_fuzzer:fuzztest",
|
||||
"dinputonsessionclosed_fuzzer:fuzztest",
|
||||
"dinputonsessionopend_fuzzer:fuzztest",
|
||||
"dinputreleasesink_fuzzer:fuzztest",
|
||||
"dinputreleasesource_fuzzer:fuzztest",
|
||||
"dinputsubscribelocaldh_fuzzer:fuzztest",
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright (c) 2023 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("../../../distributedinput.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DinputOnSessionClosedFuzzTest") {
|
||||
module_out_path = "distributed_input/system"
|
||||
|
||||
fuzz_config_file =
|
||||
"${distributedinput_path}/test/fuzztest/dinputonsessionclosed_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"${av_transport_path}/common/include",
|
||||
"${services_source_path}/transport/include",
|
||||
"${distributedinput_path}/services/transportbase/include",
|
||||
"${common_path}/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_interfaces_path}/include",
|
||||
"${service_common}/include",
|
||||
"${services_source_path}/inputinject/include",
|
||||
"${services_source_path}/transport/include",
|
||||
"//third_party/json/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"${frameworks_path}/include",
|
||||
"${distributedinput_path}/inputdevicehandler/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dinputonsessionclosed_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"distributed_hardware_fwk:libdhfwk_sdk",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DinputConfigDhFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":DinputOnSessionClosedFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 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) 2023 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 "dinputonsessionclosed_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <refbase.h>
|
||||
|
||||
#include "distributed_input_transport_base.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void OnSessionClosedFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
DistributedInput::DistributedInputTransportBase::GetInstance().OnSessionClosed(sessionId);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DistributedHardware::OnSessionClosedFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 DINPUT_ON_SESSION_OPEND_FUZZER_H
|
||||
#define DINPUT_ON_SESSION_OPEND_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dinputonsessionclosed_fuzzer"
|
||||
|
||||
#endif // DINPUT_ON_SESSION_OPEND_FUZZER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2023 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,84 @@
|
||||
# Copyright (c) 2023 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("../../../distributedinput.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DinputOnSessionOpendFuzzTest") {
|
||||
module_out_path = "distributed_input/system"
|
||||
|
||||
fuzz_config_file =
|
||||
"${distributedinput_path}/test/fuzztest/dinputonsessionopend_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"${av_transport_path}/common/include",
|
||||
"${services_source_path}/transport/include",
|
||||
"${distributedinput_path}/services/transportbase/include",
|
||||
"${common_path}/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_interfaces_path}/include",
|
||||
"${service_common}/include",
|
||||
"${services_source_path}/inputinject/include",
|
||||
"${services_source_path}/transport/include",
|
||||
"//third_party/json/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"${frameworks_path}/include",
|
||||
"${distributedinput_path}/inputdevicehandler/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dinputonsessionopend_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"distributed_hardware_fwk:libdhfwk_sdk",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DinputOnSessionOpendFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":DinputOnSessionOpendFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 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) 2023 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 "dinputonsessionopend_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <refbase.h>
|
||||
|
||||
#include "distributed_input_transport_base.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void OnSessionOpenedFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
int32_t result = *(reinterpret_cast<const int32_t*>(data));
|
||||
DistributedInput::DistributedInputTransportBase::GetInstance().OnSessionOpened(sessionId, result);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DistributedHardware::OnSessionOpenedFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 DINPUT_ON_SESSION_CLOSED_FUZZER_H
|
||||
#define DINPUT_ON_SESSION_CLOSED_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dinputonsessionopend_fuzzer"
|
||||
|
||||
#endif // DINPUT_ON_SESSION_CLOSED_FUZZER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2023 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