FUZZ_0219

Signed-off-by: chenliming <chenliming20@huawei-partners.com>
This commit is contained in:
chenliming
2025-02-19 10:07:34 +08:00
parent 4e2349859d
commit 45bc12e046
10 changed files with 5 additions and 201 deletions
+2
View File
@@ -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",
-1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
@@ -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",
]
}
###############################################################################
@@ -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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -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 <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#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> appMgrService = std::make_shared<AppMgrService>();
if (!appMgrService) {
return false;
}
sptr<IApplicationStateObserver> observer;
std::vector<std::string> 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;
}
@@ -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
@@ -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",