diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 1b811fbf12f261a83a57267cf2c4cdacfedd389f..684b9925ee0c3e9c7a22d7d22f85e00d9b7cc1ae 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -328,7 +328,13 @@ group("fuzztest") { "insightintentexecutecallbackstub_fuzzer:fuzztest", "isramconstraineddevice_fuzzer:fuzztest", "jsabilityautostartupmanager_fuzzer:fuzztest", - "jsabilityautostartupmanager_fuzzer:fuzztest", + "keepaliveprocessmanagerfifth_fuzzer:fuzztest", + "keepaliveprocessmanagerfirst_fuzzer:fuzztest", + "keepaliveprocessmanagerfourth_fuzzer:fuzztest", + "keepaliveprocessmanagersecond_fuzzer:fuzztest", + "keepaliveprocessmanagerseventh_fuzzer:fuzztest", + "keepaliveprocessmanagersixth_fuzzer:fuzztest", + "keepaliveprocessmanagerthird_fuzzer:fuzztest", "killapplication_fuzzer:fuzztest", "killapplicationself_fuzzer:fuzztest", "killprocessbyabilitytoken_fuzzer:fuzztest", diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 9eb65cf7d8104510c514934e8a394b528d355f54..e39e4612458e9e0e24061abbe3d96e8af5eedeb5 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -24,10 +24,13 @@ #include "auto_startup_info.h" #include "bundle_info.h" #include "bundle_user_info.h" +#include "keep_alive_process_manager.h" namespace OHOS { namespace AppExecFwk { namespace AbilityFuzzUtil { +constexpr size_t CODE_TWO = 2; +constexpr size_t CODE_MAX = 99; constexpr size_t STRING_MAX_LENGTH = 128; std::vector GenerateStringArray(FuzzedDataProvider& fdp, size_t arraySizeMax = STRING_MAX_LENGTH, size_t stringSize = STRING_MAX_LENGTH) @@ -106,6 +109,36 @@ void GetRandomBundleInfo(FuzzedDataProvider& fdp, BundleInfo& info) info.reqPermissions = GenerateStringArray(fdp); info.defPermissions = GenerateStringArray(fdp); } + +void GetRandomKeepAliveInfo(FuzzedDataProvider& fdp, KeepAliveInfo& info) +{ + info.userId = fdp.ConsumeIntegral(); + info.setterId = fdp.ConsumeIntegral(); + info.appType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.setter = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.policy = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + +void GetRandomKeepAliveAbilityInfo(FuzzedDataProvider& fdp, KeepAliveAbilityInfo& info) +{ + info.userId = fdp.ConsumeIntegral(); + info.appCloneIndex = fdp.ConsumeIntegral(); + info.uid = fdp.ConsumeIntegral(); + info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + +void GetRandomKeepAliveAppInfo(FuzzedDataProvider& fdp, AppInfo& info) +{ + info.processName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.state = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.pid = fdp.ConsumeIntegral(); + info.appIndex = fdp.ConsumeIntegral(); + info.instanceKey = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} } // namespace AbilityFuzzUtil } // namespace AppExecFwk } // namespace OHOS diff --git a/test/fuzztest/abilityautostartupclientfirst_fuzzer/BUILD.gn b/test/fuzztest/abilityautostartupclientfirst_fuzzer/BUILD.gn index 81af2fa30eadc98f9cb8175ebb6f2be7b064a870..08fc227753b2cea44ed5fc81c85b3a7bba090e2c 100644 --- a/test/fuzztest/abilityautostartupclientfirst_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityautostartupclientfirst_fuzzer/BUILD.gn @@ -66,6 +66,7 @@ ohos_fuzztest("AbilityAutoStartupClientFirstFuzzTest") { "config_policy:configpolicy_util", "ffrt:libffrt", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", "kv_store:distributeddata_inner", diff --git a/test/fuzztest/abilityautostartupclientsecond_fuzzer/BUILD.gn b/test/fuzztest/abilityautostartupclientsecond_fuzzer/BUILD.gn index 0ee5fb2ad6d756e42f901430a5c0e04a49eddba5..826ac2d6059346f71b9642c171c42b90bc406bfa 100644 --- a/test/fuzztest/abilityautostartupclientsecond_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityautostartupclientsecond_fuzzer/BUILD.gn @@ -66,6 +66,7 @@ ohos_fuzztest("AbilityAutoStartupClientSecondFuzzTest") { "config_policy:configpolicy_util", "ffrt:libffrt", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", "kv_store:distributeddata_inner", diff --git a/test/fuzztest/abilityautostartupclientthird_fuzzer/BUILD.gn b/test/fuzztest/abilityautostartupclientthird_fuzzer/BUILD.gn index 13330018b32c85757c323ab6e138d6695d74adc2..7e9975d3c0ede7e27a8474799b2816bf04ca8fa6 100644 --- a/test/fuzztest/abilityautostartupclientthird_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityautostartupclientthird_fuzzer/BUILD.gn @@ -66,6 +66,7 @@ ohos_fuzztest("AbilityAutoStartupClientThirdFuzzTest") { "config_policy:configpolicy_util", "ffrt:libffrt", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", "kv_store:distributeddata_inner", diff --git a/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a62160fddfdfdaae945779ea5b78753d9d3f34e9 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerFifthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagerfifth_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagerfifth_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerFifthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aacff3da37d5ece164544a17df9efd2fc6b02810 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * 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 "keepaliveprocessmanagerfifth_fuzzer.h" + +#include +#include +#include + +#include "keep_alive_process_manager.h" +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + int32_t uid; + bool shouldCancel; + FuzzedDataProvider fdp(data, size); + uid = fdp.ConsumeIntegral(); + shouldCancel = fdp.ConsumeBool(); + KeepAliveProcessManager::GetInstance().RemoveCheckStatusBarTask(uid, shouldCancel); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_fuzzer.h b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5b6cdb52ae2e175e224760d4ac4d83738e70153b --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/keepaliveprocessmanagerfifth_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIFTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIFTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagerfifth_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIFTH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfifth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..23965c898f5cdd9c7b13a4a858833b0773abc9e2 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerFirstFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagerfirst_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagerfirst_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerFirstFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bbca4592b0ad234fc6843d712c76e18c4651a29 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_fuzzer.cpp @@ -0,0 +1,60 @@ +/* + * 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 "keepaliveprocessmanagerfirst_fuzzer.h" + +#include +#include +#include + +#include "keep_alive_process_manager.h" +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + std::vector bundleInfos; + BundleInfo info; + int32_t userId; + FuzzedDataProvider fdp(data, size); + size_t arraySize = fdp.ConsumeIntegralInRange(0, STRING_MAX_LENGTH); + for (size_t i = 0; i < arraySize; ++i) { + AbilityFuzzUtil::GetRandomBundleInfo(fdp, info); + bundleInfos.emplace_back(info); + } + userId = fdp.ConsumeIntegral(); + KeepAliveProcessManager::GetInstance().StartKeepAliveProcessWithMainElement(bundleInfos, userId); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_fuzzer.h b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..feecae3c28f3862865d86024895f9d5782f7c457 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/keepaliveprocessmanagerfirst_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIRST_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIRST_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagerfirst_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FIRST_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfirst_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..34ad1df44d28d4147b54c486a43bf7c4f5b050a9 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerFourthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagerfourth_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagerfourth_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerFourthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c15885ce3d25a90bb7ef3fa97b233ca541b2f282 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_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 "keepaliveprocessmanagerfourth_fuzzer.h" + +#include +#include +#include + +#define private public +#include "keep_alive_process_manager.h" +#undef private + +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + std::string bundleName; + uint32_t accessTokenId; + int32_t uid; + int32_t userId; + bool isMultiInstance; + FuzzedDataProvider fdp(data, size); + bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + accessTokenId = fdp.ConsumeIntegral(); + uid = fdp.ConsumeIntegral(); + userId = fdp.ConsumeIntegral(); + isMultiInstance = fdp.ConsumeBool(); + KeepAliveProcessManager::GetInstance().AfterStartKeepAliveApp(bundleName, accessTokenId, uid, + userId, isMultiInstance); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_fuzzer.h b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..751b44d78e9e2819bf9a0bee427105cc8b522ac9 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/keepaliveprocessmanagerfourth_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FOURTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FOURTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagerfourth_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_FOURTH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerfourth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..84cbcd313435e95e275c5135df4b807cba9d9440 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerSecondFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagersecond_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagersecond_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerSecondFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2fab818d094ae3e1cea1e8adc316b10d99f7fae8 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "keepaliveprocessmanagersecond_fuzzer.h" + +#include +#include +#include + +#define private public +#include "keep_alive_process_manager.h" +#undef private + +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + BundleInfo info; + int32_t userId; + FuzzedDataProvider fdp(data, size); + AbilityFuzzUtil::GetRandomBundleInfo(fdp, info); + userId = fdp.ConsumeIntegral(); + KeepAliveProcessManager::GetInstance().StartKeepAliveProcessWithMainElementPerBundle(info, userId); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_fuzzer.h b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..32a2840db29148abbbb609b3096bc92de705fcf4 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/keepaliveprocessmanagersecond_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SECOND_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SECOND_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagersecond_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SECOND_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersecond_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bc7eebc84cc7f681593dee613775ce426420bd71 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerSeventhFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagerseventh_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagerseventh_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerSeventhFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..88a0ea9115418e47956a5330697895dfa9f3f9d9 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_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 "keepaliveprocessmanagerseventh_fuzzer.h" + +#include +#include +#include + +#define private public +#include "keep_alive_process_manager.h" +#undef private + +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + BundleInfo info; + FuzzedDataProvider fdp(data, size); + AbilityFuzzUtil::GetRandomBundleInfo(fdp, info); + KeepAliveProcessManager::GetInstance().IsRunningAppInStatusBar(info); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_fuzzer.h b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..15b8064449823faaed217b9175ba71a8c8f704c6 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/keepaliveprocessmanagerseventh_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SEVENTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SEVENTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagerseventh_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SEVENTH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerseventh_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..94cbe2a9fe1b51d456cea7a4c61669f1e7deeb27 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerSixthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagersixth_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagersixth_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerSixthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4926148af6adc09deb79ab047cad810fbd1ce698 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_fuzzer.cpp @@ -0,0 +1,60 @@ +/* + * 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 "keepaliveprocessmanagersixth_fuzzer.h" + +#include +#include +#include + +#include "keep_alive_process_manager.h" +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + std::string bundleName; + int32_t userId; + bool updateEnable; + bool isByEDM; + bool isInner; + FuzzedDataProvider fdp(data, size); + bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + userId = fdp.ConsumeIntegral(); + updateEnable = fdp.ConsumeBool(); + isByEDM = fdp.ConsumeBool(); + isInner = fdp.ConsumeBool(); + KeepAliveProcessManager::GetInstance().SetApplicationKeepAlive(bundleName, userId, updateEnable, isByEDM, isInner); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_fuzzer.h b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..cc11558e7c03d0fccec6ff61af72086974acb119 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/keepaliveprocessmanagersixth_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SIXTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SIXTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagersixth_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_SIXTH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagersixth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/BUILD.gn b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8d8e1adb0e2febe678339ef0c37b77aeb82885ae --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/BUILD.gn @@ -0,0 +1,129 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("KeepAliveProcessManagerThirdFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/keepaliveprocessmanagerthird_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include/keep_alive", + "${ability_runtime_services_path}/common/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_mgr_client.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_service_manager.cpp", + "${ability_runtime_native_path}/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/process_options.cpp", + "${ability_runtime_services_path}/common/src/app_utils.cpp", + "${ability_runtime_services_path}/common/src/json_utils.cpp", + "${ability_runtime_services_path}/common/src/permission_verification.cpp", + "${ability_runtime_services_path}/common/src/record_cost_time_util.cpp", + "keepaliveprocessmanagerthird_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:mission_info", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "input:libmmi-client", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "kv_store:distributeddata_inner", + "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + ] + + if (ability_runtime_child_process) { + defines = [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } + if (ability_runtime_upms) { + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":KeepAliveProcessManagerThirdFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/corpus/init b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * 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/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_fuzzer.cpp b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..001178e172b22f9fbf1ab3c5abccf34eb00a9b9f --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "keepaliveprocessmanagerthird_fuzzer.h" + +#include +#include +#include + +#include "keep_alive_process_manager.h" +#include "ability_keep_alive_service.h" +#include "ability_util.h" +#include "app_mgr_client.h" +#include "parameters.h" +#include "permission_verification.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + KeepAliveAbilityInfo info; + FuzzedDataProvider fdp(data, size); + AbilityFuzzUtil::GetRandomKeepAliveAbilityInfo(fdp, info); + KeepAliveProcessManager::GetInstance().StartKeepAliveMainAbility(info); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_fuzzer.h b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8f1ee24ac7e8b64394c0e53c056e7008d54cd561 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/keepaliveprocessmanagerthird_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 FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_THIRD_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_THIRD_FUZZER_H + +#define FUZZ_PROJECT_NAME "keepaliveprocessmanagerthird_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_KEEPALIVEPROCESSMANAGER_THIRD_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/project.xml b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..500f6f414493290025d8dea9b066e5d5021a9377 --- /dev/null +++ b/test/fuzztest/keepaliveprocessmanagerthird_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/residentprocessmanagereighth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagereighth_fuzzer/BUILD.gn index d76f57785d70b43baf13bcc4910018fce4ea1493..406e0accfc41d4b29c644d326c27f1e768647b94 100644 --- a/test/fuzztest/residentprocessmanagereighth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagereighth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerEighthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagereleven_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagereleven_fuzzer/BUILD.gn index ae0f3635332dd18bbfa0323a930e5a6a568205ec..b56e94dcc91b4ac3461fa779809a56d7ff860fa9 100644 --- a/test/fuzztest/residentprocessmanagereleven_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagereleven_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerElevenFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerfifth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerfifth_fuzzer/BUILD.gn index c5d1fce218c4b8c2c05e03aa50b1089f6e9b98ac..37211fe29c42bfab0e3c845a4ade1bc46375daa1 100644 --- a/test/fuzztest/residentprocessmanagerfifth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerfifth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerFifthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerfirst_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerfirst_fuzzer/BUILD.gn index 323687b0319376b2c29edf3d68d1c10f7f41caf8..4faad1c2cfc01357dd2f24e1330efe86785db52e 100644 --- a/test/fuzztest/residentprocessmanagerfirst_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerfirst_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerFirstFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerfourth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerfourth_fuzzer/BUILD.gn index 189fa3968a496fe936d7b1fe9ede14f46b9fa4fc..d0d0f82f031d061a29e84ac9c0dc3745e454b4ba 100644 --- a/test/fuzztest/residentprocessmanagerfourth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerfourth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerFourthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerninth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerninth_fuzzer/BUILD.gn index d371655e15716b53703bb785c13bc550b54f3744..484659de037089c85e024cd5923436a0c02725a7 100644 --- a/test/fuzztest/residentprocessmanagerninth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerninth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerNinthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagersecond_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagersecond_fuzzer/BUILD.gn index 8a4d774aee4e1369f48ced0f80cbf387f201943c..dddb98d9382d817e7713f926bba10a3e5268c3b4 100644 --- a/test/fuzztest/residentprocessmanagersecond_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagersecond_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerSecondFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerseventh_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerseventh_fuzzer/BUILD.gn index 5709547c3261e693e90dece6a99aeab0a1d7cd5b..25c1aed219c4bd119bb6e535f61cd85979bdfa92 100644 --- a/test/fuzztest/residentprocessmanagerseventh_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerseventh_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerSeventhFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagersixth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagersixth_fuzzer/BUILD.gn index 88fd9401cac01180aed22d9ff2da644d8cde5ea0..515779c1f6b2510beb8400ebd247ab1eaefa7298 100644 --- a/test/fuzztest/residentprocessmanagersixth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagersixth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerSixthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagertenth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagertenth_fuzzer/BUILD.gn index 0a2da501f14ea09d783aa712200de5155ffc53bf..c447509322e36e5e68112a77d2cd05ec93b38402 100644 --- a/test/fuzztest/residentprocessmanagertenth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagertenth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerTenthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagerthird_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagerthird_fuzzer/BUILD.gn index 4ba97249374d0e2892bde61f80bf9f8c464cd8d4..0521110d108ed3b28f1f83c93e5ea0d417ed0df0 100644 --- a/test/fuzztest/residentprocessmanagerthird_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagerthird_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerThirdFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp", diff --git a/test/fuzztest/residentprocessmanagertwelfth_fuzzer/BUILD.gn b/test/fuzztest/residentprocessmanagertwelfth_fuzzer/BUILD.gn index 980337b2c350c02d2310165a1ea8110ee0196153..92cd3928c61ab2e826c48f56c675691ca3d14694 100644 --- a/test/fuzztest/residentprocessmanagertwelfth_fuzzer/BUILD.gn +++ b/test/fuzztest/residentprocessmanagertwelfth_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("ResidentProcessManagerTwelfthFuzzTest") { "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", + "hisysevent:libhisysevent", "input:libmmi-client", "ipc:ipc_core", "jsoncpp:jsoncpp",