Signed-off-by: huangshiwei <huangshiwei4@huawei.com>
This commit is contained in:
huangshiwei
2025-06-18 11:37:53 +08:00
parent eba613a237
commit 189c8b15ca
41 changed files with 1739 additions and 0 deletions
+8
View File
@@ -46,10 +46,18 @@ group("fuzztest") {
"abilityappmgrrenderstatedata_fuzzer:fuzztest",
"abilityappmgrrunningmultiinfo_fuzzer:fuzztest",
"abilityapppreloader_fuzzer:fuzztest",
"abilityapppreloaderfirst_fuzzer:fuzztest",
"abilityapppreloadersecond_fuzzer:fuzztest",
"abilityattachtimeout_fuzzer:fuzztest",
"abilityautostartupclientfirst_fuzzer:fuzztest",
"abilityautostartupclientsecond_fuzzer:fuzztest",
"abilityautostartupclientthird_fuzzer:fuzztest",
"abilityautostartupdatamanager_fuzzer:fuzztest",
"abilityautostartupdatamanagera_fuzzer:fuzztest",
"abilityautostartupdatamanagerb_fuzzer:fuzztest",
"abilityautostartupdatamanagerfifth_fuzzer:fuzztest",
"abilityautostartupdatamanagerfourth_fuzzer:fuzztest",
"abilityautostartupdatamanagerthird_fuzzer:fuzztest",
"abilityautostartupservicea_fuzzer:fuzztest",
"abilityautostartupserviceb_fuzzer:fuzztest",
"abilitybackgroundconnection_fuzzer:fuzztest",
@@ -0,0 +1,73 @@
# 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/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
module_output_path = "ability_runtime/appmgrservice"
ohos_fuzztest("AbilityAppPreloaderFirstFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilityapppreloaderfirst_fuzzer"
include_dirs = [
"${ability_runtime_services_path}/appmgr/include",
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"abilityapppreloaderfirst_fuzzer.cpp",
]
deps = [
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
"${ability_runtime_path}/utils/server/startup:startup_util",
"${ability_runtime_services_path}/appmgr:libappms",
"${ability_runtime_services_path}/common:task_handler_wrap",
]
external_deps = [
"ability_base:want",
"appspawn:appspawn_client",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"resource_schedule_service:ressched_client",
"samgr:samgr_proxy",
"window_manager:libwm",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAppPreloaderFirstFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2022 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 "abilityapppreloaderfirst_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#define protected public
#include "app_preloader.h"
#include "bundle_mgr_helper.h"
#undef protected
#undef private
#include "parcel.h"
#include <iostream>
#include "securec.h"
#include "configuration.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
std::shared_ptr<RemoteClientManager> remoteClientManager = std::make_shared<RemoteClientManager>();
auto bundleMgrHelper = std::make_shared<AppExecFwk::BundleMgrHelper>();
remoteClientManager->SetBundleManagerHelper(bundleMgrHelper);
auto appPreloader = std::make_shared<AppPreloader>(remoteClientManager);
std::string bundleName;
int32_t userId;
int32_t appIndex;
PreloadRequest request;
FuzzedDataProvider fdp(data, size);
bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
appIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
appPreloader->GeneratePreloadRequest(bundleName, userId, appIndex, request);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 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_ABILITYAPPPRELOADER_FIRST_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_FIRST_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityapppreloaderfirst_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_FIRST_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2022 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>
@@ -0,0 +1,73 @@
# 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/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
module_output_path = "ability_runtime/appmgrservice"
ohos_fuzztest("AbilityAppPreloaderSecondFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilityapppreloadersecond_fuzzer"
include_dirs = [
"${ability_runtime_services_path}/appmgr/include",
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"abilityapppreloadersecond_fuzzer.cpp",
]
deps = [
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
"${ability_runtime_path}/utils/server/startup:startup_util",
"${ability_runtime_services_path}/appmgr:libappms",
"${ability_runtime_services_path}/common:task_handler_wrap",
]
external_deps = [
"ability_base:want",
"appspawn:appspawn_client",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"resource_schedule_service:ressched_client",
"samgr:samgr_proxy",
"window_manager:libwm",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAppPreloaderSecondFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 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 "abilityapppreloadersecond_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#define protected public
#include "app_preloader.h"
#include "bundle_mgr_helper.h"
#undef protected
#undef private
#include "parcel.h"
#include <iostream>
#include "securec.h"
#include "configuration.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
std::shared_ptr<RemoteClientManager> remoteClientManager = std::make_shared<RemoteClientManager>();
auto bundleMgrHelper = std::make_shared<AppExecFwk::BundleMgrHelper>();
remoteClientManager->SetBundleManagerHelper(bundleMgrHelper);
auto appPreloader = std::make_shared<AppPreloader>(remoteClientManager);
std::string bundleName;
int32_t userId;
AAFwk::Want launchWant;
FuzzedDataProvider fdp(data, size);
bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
appPreloader->GetLaunchWant(bundleName, userId, launchWant);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 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_ABILITYAPPPRELOADER_SECOND_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_SECOND_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityapppreloadersecond_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_SECOND_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2022 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>
@@ -0,0 +1,92 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupClientFirstFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilityautostartupclientfirst_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_client.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupclientfirst_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupClientFirstFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,63 @@
/*
* 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 "abilityautostartupclientfirst_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_client.h"
#undef private
#include "securec.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupClient = AbilityAutoStartupClient::GetInstance();
abilityAutoStartupClient->Connect();
AutoStartupInfo info;
FuzzedDataProvider fdp(data, size);
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
bool boolParam = fdp.ConsumeBool();
abilityAutoStartupClient->SetApplicationAutoStartupByEDM(info, boolParam);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_FIRST_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_FIRST_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupclientfirst_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_FIRST_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>
@@ -0,0 +1,92 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupClientSecondFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilityautostartupclientsecond_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_client.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupclientsecond_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupClientSecondFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,63 @@
/*
* 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 "abilityautostartupclientsecond_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_client.h"
#undef private
#include "securec.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupClient = AbilityAutoStartupClient::GetInstance();
abilityAutoStartupClient->Connect();
AutoStartupInfo info;
FuzzedDataProvider fdp(data, size);
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
bool boolParam = fdp.ConsumeBool();
abilityAutoStartupClient->CancelApplicationAutoStartupByEDM(info, boolParam);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_SECOND_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_SECOND_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupclientsecond_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_SECOND_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>
@@ -0,0 +1,92 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupClientThirdFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilityautostartupclientthird_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_client.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupclientthird_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupClientThirdFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,71 @@
/*
* 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 "abilityautostartupclientthird_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_client.h"
#undef private
#include "securec.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
void GetRandomAutoStartupInfo(FuzzedDataProvider& fdp, AutoStartupInfo& info)
{
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
}
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupClient = AbilityAutoStartupClient::GetInstance();
abilityAutoStartupClient->Connect();
AutoStartupInfo info;
std::vector<AutoStartupInfo> infoList;
FuzzedDataProvider fdp(data, size);
size_t arraySize = fdp.ConsumeIntegralInRange<size_t>(0, U32_AT_SIZE);
for (size_t i = 0; i < arraySize; ++i) {
GetRandomAutoStartupInfo(fdp, info);
infoList.emplace_back(info);
}
abilityAutoStartupClient->QueryAllAutoStartupApplications(infoList);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_THIRD_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_THIRD_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupclientthird_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_CLIENT_THIRD_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>
@@ -0,0 +1,93 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupDataManagerFifthFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityautostartupdatamanagerfifth_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_innerkits_path}/deps_wrapper/src/os_account_manager_wrapper.cpp",
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_data_manager.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupdatamanagerfifth_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupDataManagerFifthFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,73 @@
/*
* 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 "abilityautostartupdatamanagerfifth_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_data_manager.h"
#undef private
#include "ability_record.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
void GetRandomAutoStartupInfo(FuzzedDataProvider& fdp, AutoStartupInfo& info)
{
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
}
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupDataManager = std::make_shared<AbilityRuntime::AbilityAutoStartupDataManager>();
AutoStartupInfo info;
std::vector<AutoStartupInfo> infoList;
std::string strParam;
FuzzedDataProvider fdp(data, size);
strParam = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
size_t arraySize = fdp.ConsumeIntegralInRange<size_t>(0, U32_AT_SIZE);
for (size_t i = 0; i < arraySize; ++i) {
GetRandomAutoStartupInfo(fdp, info);
infoList.emplace_back(info);
}
abilityAutoStartupDataManager->GetCurrentAppAutoStartupData(strParam, infoList, strParam);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FIFTH_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FIFTH_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupdatamanagerfifth_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FIFTH_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>
@@ -0,0 +1,93 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupDataManagerFourthFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityautostartupdatamanagerfourth_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_innerkits_path}/deps_wrapper/src/os_account_manager_wrapper.cpp",
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_data_manager.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupdatamanagerfourth_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupDataManagerFourthFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,72 @@
/*
* 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 "abilityautostartupdatamanagerfourth_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_data_manager.h"
#undef private
#include "ability_record.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
void GetRandomAutoStartupInfo(FuzzedDataProvider& fdp, AutoStartupInfo& info)
{
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
}
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupDataManager = std::make_shared<AbilityRuntime::AbilityAutoStartupDataManager>();
FuzzedDataProvider fdp(data, size);
AutoStartupInfo info;
std::vector<AutoStartupInfo> infoList;
int32_t in32Param = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
size_t arraySize = fdp.ConsumeIntegralInRange<size_t>(0, U32_AT_SIZE);
for (size_t i = 0; i < arraySize; ++i) {
GetRandomAutoStartupInfo(fdp, info);
infoList.emplace_back(info);
}
abilityAutoStartupDataManager->QueryAllAutoStartupApplications(infoList, in32Param);
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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FOURTH_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FOURTH_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupdatamanagerfourth_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_FOURTH_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>
@@ -0,0 +1,93 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityAutoStartupDataManagerThirdFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityautostartupdatamanagerthird_fuzzer"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_services_path}/abilitymgr/include/utils",
"${ability_runtime_services_path}/abilitymgr/include",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [
"${ability_runtime_innerkits_path}/deps_wrapper/src/os_account_manager_wrapper.cpp",
"${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_data_manager.cpp",
"${ability_runtime_services_path}/common/src/app_utils.cpp",
"${ability_runtime_services_path}/common/src/json_utils.cpp",
"abilityautostartupdatamanagerthird_fuzzer.cpp",
]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"window_manager:libwsutils",
]
if (ability_runtime_graphics) {
external_deps += [ "input:libmmi-client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityAutoStartupDataManagerThirdFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,62 @@
/*
* 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 "abilityautostartupdatamanagerthird_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <fuzzer/FuzzedDataProvider.h>
#define private public
#include "ability_auto_startup_data_manager.h"
#undef private
#include "ability_record.h"
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t STRING_MAX_LENGTH = 128;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
auto abilityAutoStartupDataManager = std::make_shared<AbilityRuntime::AbilityAutoStartupDataManager>();
AutoStartupInfo info;
FuzzedDataProvider fdp(data, size);
info.appCloneIndex = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.userId = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.retryCount = fdp.ConsumeIntegralInRange<int32_t>(0, U32_AT_SIZE);
info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.abilityTypeName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
info.accessTokenId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH);
abilityAutoStartupDataManager->QueryAutoStartupData(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;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_THIRD_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_THIRD_FUZZER_H
#define FUZZ_PROJECT_NAME "abilityautostartupdatamanagerthird_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITY_AUTO_STARTUP_DATA_MANAGER_THIRD_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?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>