From 740b04e800fa09c4e4c1b25e15999f20b079208a Mon Sep 17 00:00:00 2001 From: huxianghao Date: Sat, 13 Sep 2025 00:42:15 +0000 Subject: [PATCH] [test]:Modify fuzz injectevent 1 Signed-off-by: huxianghao --- .../injecteventsetdeviceid_fuzzer/BUILD.gn | 144 ++++++++++++++++++ .../injecteventsetdeviceid_fuzzer/corpus/init | 14 ++ .../injecteventsetdeviceid_fuzzer.cpp | 51 +++++++ .../injecteventsetdeviceid_fuzzer.h | 21 +++ .../injecteventsetdeviceid_fuzzer/project.xml | 25 +++ .../injecteventsetdisplayxy_fuzzer/BUILD.gn | 144 ++++++++++++++++++ .../corpus/init | 14 ++ .../injecteventsetdisplayxy_fuzzer.cpp | 53 +++++++ .../injecteventsetdisplayxy_fuzzer.h | 21 +++ .../project.xml | 25 +++ .../injecteventsetdowntime_fuzzer/BUILD.gn | 144 ++++++++++++++++++ .../injecteventsetdowntime_fuzzer/corpus/init | 14 ++ .../injecteventsetdowntime_fuzzer.cpp | 51 +++++++ .../injecteventsetdowntime_fuzzer.h | 21 +++ .../injecteventsetdowntime_fuzzer/project.xml | 25 +++ .../injecteventsetkeyaction_fuzzer/BUILD.gn | 144 ++++++++++++++++++ .../corpus/init | 14 ++ .../injecteventsetkeyaction_fuzzer.cpp | 52 +++++++ .../injecteventsetkeyaction_fuzzer.h | 21 +++ .../project.xml | 25 +++ .../injecteventsetkeycode_fuzzer/BUILD.gn | 144 ++++++++++++++++++ .../injecteventsetkeycode_fuzzer/corpus/init | 14 ++ .../injecteventsetkeycode_fuzzer.cpp | 51 +++++++ .../injecteventsetkeycode_fuzzer.h | 21 +++ .../injecteventsetkeycode_fuzzer/project.xml | 25 +++ 25 files changed, 1278 insertions(+) create mode 100644 test/fuzztest/injecteventsetdeviceid_fuzzer/BUILD.gn create mode 100644 test/fuzztest/injecteventsetdeviceid_fuzzer/corpus/init create mode 100644 test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.cpp create mode 100644 test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.h create mode 100644 test/fuzztest/injecteventsetdeviceid_fuzzer/project.xml create mode 100644 test/fuzztest/injecteventsetdisplayxy_fuzzer/BUILD.gn create mode 100644 test/fuzztest/injecteventsetdisplayxy_fuzzer/corpus/init create mode 100644 test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.cpp create mode 100644 test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.h create mode 100644 test/fuzztest/injecteventsetdisplayxy_fuzzer/project.xml create mode 100644 test/fuzztest/injecteventsetdowntime_fuzzer/BUILD.gn create mode 100644 test/fuzztest/injecteventsetdowntime_fuzzer/corpus/init create mode 100644 test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.cpp create mode 100644 test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.h create mode 100644 test/fuzztest/injecteventsetdowntime_fuzzer/project.xml create mode 100644 test/fuzztest/injecteventsetkeyaction_fuzzer/BUILD.gn create mode 100644 test/fuzztest/injecteventsetkeyaction_fuzzer/corpus/init create mode 100644 test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.cpp create mode 100644 test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.h create mode 100644 test/fuzztest/injecteventsetkeyaction_fuzzer/project.xml create mode 100644 test/fuzztest/injecteventsetkeycode_fuzzer/BUILD.gn create mode 100644 test/fuzztest/injecteventsetkeycode_fuzzer/corpus/init create mode 100644 test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.cpp create mode 100644 test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.h create mode 100644 test/fuzztest/injecteventsetkeycode_fuzzer/project.xml diff --git a/test/fuzztest/injecteventsetdeviceid_fuzzer/BUILD.gn b/test/fuzztest/injecteventsetdeviceid_fuzzer/BUILD.gn new file mode 100644 index 0000000000..3421eeccfa --- /dev/null +++ b/test/fuzztest/injecteventsetdeviceid_fuzzer/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright (c) 2024 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("InjecteventSetDeviceIdFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/injecteventsetdeviceid_fuzzer" + include_dirs = [ + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/device_config/include", + "${mmi_path}/service/device_manager/include", + "${mmi_path}/service/device_scalability/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dump/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/gesturesense_wrapper/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/dfx/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/permission_helper/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/filter/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/nap_process/include", + "${mmi_path}/service/event_resample/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/util/common/include", + "${mmi_path}/util/socket/include", + "${mmi_path}/util/network/include", + "${mmi_path}/frameworks/proxy/event_handler/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "injecteventsetdeviceid_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "cJSON:cjson", + "c_utils:utilsbase", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hilog:libhilog_base", + "hisysevent:libhisysevent", + "image_framework:image_native", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "napi:ace_napi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (resource_schedule_service_enabled) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InjecteventSetDeviceIdFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/injecteventsetdeviceid_fuzzer/corpus/init b/test/fuzztest/injecteventsetdeviceid_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/injecteventsetdeviceid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.cpp b/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.cpp new file mode 100644 index 0000000000..073ff01bcd --- /dev/null +++ b/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "injecteventsetdeviceid_fuzzer.h" +#include "input_manager.h" +#include "define_multimodal.h" +#include "mmi_service.h" +#include "mmi_log.h" + +namespace OHOS { +namespace MMI { + +bool InjecteventSetDeviceIdFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t pointerId = provider.ConsumeIntegral(); + + PointerEvent::PointerItem downitem; + downitem.SetDeviceId(pointerId); + + return true; +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < 0) { + return 0; + } + /* Run your code on data */ + + OHOS::MMI::InjecteventSetDeviceIdFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.h b/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.h new file mode 100644 index 0000000000..1dc01f5a92 --- /dev/null +++ b/test/fuzztest/injecteventsetdeviceid_fuzzer/injecteventsetdeviceid_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 INJECTEVENT_FUZZER_H +#define INJECTEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "injecteventsetdeviceid_fuzzer" + +#endif // INJECTEVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdeviceid_fuzzer/project.xml b/test/fuzztest/injecteventsetdeviceid_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/injecteventsetdeviceid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/injecteventsetdisplayxy_fuzzer/BUILD.gn b/test/fuzztest/injecteventsetdisplayxy_fuzzer/BUILD.gn new file mode 100644 index 0000000000..95a68f4fe3 --- /dev/null +++ b/test/fuzztest/injecteventsetdisplayxy_fuzzer/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright (c) 2024 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("InjecteventSetDisplayXYFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/injecteventsetdisplayxy_fuzzer" + include_dirs = [ + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/device_config/include", + "${mmi_path}/service/device_manager/include", + "${mmi_path}/service/device_scalability/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dump/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/gesturesense_wrapper/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/dfx/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/permission_helper/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/filter/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/nap_process/include", + "${mmi_path}/service/event_resample/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/util/common/include", + "${mmi_path}/util/socket/include", + "${mmi_path}/util/network/include", + "${mmi_path}/frameworks/proxy/event_handler/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "injecteventsetdisplayxy_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "cJSON:cjson", + "c_utils:utilsbase", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hilog:libhilog_base", + "hisysevent:libhisysevent", + "image_framework:image_native", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "napi:ace_napi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (resource_schedule_service_enabled) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InjecteventSetDisplayXYFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/injecteventsetdisplayxy_fuzzer/corpus/init b/test/fuzztest/injecteventsetdisplayxy_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/injecteventsetdisplayxy_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.cpp b/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.cpp new file mode 100644 index 0000000000..4512e7abc1 --- /dev/null +++ b/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "injecteventsetdisplayxy_fuzzer.h" +#include "input_manager.h" +#include "define_multimodal.h" +#include "mmi_service.h" +#include "mmi_log.h" + +namespace OHOS { +namespace MMI { + +bool InjecteventSetDisplayXYFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t pointerIdX = provider.ConsumeIntegral(); + int32_t pointerIdY = provider.ConsumeIntegral(); + + PointerEvent::PointerItem downitem; + downitem.SetDisplayX(pointerIdX); + downitem.SetDisplayY(pointerIdY); + + return true; +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < 0) { + return 0; + } + /* Run your code on data */ + + OHOS::MMI::InjecteventSetDisplayXYFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.h b/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.h new file mode 100644 index 0000000000..532bf1094a --- /dev/null +++ b/test/fuzztest/injecteventsetdisplayxy_fuzzer/injecteventsetdisplayxy_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 INJECTEVENT_FUZZER_H +#define INJECTEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "injecteventsetdisplayxy_fuzzer" + +#endif // INJECTEVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdisplayxy_fuzzer/project.xml b/test/fuzztest/injecteventsetdisplayxy_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/injecteventsetdisplayxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/injecteventsetdowntime_fuzzer/BUILD.gn b/test/fuzztest/injecteventsetdowntime_fuzzer/BUILD.gn new file mode 100644 index 0000000000..3bc621d77c --- /dev/null +++ b/test/fuzztest/injecteventsetdowntime_fuzzer/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright (c) 2024 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("InjecteventSetDownTimeFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/injecteventsetdowntime_fuzzer" + include_dirs = [ + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/device_config/include", + "${mmi_path}/service/device_manager/include", + "${mmi_path}/service/device_scalability/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dump/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/gesturesense_wrapper/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/dfx/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/permission_helper/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/filter/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/nap_process/include", + "${mmi_path}/service/event_resample/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/util/common/include", + "${mmi_path}/util/socket/include", + "${mmi_path}/util/network/include", + "${mmi_path}/frameworks/proxy/event_handler/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "injecteventsetdowntime_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "cJSON:cjson", + "c_utils:utilsbase", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hilog:libhilog_base", + "hisysevent:libhisysevent", + "image_framework:image_native", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "napi:ace_napi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (resource_schedule_service_enabled) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InjecteventSetDownTimeFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/injecteventsetdowntime_fuzzer/corpus/init b/test/fuzztest/injecteventsetdowntime_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/injecteventsetdowntime_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.cpp b/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.cpp new file mode 100644 index 0000000000..78e5d29ab1 --- /dev/null +++ b/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "injecteventsetdowntime_fuzzer.h" +#include "input_manager.h" +#include "define_multimodal.h" +#include "mmi_service.h" +#include "mmi_log.h" + +namespace OHOS { +namespace MMI { + +bool InjecteventSetDownTimeFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int64_t downTime = provider.ConsumeIntegral(); + + KeyEvent::KeyItem kitDown; + kitDown.SetDownTime(downTime); + + return true; +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < 0) { + return 0; + } + /* Run your code on data */ + + OHOS::MMI::InjecteventSetDownTimeFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.h b/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.h new file mode 100644 index 0000000000..f482938490 --- /dev/null +++ b/test/fuzztest/injecteventsetdowntime_fuzzer/injecteventsetdowntime_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 INJECTEVENT_FUZZER_H +#define INJECTEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "injecteventsetdowntime_fuzzer" + +#endif // INJECTEVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/injecteventsetdowntime_fuzzer/project.xml b/test/fuzztest/injecteventsetdowntime_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/injecteventsetdowntime_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/injecteventsetkeyaction_fuzzer/BUILD.gn b/test/fuzztest/injecteventsetkeyaction_fuzzer/BUILD.gn new file mode 100644 index 0000000000..c0b18671fe --- /dev/null +++ b/test/fuzztest/injecteventsetkeyaction_fuzzer/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright (c) 2024 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("InjecteventSetKeyActionFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/injecteventsetkeyaction_fuzzer" + include_dirs = [ + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/device_config/include", + "${mmi_path}/service/device_manager/include", + "${mmi_path}/service/device_scalability/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dump/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/gesturesense_wrapper/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/dfx/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/permission_helper/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/filter/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/nap_process/include", + "${mmi_path}/service/event_resample/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/util/common/include", + "${mmi_path}/util/socket/include", + "${mmi_path}/util/network/include", + "${mmi_path}/frameworks/proxy/event_handler/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "injecteventsetkeyaction_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "cJSON:cjson", + "c_utils:utilsbase", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hilog:libhilog_base", + "hisysevent:libhisysevent", + "image_framework:image_native", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "napi:ace_napi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (resource_schedule_service_enabled) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InjecteventSetKeyActionFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/injecteventsetkeyaction_fuzzer/corpus/init b/test/fuzztest/injecteventsetkeyaction_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/injecteventsetkeyaction_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.cpp b/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.cpp new file mode 100644 index 0000000000..22a47a4518 --- /dev/null +++ b/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "injecteventsetkeyaction_fuzzer.h" +#include "input_manager.h" +#include "define_multimodal.h" +#include "mmi_service.h" +#include "mmi_log.h" + +namespace OHOS { +namespace MMI { + +bool InjecteventSetKeyActionFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t keyAction = provider.ConsumeIntegral(); + + auto injectUpEvent = KeyEvent::Create(); + CHKPF(injectUpEvent); + injectUpEvent->SetKeyAction(keyAction); + + return true; +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < 0) { + return 0; + } + /* Run your code on data */ + + OHOS::MMI::InjecteventSetKeyActionFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.h b/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.h new file mode 100644 index 0000000000..2f3b73adbe --- /dev/null +++ b/test/fuzztest/injecteventsetkeyaction_fuzzer/injecteventsetkeyaction_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 INJECTEVENT_FUZZER_H +#define INJECTEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "injecteventsetkeyaction_fuzzer" + +#endif // INJECTEVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeyaction_fuzzer/project.xml b/test/fuzztest/injecteventsetkeyaction_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/injecteventsetkeyaction_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/injecteventsetkeycode_fuzzer/BUILD.gn b/test/fuzztest/injecteventsetkeycode_fuzzer/BUILD.gn new file mode 100644 index 0000000000..7ed6c15069 --- /dev/null +++ b/test/fuzztest/injecteventsetkeycode_fuzzer/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright (c) 2024 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("InjecteventSetKeyCodeFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/injecteventsetkeycode_fuzzer" + include_dirs = [ + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/device_config/include", + "${mmi_path}/service/device_manager/include", + "${mmi_path}/service/device_scalability/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dump/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/gesturesense_wrapper/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/dfx/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/permission_helper/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/filter/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/nap_process/include", + "${mmi_path}/service/event_resample/include", + "${mmi_path}/interfaces/native/innerkits/proxy/include", + "${mmi_path}/interfaces/native/innerkits/event/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/interfaces/native/innerkits/common/include", + "${mmi_path}/util/common/include", + "${mmi_path}/util/socket/include", + "${mmi_path}/util/network/include", + "${mmi_path}/frameworks/proxy/event_handler/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "injecteventsetkeycode_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:abilitykit_native", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "cJSON:cjson", + "c_utils:utilsbase", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_consumer", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hilog:libhilog_base", + "hisysevent:libhisysevent", + "image_framework:image_native", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "napi:ace_napi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + "window_manager:libwsutils", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (resource_schedule_service_enabled) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InjecteventSetKeyCodeFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/injecteventsetkeycode_fuzzer/corpus/init b/test/fuzztest/injecteventsetkeycode_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/injecteventsetkeycode_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.cpp b/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.cpp new file mode 100644 index 0000000000..f8de4d2d1a --- /dev/null +++ b/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "injecteventsetkeycode_fuzzer.h" +#include "input_manager.h" +#include "define_multimodal.h" +#include "mmi_service.h" +#include "mmi_log.h" + +namespace OHOS { +namespace MMI { + +bool InjecteventSetKeyCodeFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t keyCode = provider.ConsumeIntegral(); + + KeyEvent::KeyItem keyItem; + keyItem.SetKeyCode(keyCode); + + return true; +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < 0) { + return 0; + } + /* Run your code on data */ + + OHOS::MMI::InjecteventSetKeyCodeFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.h b/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.h new file mode 100644 index 0000000000..d1cb6f5ad5 --- /dev/null +++ b/test/fuzztest/injecteventsetkeycode_fuzzer/injecteventsetkeycode_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 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 INJECTEVENT_FUZZER_H +#define INJECTEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "injecteventsetkeycode_fuzzer" + +#endif // INJECTEVENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/injecteventsetkeycode_fuzzer/project.xml b/test/fuzztest/injecteventsetkeycode_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/injecteventsetkeycode_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + -- Gitee