diff --git a/test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn b/test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5916804690d03d6b61712271eebb4c65b2089e54 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleDownDurationFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandledownduration_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandledownduration_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleDownDurationFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandledownduration_fuzzer/corpus/init b/test/fuzztest/stubhandledownduration_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandledownduration_fuzzer/project.xml b/test/fuzztest/stubhandledownduration_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50741b7066fbf41dca29e914d34c2f047f2be29c --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 "stubhandledownduration_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleDownDurationFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + std::string businessId = provider.ConsumeBytesAsString(10); // test value + int32_t delay = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetKeyDownDuration(businessId, delay); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleDownDurationFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..44c8c0e45965ffc103336032c813fb731a943070 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandledownduration_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandledump_fuzzer/BUILD.gn b/test/fuzztest/stubhandledump_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1519f1d4b4bf41916e3dcd249e392a6586a39aec --- /dev/null +++ b/test/fuzztest/stubhandledump_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleDumpFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandledump_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandledump_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleDumpFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandledump_fuzzer/corpus/init b/test/fuzztest/stubhandledump_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandledump_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandledump_fuzzer/project.xml b/test/fuzztest/stubhandledump_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandledump_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.cpp b/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b0e4e5e0003741fdf7ab4f66d8f678748289479b --- /dev/null +++ b/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 "stubhandledump_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleDumpFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + std::vector args = { + u"datatest1", + u"datatest2", + u"datatest3", + u"datatest4" + }; + int32_t fd = provider.ConsumeIntegral(); + + MMIService::GetInstance()->Dump(fd, args); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleDumpFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.h b/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5823515daf0e8eeb5e9666eefef1cb2916a2ae5e --- /dev/null +++ b/test/fuzztest/stubhandledump_fuzzer/stubhandledump_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandledump_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlegetkbtype_fuzzer/BUILD.gn b/test/fuzztest/stubhandlegetkbtype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..68fe0c90bcb733e113114a8edb8410ac90a262b1 --- /dev/null +++ b/test/fuzztest/stubhandlegetkbtype_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleGetKbTypeFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlegetkbtype_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlegetkbtype_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleGetKbTypeFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlegetkbtype_fuzzer/corpus/init b/test/fuzztest/stubhandlegetkbtype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlegetkbtype_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlegetkbtype_fuzzer/project.xml b/test/fuzztest/stubhandlegetkbtype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlegetkbtype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.cpp b/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8005b1aea97bba41401c1056c90a3458c3c5603 --- /dev/null +++ b/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 "stubhandlegetkbtype_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleGetKbTypeFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t deviceId = provider.ConsumeIntegral(); + int32_t keyboardType = provider.ConsumeIntegral(); + + MMIService::GetInstance()->OnGetKeyboardType(deviceId, keyboardType); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleGetKbTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.h b/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..787062fc614a2d0c90315a914ca26f10c621a2f1 --- /dev/null +++ b/test/fuzztest/stubhandlegetkbtype_fuzzer/stubhandlegetkbtype_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlegetkbtype_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlegetkeystate_fuzzer/BUILD.gn b/test/fuzztest/stubhandlegetkeystate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3e60e69a4b731cab2f50f111cc45efb24c35d2d5 --- /dev/null +++ b/test/fuzztest/stubhandlegetkeystate_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleGetKeyStateFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlegetkeystate_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlegetkeystate_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleGetKeyStateFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlegetkeystate_fuzzer/corpus/init b/test/fuzztest/stubhandlegetkeystate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlegetkeystate_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlegetkeystate_fuzzer/project.xml b/test/fuzztest/stubhandlegetkeystate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlegetkeystate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.cpp b/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4a5ed6bfe70c817f1d7842574425e4f65c696a2 --- /dev/null +++ b/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 "stubhandlegetkeystate_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleGetKeyStateFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + std::vector pressedKey = { + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral() + }; + + std::unordered_map specialkeysState = { + {provider.ConsumeIntegral(), provider.ConsumeIntegral()}, + {provider.ConsumeIntegral(), provider.ConsumeIntegral()}, + {provider.ConsumeIntegral(), provider.ConsumeIntegral()}, + {provider.ConsumeIntegral(), provider.ConsumeIntegral()}, + }; + + MMIService::GetInstance()->GetKeyState(pressedKey, specialkeysState); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleGetKeyStateFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.h b/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..18015eb8b49731dbce4a3acb02952ab57bc6bae3 --- /dev/null +++ b/test/fuzztest/stubhandlegetkeystate_fuzzer/stubhandlegetkeystate_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlegetkeystate_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlekeyevent_fuzzer/BUILD.gn b/test/fuzztest/stubhandlekeyevent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..06d971dbc3d706317d6aeb5651c43c6004b9a357 --- /dev/null +++ b/test/fuzztest/stubhandlekeyevent_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleKeyEventFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlekeyevent_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlekeyevent_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleKeyEventFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlekeyevent_fuzzer/corpus/init b/test/fuzztest/stubhandlekeyevent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlekeyevent_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlekeyevent_fuzzer/project.xml b/test/fuzztest/stubhandlekeyevent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlekeyevent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.cpp b/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b816b2e6e138d9505070bf6b7306f860bdd6a29 --- /dev/null +++ b/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 "stubhandlekeyevent_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleKeyEventFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + KeyOption keyOption; + keyOption.finalKey_ = provider.ConsumeIntegral(); + keyOption.isFinalKeyDown_ = provider.ConsumeIntegral(); + keyOption.finalKeyDownDuration_ = provider.ConsumeBool(); + keyOption.finalKeyUpDelay_ = provider.ConsumeIntegral(); + keyOption.isRepeat_ = provider.ConsumeBool(); + keyOption.priority_ = SubscribePriority::PRIORITY_0; + + int32_t subscribeId = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SubscribeKeyEvent(subscribeId, keyOption); + MMIService::GetInstance()->UnsubscribeKeyEvent(subscribeId); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleKeyEventFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.h b/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..35009f6d03cdb18a82944f9deb0a1b290a43c780 --- /dev/null +++ b/test/fuzztest/stubhandlekeyevent_fuzzer/stubhandlekeyevent_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlekeyevent_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlekeystate_fuzzer/BUILD.gn b/test/fuzztest/stubhandlekeystate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..06bfc1071df0be9a60bb2eb06c75db4e7f5a3be2 --- /dev/null +++ b/test/fuzztest/stubhandlekeystate_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleKeyStateFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlekeystate_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlekeystate_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleKeyStateFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlekeystate_fuzzer/corpus/init b/test/fuzztest/stubhandlekeystate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlekeystate_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlekeystate_fuzzer/project.xml b/test/fuzztest/stubhandlekeystate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlekeystate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.cpp b/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1bd2af431660e3570e15c3b5e5e48a6a3b4b4917 --- /dev/null +++ b/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 "stubhandlekeystate_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleKeyStateFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t funcKey = provider.ConsumeIntegral(); + bool enable = provider.ConsumeBool(); + + MMIService::GetInstance()->SetFunctionKeyState(funcKey, enable); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleKeyStateFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.h b/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..842644790f9e945758968a513517d35ca75ac948 --- /dev/null +++ b/test/fuzztest/stubhandlekeystate_fuzzer/stubhandlekeystate_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlekeystate_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlemapdata_fuzzer/BUILD.gn b/test/fuzztest/stubhandlemapdata_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b2f7fa1c5e412595925f987a10029fa6aeafc083 --- /dev/null +++ b/test/fuzztest/stubhandlemapdata_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleMapDataFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlemapdata_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlemapdata_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleMapDataFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlemapdata_fuzzer/corpus/init b/test/fuzztest/stubhandlemapdata_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlemapdata_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlemapdata_fuzzer/project.xml b/test/fuzztest/stubhandlemapdata_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlemapdata_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.cpp b/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3d6bb83160b8052ab41875985b42a5b85a6c202 --- /dev/null +++ b/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 "stubhandlemapdata_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleMapDataFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t infoId = provider.ConsumeIntegral(); + CursorPixelMap cursorPixelMap; + + MMIService::GetInstance()->SetPixelMapData(infoId, cursorPixelMap); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleMapDataFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.h b/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..edef23b53168a49522e6ff976d9d6ae15affbc06 --- /dev/null +++ b/test/fuzztest/stubhandlemapdata_fuzzer/stubhandlemapdata_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlemapdata_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlemarkevent_fuzzer/BUILD.gn b/test/fuzztest/stubhandlemarkevent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3dfd7d603ae012a94c511c377852849d7753b769 --- /dev/null +++ b/test/fuzztest/stubhandlemarkevent_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("StubHandleMarkEventFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlemarkevent_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + 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 = [ "stubhandlemarkevent_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleMarkEventFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlemarkevent_fuzzer/corpus/init b/test/fuzztest/stubhandlemarkevent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlemarkevent_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/stubhandlemarkevent_fuzzer/project.xml b/test/fuzztest/stubhandlemarkevent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlemarkevent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.cpp b/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..121464fad486a10c07b9c3732b17662c7015d273 --- /dev/null +++ b/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 "stubhandlemarkevent_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleMarkEventFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t eventId = provider.ConsumeIntegral(); + + MMIService::GetInstance()->MarkEventConsumed(eventId); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleMarkEventFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.h b/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f612a6b2d12ab388ba3c62fb5c674b6671d9818f --- /dev/null +++ b/test/fuzztest/stubhandlemarkevent_fuzzer/stubhandlemarkevent_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlemarkevent_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H