From 2d540d28ca17b230ac3bb9b8a5dc0a5bce2d9c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Tue, 16 Jul 2024 17:08:06 +0800 Subject: [PATCH] LXL_FUZZTEXT_change_04 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- .../BUILD.gn | 119 +++++++++++++++++ .../abilityframeworkscjenvironment_fuzzer.cpp | 106 +++++++++++++++ .../abilityframeworkscjenvironment_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ .../BUILD.gn | 82 ++++++++++++ ...yinterfacesappmanageramsmgrstub_fuzzer.cpp | 118 +++++++++++++++++ ...ityinterfacesappmanageramsmgrstub_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ .../BUILD.gn | 82 ++++++++++++ ...appmgrabilitydebugresponseproxy_fuzzer.cpp | 125 ++++++++++++++++++ ...esappmgrabilitydebugresponseproxy_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ .../BUILD.gn | 82 ++++++++++++ ...acesappmgrappdebuglistenerproxy_fuzzer.cpp | 121 +++++++++++++++++ ...rfacesappmgrappdebuglistenerproxy_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ .../BUILD.gn | 102 ++++++++++++++ .../abilitymgrabilitymanagerstub_fuzzer.cpp | 122 +++++++++++++++++ .../abilitymgrabilitymanagerstub_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ .../BUILD.gn | 100 ++++++++++++++ .../abilitymgruiextensionrecord_fuzzer.cpp | 121 +++++++++++++++++ .../abilitymgruiextensionrecord_fuzzer.h | 21 +++ .../corpus/init | 16 +++ .../project.xml | 25 ++++ 30 files changed, 1652 insertions(+) create mode 100644 test/fuzztest/abilityframeworkscjenvironment_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.cpp create mode 100644 test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.h create mode 100644 test/fuzztest/abilityframeworkscjenvironment_fuzzer/corpus/init create mode 100644 test/fuzztest/abilityframeworkscjenvironment_fuzzer/project.xml create mode 100644 test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.cpp create mode 100644 test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.h create mode 100644 test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/corpus/init create mode 100644 test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/project.xml create mode 100644 test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.cpp create mode 100644 test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.h create mode 100644 test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/corpus/init create mode 100644 test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/project.xml create mode 100644 test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.cpp create mode 100644 test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.h create mode 100644 test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/corpus/init create mode 100644 test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/project.xml create mode 100644 test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.cpp create mode 100644 test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.h create mode 100644 test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/corpus/init create mode 100644 test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/project.xml create mode 100644 test/fuzztest/abilitymgruiextensionrecord_fuzzer/BUILD.gn create mode 100644 test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.cpp create mode 100644 test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.h create mode 100644 test/fuzztest/abilitymgruiextensionrecord_fuzzer/corpus/init create mode 100644 test/fuzztest/abilitymgruiextensionrecord_fuzzer/project.xml diff --git a/test/fuzztest/abilityframeworkscjenvironment_fuzzer/BUILD.gn b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/BUILD.gn new file mode 100644 index 0000000000..42de5ca11d --- /dev/null +++ b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/BUILD.gn @@ -0,0 +1,119 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +import("//foundation/ability/ability_runtime/cj_environment/cj_environment.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityFrameworksCjEnvironmentFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityframeworkscjenvironment_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/dataobs_manager/include", + "${ability_runtime_path}/cj_environment/interfaces/inner_api", + "${ability_runtime_path}/cj_environment/frameworks/cj_environment/include", + "${ability_runtime_native_path}/runtime", + "${ability_runtime_native_path}/runtime/utils/include", + "${ability_base_kits_path}/extractortool/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_services_path}/abilitymgr/include", + "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "${distributedschedule_path}/samgr/adapter/interfaces/innerkits/include/", + "${multimodalinput_path}/interfaces/native/innerkits/event/include", + "//third_party/zlib/contrib/minizip", + "//third_party/zlib", + "//third_party/jsoncpp:jsoncpp", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "${ability_runtime_path}/cj_environment/frameworks/cj_environment/src/cj_environment.cpp", + "abilityframeworkscjenvironment_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + "//third_party/jsoncpp:jsoncpp", + "//third_party/libjpeg-turbo:turbojpeg_static", + ] + defines = [ "WITH_EVENT_HANDLER" ] + external_deps = [ + "ability_base:extractortool", + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "ability_runtime:js_environment", + "ability_runtime:runtime", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "ets_runtime:libark_jsruntime", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "napi:ace_napi", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityFrameworksCjEnvironmentFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.cpp b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.cpp new file mode 100644 index 0000000000..c09ee88c67 --- /dev/null +++ b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.cpp @@ -0,0 +1,106 @@ +/* + * 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 "abilityframeworkscjenvironment_fuzzer.h" + +#include +#include + +#define private public +#include "cj_environment.h" +#undef private + +#include "ability_record.h" +#include "securec.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} + +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + std::string jsonStr(data, size); + IsCJAbility(jsonStr); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + /* Validate the length of size */ + if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.h b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_fuzzer.h new file mode 100644 index 0000000000..97127ada29 --- /dev/null +++ b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/abilityframeworkscjenvironment_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYFRAMEWORKSCJENVIRONMENT_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYFRAMEWORKSCJENVIRONMENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityframeworkscjenvironment_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYFRAMEWORKSCJENVIRONMENT_FUZZER_H diff --git a/test/fuzztest/abilityframeworkscjenvironment_fuzzer/corpus/init b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilityframeworkscjenvironment_fuzzer/project.xml b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityframeworkscjenvironment_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..1500deea9f --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppManagerAmsMgrStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmanageramsmgrstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppManagerAmsMgrStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.cpp new file mode 100644 index 0000000000..689cb472c5 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.cpp @@ -0,0 +1,118 @@ +/* + * 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 "abilityinterfacesappmanageramsmgrstub_fuzzer.h" + +#include +#include + +#define private public +#include "ams_mgr_stub.h" +#include "ams_mgr_scheduler.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string AMSMGR_INTERFACE_TOKEN = u"ohos.appexecfwk.IAmsMgr"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t code = static_cast(IAmsMgr::Message::UPDATE_EXTENSION_STATE); + MessageParcel parcel; + parcel.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr MgrServiceInner; + std::shared_ptr Handler; + std::shared_ptr abms = std::make_shared(MgrServiceInner, Handler); + abms->OnRemoteRequest(code, parcel, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.h b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_fuzzer.h new file mode 100644 index 0000000000..ece7601ebb --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/abilityinterfacesappmanageramsmgrstub_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMANGERAMSMGRSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMANGERAMSMGRSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmanageramsmgrstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMANGERAMSMGRSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilityinterfacesappmanageramsmgrstub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmanageramsmgrstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/BUILD.gn new file mode 100644 index 0000000000..006c7c5a79 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrAbilityDebugResponseProxyFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrAbilityDebugResponseProxyFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.cpp new file mode 100644 index 0000000000..2b68bca8be --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.cpp @@ -0,0 +1,125 @@ +/* + * 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 "abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.h" + +#include +#include + +#define private public +#include "ability_debug_response_proxy.h" +#include "ability_debug_response_interface.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string AMSMGR_INTERFACE_TOKEN = u"ohos.appexecfwk.IAmsMgr"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + sptr impl; + std::shared_ptr infosProxy = std::make_shared(impl); + std::vector> tokens; + infosProxy->OnAbilitysDebugStarted(tokens); + infosProxy->OnAbilitysDebugStoped(tokens); + bool isAssertDebug = *data % ENABLE; + infosProxy->OnAbilitysAssertDebugChange(tokens, isAssertDebug); + MessageParcel parcels; + parcels.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); + parcels.WriteBuffer(data, size); + parcels.RewindRead(0); + infosProxy->WriteInterfaceToken(parcels); + IAbilityDebugResponse::Message message = IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STARTED; + infosProxy->SendRequest(message, tokens); + message = IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STOPED; + infosProxy->SendRequest(message, tokens); + message = IAbilityDebugResponse::Message::ON_ABILITYS_ASSERT_DEBUG; + infosProxy->SendRequest(message, tokens); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer.h new file mode 100644 index 0000000000..660be13b33 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/abilityinterfacesappmgrabilitydebugresponseproxy_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrappdebuglistenerproxy_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/BUILD.gn new file mode 100644 index 0000000000..4f3df9a1d7 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrAppDebugListenerProxyFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrAppDebugListenerProxyFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.cpp new file mode 100644 index 0000000000..cd85ad9ba1 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.cpp @@ -0,0 +1,121 @@ +/* + * 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 "abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.h" + +#include +#include + +#define private public +#include "app_debug_listener_proxy.h" +#include "app_debug_listener_interface.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string AMSMGR_INTERFACE_TOKEN = u"ohos.appexecfwk.IAmsMgr"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + sptr impl; + std::shared_ptr infosProxy = std::make_shared(impl); + std::vector debugInfos; + infosProxy->OnAppDebugStarted(debugInfos); + infosProxy->OnAppDebugStoped(debugInfos); + MessageParcel parcels; + parcels.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); + parcels.WriteBuffer(data, size); + parcels.RewindRead(0); + infosProxy->WriteInterfaceToken(parcels); + IAppDebugListener::Message message = IAppDebugListener::Message::ON_APP_DEBUG_STARTED; + infosProxy->SendRequest(message, debugInfos); + message = IAppDebugListener::Message::ON_APP_DEBUG_STOPED; + infosProxy->SendRequest(message, debugInfos); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer.h new file mode 100644 index 0000000000..660be13b33 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/abilityinterfacesappmgrappdebuglistenerproxy_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrappdebuglistenerproxy_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTTENERPROXY_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/BUILD.gn b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..eec6ffc222 --- /dev/null +++ b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityMgrAbilityManagerStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitymgrabilitymanagerstub_fuzzer" + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_services_path}/common/include", + "${ability_runtime_path}/interfaces/kits/native/session_info/include", + "${distributedschedule_path}/samgr/adapter/interfaces/innerkits/include", + "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "${distributedschedule_path}/samgr/utils/native/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilitymgrabilitymanagerstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "//third_party/jsoncpp:jsoncpp", + "//third_party/libjpeg-turbo:turbojpeg_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "ability_runtime:ability_manager", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "ipc:ipc_core", + "napi:ace_napi", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityMgrAbilityManagerStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.cpp b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.cpp new file mode 100644 index 0000000000..bb4e9821f3 --- /dev/null +++ b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.cpp @@ -0,0 +1,122 @@ +/* + * 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 "abilitymgrabilitymanagerstub_fuzzer.h" + +#include +#include + +#define private public +#include "ability_manager_service.h" +#undef private + +#include "securec.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t codeOne = static_cast(AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE); + MessageParcel parcel; + parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abmsOne = std::make_shared(); + abmsOne->OnRemoteRequest(codeOne, parcel, reply, option); + + uint32_t codeTwo = static_cast(AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY); + MessageParcel parcels; + parcels.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN); + parcels.WriteBuffer(data, size); + parcels.RewindRead(0); + std::shared_ptr abmsTwo = std::make_shared(); + abmsTwo->OnRemoteRequest(codeTwo, parcels, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.h b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_fuzzer.h new file mode 100644 index 0000000000..b28b73cbe6 --- /dev/null +++ b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/abilitymgrabilitymanagerstub_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRABILITYMANAGERSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRABILITYMANAGERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilitymgrabilitymanagerstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRABILITYMANAGERSTUB_FUZZER_H diff --git a/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/corpus/init b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilitymgrabilitymanagerstub_fuzzer/project.xml b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilitymgrabilitymanagerstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilitymgruiextensionrecord_fuzzer/BUILD.gn b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/BUILD.gn new file mode 100644 index 0000000000..8e1df1e27d --- /dev/null +++ b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/BUILD.gn @@ -0,0 +1,100 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityMgrUiExtensionRecordFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/abilitymgruiextensionrecord_fuzzer" + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "${distributedschedule_path}/samgr/adapter/interfaces/innerkits/include/", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_services_path}/abilitymgr/src/extension_record.cpp", + "${ability_runtime_services_path}/abilitymgr/src/preload_uiext_state_observer.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ui_extension_record.cpp", + "abilitymgruiextensionrecord_fuzzer.cpp", + ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + "//third_party/jsoncpp:jsoncpp", + "//third_party/libjpeg-turbo:turbojpeg_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "napi:ace_napi", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityMgrUiExtensionRecordFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.cpp b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.cpp new file mode 100644 index 0000000000..f992af99e5 --- /dev/null +++ b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.cpp @@ -0,0 +1,121 @@ +/* + * 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 "abilitymgruiextensionrecord_fuzzer.h" + +#include +#include + +#define private public +#include "ui_extension_record.h" +#undef private + +#include "securec.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + std::shared_ptr abilityRecord; + AbilityRuntime::UIExtensionRecord infos(abilityRecord); + infos.ContinueToGetCallerToken(); + AAFwk::AbilityRequest abilityRequest; + infos.Update(abilityRequest); + infos.LoadTimeout(); + infos.ForegroundTimeout(); + infos.BackgroundTimeout(); + infos.TerminateTimeout(); + AbilityRuntime::UIExtensionRecord::ErrorCode code = AbilityRuntime::UIExtensionRecord::ErrorCode::LOAD_TIMEOUT; + infos.HandleNotifyUIExtensionTimeout(code); + code = AbilityRuntime::UIExtensionRecord::ErrorCode::FOREGROUND_TIMEOUT; + infos.HandleNotifyUIExtensionTimeout(code); + code = AbilityRuntime::UIExtensionRecord::ErrorCode::BACKGROUND_TIMEOUT; + infos.HandleNotifyUIExtensionTimeout(code); + code = AbilityRuntime::UIExtensionRecord::ErrorCode::TERMINATE_TIMEOUT; + infos.HandleNotifyUIExtensionTimeout(code); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.h b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_fuzzer.h new file mode 100644 index 0000000000..7d613149d2 --- /dev/null +++ b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/abilitymgruiextensionrecord_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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRUIEXTENSIONRECORD_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRUIEXTENSIONRECORD_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilitymgruiextensionrecord_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRUIEXTENSIONRECORD_FUZZER_H diff --git a/test/fuzztest/abilitymgruiextensionrecord_fuzzer/corpus/init b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/abilitymgruiextensionrecord_fuzzer/project.xml b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilitymgruiextensionrecord_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + +