From 45bc12e046cd886876018cd0a87d25743f22d574 Mon Sep 17 00:00:00 2001 From: chenliming Date: Wed, 19 Feb 2025 10:07:34 +0800 Subject: [PATCH] FUZZ_0219 Signed-off-by: chenliming --- services/dataobsmgr/BUILD.gn | 2 + test/fuzztest/BUILD.gn | 1 - test/fuzztest/amsmanager_fuzzer/BUILD.gn | 1 + test/fuzztest/appmanager_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 79 ------------------- .../corpus/init | 16 ---- .../project.xml | 25 ------ ...egisterapplicationstateobserver_fuzzer.cpp | 59 -------------- .../registerapplicationstateobserver_fuzzer.h | 21 ----- .../BUILD.gn | 1 + 10 files changed, 5 insertions(+), 201 deletions(-) delete mode 100644 test/fuzztest/registerapplicationstateobserver_fuzzer/BUILD.gn delete mode 100644 test/fuzztest/registerapplicationstateobserver_fuzzer/corpus/init delete mode 100644 test/fuzztest/registerapplicationstateobserver_fuzzer/project.xml delete mode 100644 test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.cpp delete mode 100644 test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.h diff --git a/services/dataobsmgr/BUILD.gn b/services/dataobsmgr/BUILD.gn index d4db6575f3..4ae10b9dd1 100644 --- a/services/dataobsmgr/BUILD.gn +++ b/services/dataobsmgr/BUILD.gn @@ -53,6 +53,7 @@ ohos_shared_library("dataobsms") { "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", + "image_framework:image_native", "ipc:ipc_core", "json:nlohmann_json_static", "safwk:system_ability_fwk", @@ -93,6 +94,7 @@ ohos_static_library("dataobsms_static") { "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", + "image_framework:image_native", "ipc:ipc_core", "json:nlohmann_json_static", "safwk:system_ability_fwk", diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index d4516077e0..ba5e629d1a 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -305,7 +305,6 @@ group("fuzztest") { "prepareterminate_fuzzer:fuzztest", "prestartnwebspawnprocess_fuzzer:fuzztest", "registerabilitylifecyclecallback_fuzzer:fuzztest", - "registerapplicationstateobserver_fuzzer:fuzztest", "registerconfigurationobserver_fuzzer:fuzztest", "registerenvironmentcallback_fuzzer:fuzztest", "registermissionlistener_fuzzer:fuzztest", diff --git a/test/fuzztest/amsmanager_fuzzer/BUILD.gn b/test/fuzztest/amsmanager_fuzzer/BUILD.gn index 9266ef0be4..a823dea20e 100644 --- a/test/fuzztest/amsmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/amsmanager_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("AmsManagerFuzzTest") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "ffrt:libffrt", + "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/test/fuzztest/appmanager_fuzzer/BUILD.gn b/test/fuzztest/appmanager_fuzzer/BUILD.gn index 0f65f95d5e..a23cdb85fb 100644 --- a/test/fuzztest/appmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/appmanager_fuzzer/BUILD.gn @@ -53,6 +53,7 @@ ohos_fuzztest("AppManagerFuzzTest") { "bundle_framework:appexecfwk_core", "c_utils:utils", "ffrt:libffrt", + "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", "ipc:ipc_core", diff --git a/test/fuzztest/registerapplicationstateobserver_fuzzer/BUILD.gn b/test/fuzztest/registerapplicationstateobserver_fuzzer/BUILD.gn deleted file mode 100644 index 80f9d5de73..0000000000 --- a/test/fuzztest/registerapplicationstateobserver_fuzzer/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# 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/libappms" - -##############################fuzztest########################################## -ohos_fuzztest("RegisterApplicationStateObserverFuzzTest") { - module_out_path = module_output_path - - fuzz_config_file = "${ability_runtime_test_path}/fuzztest/registerapplicationstateobserver_fuzzer" - include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "registerapplicationstateobserver_fuzzer.cpp" ] - - configs = [ "${ability_runtime_services_path}/appmgr:appmgr_config" ] - - deps = [ "${ability_runtime_services_path}/appmgr:libappms" ] - - external_deps = [ - "ability_base:base", - "ability_runtime:ability_deps_wrapper", - "ability_runtime:app_manager", - "appspawn:appspawn_client", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "c_utils:utils", - "ffrt:libffrt", - "hisysevent:libhisysevent", - "init:libbeget_proxy", - "init:libbegetutil", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - 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 - ":RegisterApplicationStateObserverFuzzTest", - ] -} -############################################################################### diff --git a/test/fuzztest/registerapplicationstateobserver_fuzzer/corpus/init b/test/fuzztest/registerapplicationstateobserver_fuzzer/corpus/init deleted file mode 100644 index 6198079a28..0000000000 --- a/test/fuzztest/registerapplicationstateobserver_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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/registerapplicationstateobserver_fuzzer/project.xml b/test/fuzztest/registerapplicationstateobserver_fuzzer/project.xml deleted file mode 100644 index 6d3e765c7d..0000000000 --- a/test/fuzztest/registerapplicationstateobserver_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - \ No newline at end of file diff --git a/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.cpp b/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.cpp deleted file mode 100644 index 62c6db4c6c..0000000000 --- a/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 "registerapplicationstateobserver_fuzzer.h" - -#include -#include -#include - -#define private public -#include "app_mgr_service.h" -#undef private -#include "iapplication_state_observer.h" -#include "securec.h" - -using namespace OHOS::AAFwk; -using namespace OHOS::AppExecFwk; - -namespace OHOS { -bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) -{ - std::shared_ptr appMgrService = std::make_shared(); - if (!appMgrService) { - return false; - } - - sptr observer; - std::vector bundleNameList; - std::string bundleName(fdp->ConsumeRandomLengthString()); - bundleNameList.emplace_back(bundleName); - - if (appMgrService->RegisterApplicationStateObserver(observer, bundleNameList) != 0) { - return false; - } - - return true; -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - FuzzedDataProvider fdp(data, size); - OHOS::DoSomethingInterestingWithMyAPI(&fdp); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.h b/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.h deleted file mode 100644 index ae515ead6e..0000000000 --- a/test/fuzztest/registerapplicationstateobserver_fuzzer/registerapplicationstateobserver_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_REGISTERAPPLICATIONSTATEOBSERVER_FUZZER_H -#define FUZZTEST_OHOS_ABILITY_RUNTIME_REGISTERAPPLICATIONSTATEOBSERVER_FUZZER_H - -#define FUZZ_PROJECT_NAME "registerapplicationstateobserver_fuzzer" - -#endif \ No newline at end of file diff --git a/test/fuzztest/unregisterapplicationstateobserver_fuzzer/BUILD.gn b/test/fuzztest/unregisterapplicationstateobserver_fuzzer/BUILD.gn index 3326af778d..f84272d666 100644 --- a/test/fuzztest/unregisterapplicationstateobserver_fuzzer/BUILD.gn +++ b/test/fuzztest/unregisterapplicationstateobserver_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("UnregisterApplicationStateObserverFuzzTest") { "bundle_framework:appexecfwk_core", "c_utils:utils", "ffrt:libffrt", + "hilog:libhilog", "hisysevent:libhisysevent", "init:libbeget_proxy", "init:libbegetutil",