!6281 fuzz新增:basebundleinstaller5

Merge pull request !6281 from sunjiakun/fuzztest0629_partone
This commit is contained in:
openharmony_ci 2024-07-18 03:05:07 +00:00 committed by Gitee
commit aa5f5a31f7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
26 changed files with 1463 additions and 0 deletions

View File

@ -105,6 +105,7 @@ group("fuzztest") {
"fuzztest_others/basebundleinstallercheckuninstallinnerbundleinfo_fuzzer:BaseBundleInstallerCheckUninstallInnerBundleInfoFuzzTest",
"fuzztest_others/basebundleinstallercreatebundleanddatadir_fuzzer:BaseBundleInstallerCreateBundleAndDataDirFuzzTest",
"fuzztest_others/basebundleinstallerextractmodule_fuzzer:BaseBundleInstallerExtractModuleFuzzTest",
"fuzztest_others/basebundleinstallerextractmodulefiles_fuzzer:BaseBundleInstallerExtractModuleFilesFuzzTest",
"fuzztest_others/basebundleinstallerinnerprocessbundleinstall_fuzzer:BaseBundleInstallerInnerProcessBundleInstallFuzzTest",
"fuzztest_others/basebundleinstallerinstallbundle_fuzzer:BaseBundleInstallerInstallBundleFuzzTest",
"fuzztest_others/basebundleinstallerinstallbundlebybundlename_fuzzer:BaseBundleInstallerInstallBundleByBundleNameFuzzTest",
@ -116,9 +117,13 @@ group("fuzztest") {
"fuzztest_others/basebundleinstallerprocessbundleuninstall_fuzzer:BaseBundleInstallerProcessBundleUninstallFuzzTest",
"fuzztest_others/basebundleinstallerprocessbundleuninstallnative_fuzzer:BaseBundleInstallerProcessBundleUnInstallNativeFuzzTest",
"fuzztest_others/basebundleinstallerprocessbundleupdatestatus_fuzzer:BaseBundleInstallerProcessBundleUpdateStatusFuzzTest",
"fuzztest_others/basebundleinstallerprocessmoduleupdate_fuzzer:BaseBundleInstallerProcessModuleUpdateFuzzTest",
"fuzztest_others/basebundleinstallerrecover_fuzzer:BaseBundleInstallerRecoverFuzzTest",
"fuzztest_others/basebundleinstallerremovebundle_fuzzer:BaseBundleInstallerRemoveBundleFuzzTest",
"fuzztest_others/basebundleinstallerremovebundleanddatadir_fuzzer:BaseBundleInstallerRemoveBundleAndDataDirFuzzTest",
"fuzztest_others/basebundleinstallerremovemoduleanddatadir_fuzzer:BaseBundleInstallerRemoveModuleAndDataDirFuzzTest",
"fuzztest_others/basebundleinstallerremovemoduledir_fuzzer:BaseBundleInstallerRemoveModuleDirFuzzTest",
"fuzztest_others/basebundleinstallerrenamemoduledir_fuzzer:BaseBundleInstallerRenameModuleDirFuzzTest",
"fuzztest_others/basebundleinstallersetcheckresultmsg_fuzzer:BaseBundleInstallerSetCheckResultMsgFuzzTest",
"fuzztest_others/basebundleinstalleruninstallbundle_fuzzer:BaseBundleInstallerUnInstallBundleFuzzTest",
"fuzztest_others/basebundleinstalleruninstallbundlebyuninstallparam_fuzzer:BaseBundleInstallerUninstallBundleByUninstallParamFuzzTest",

View File

@ -0,0 +1,161 @@
# Copyright (c) 2021-2023 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("BaseBundleInstallerExtractModuleFilesFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/basebundleinstallerextractmodulefiles_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/test/mock/include/parameter",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameter.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameters.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/systemcapability.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += [ "basebundleinstallerextractmodulefiles_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [ "${core_path}:appexecfwk_core" ]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
if (bundle_framework_graphics) {
external_deps += [ "image_framework:image_native" ]
}
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -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.
*/
#define private public
#include <cstddef>
#include <cstdint>
#include "basebundleinstallerextractmodulefiles_fuzzer.h"
#include "base_bundle_installer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
{
BaseBundleInstaller basebundleinstall;
InnerBundleInfo info;
std::string modulePath;
std::string targetSoPath;
std::string cpuAbi;
auto ret1 = basebundleinstall.ExtractModuleFiles(info, modulePath, targetSoPath, cpuAbi);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char *ch = static_cast<char *>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -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 TEST_FUZZTEST_BASEBUNDLEINSTALLEREXTRACTMODULEFILES_FUZZER_H
#define TEST_FUZZTEST_BASEBUNDLEINSTALLEREXTRACTMODULEFILES_FUZZER_H
#define FUZZ_PROJECT_NAME "basebundleinstallerextractmodulefiles_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# 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

View File

@ -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>

View File

@ -0,0 +1,161 @@
# Copyright (c) 2021-2023 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("BaseBundleInstallerProcessModuleUpdateFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/basebundleinstallerprocessmoduleupdate_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/test/mock/include/parameter",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameter.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameters.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/systemcapability.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += [ "basebundleinstallerprocessmoduleupdate_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [ "${core_path}:appexecfwk_core" ]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
if (bundle_framework_graphics) {
external_deps += [ "image_framework:image_native" ]
}
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -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.
*/
#define private public
#include <cstddef>
#include <cstdint>
#include "basebundleinstallerprocessmoduleupdate_fuzzer.h"
#include "base_bundle_installer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
{
BaseBundleInstaller basebundleinstall;
InnerBundleInfo newInfo;
InnerBundleInfo oldInfo;
bool isReplace = true;
auto ret1 = basebundleinstall.ProcessModuleUpdate(newInfo, oldInfo, isReplace);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char *ch = static_cast<char *>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -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 TEST_FUZZTEST_BASEBUNDLEINSTALLERPROCESSMODULEUPDATE_FUZZER_H
#define TEST_FUZZTEST_BASEBUNDLEINSTALLERPROCESSMODULEUPDATE_FUZZER_H
#define FUZZ_PROJECT_NAME "basebundleinstallerprocessmoduleupdate_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# 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

View File

@ -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>

View File

@ -0,0 +1,161 @@
# Copyright (c) 2021-2023 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("BaseBundleInstallerRemoveModuleAndDataDirFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/basebundleinstallerremovemoduleanddatadir_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/test/mock/include/parameter",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameter.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameters.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/systemcapability.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += [ "basebundleinstallerremovemoduleanddatadir_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [ "${core_path}:appexecfwk_core" ]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
if (bundle_framework_graphics) {
external_deps += [ "image_framework:image_native" ]
}
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -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.
*/
#define private public
#include <cstddef>
#include <cstdint>
#include "basebundleinstallerremovemoduleanddatadir_fuzzer.h"
#include "base_bundle_installer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
{
BaseBundleInstaller basebundleinstall;
InnerBundleInfo info;
std::string modulePackage;
int32_t userId = 0;
bool isKeepData = true;
auto ret1 = basebundleinstall.RemoveModuleAndDataDir(info, modulePackage, userId, isKeepData);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char *ch = static_cast<char *>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -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 TEST_FUZZTEST_BASEBUNDLEINSTALLERREMOVEMODULEANDDATADIR_FUZZER_H
#define TEST_FUZZTEST_BASEBUNDLEINSTALLERREMOVEMODULEANDDATADIR_FUZZER_H
#define FUZZ_PROJECT_NAME "basebundleinstallerremovemoduleanddatadir_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# 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

View File

@ -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>

View File

@ -0,0 +1,161 @@
# Copyright (c) 2021-2023 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("BaseBundleInstallerRemoveModuleDirFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/basebundleinstallerremovemoduledir_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/test/mock/include/parameter",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameter.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameters.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/systemcapability.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += [ "basebundleinstallerremovemoduledir_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [ "${core_path}:appexecfwk_core" ]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
if (bundle_framework_graphics) {
external_deps += [ "image_framework:image_native" ]
}
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
#define private public
#include <cstddef>
#include <cstdint>
#include "basebundleinstallerremovemoduledir_fuzzer.h"
#include "base_bundle_installer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
{
BaseBundleInstaller basebundleinstall;
std::string modulePath;
auto ret1 = basebundleinstall.RemoveModuleDir(modulePath);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char *ch = static_cast<char *>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -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 TEST_FUZZTEST_BASEBUNDLEINSTALLERREMOVEMODULEDIR_FUZZER_H
#define TEST_FUZZTEST_BASEBUNDLEINSTALLERREMOVEMODULEDIR_FUZZER_H
#define FUZZ_PROJECT_NAME "basebundleinstallerremovemoduledir_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# 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

View File

@ -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>

View File

@ -0,0 +1,161 @@
# Copyright (c) 2021-2023 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("BaseBundleInstallerRenameModuleDirFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/basebundleinstallerrenamemoduledir_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/test/mock/include/parameter",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameter.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/parameters.cpp",
"${services_path}/bundlemgr/test/mock/src/parameter/systemcapability.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += [ "basebundleinstallerrenamemoduledir_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [ "${core_path}:appexecfwk_core" ]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
if (bundle_framework_graphics) {
external_deps += [ "image_framework:image_native" ]
}
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
#define private public
#include <cstddef>
#include <cstdint>
#include "basebundleinstallerrenamemoduledir_fuzzer.h"
#include "base_bundle_installer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
{
BaseBundleInstaller basebundleinstall;
InnerBundleInfo info;
auto ret1 = basebundleinstall.RenameModuleDir(info);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char *ch = static_cast<char *>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -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 TEST_FUZZTEST_BASEBUNDLEINSTALLERRENAMEMODULEDIR_FUZZER_H
#define TEST_FUZZTEST_BASEBUNDLEINSTALLERRENAMEMODULEDIR_FUZZER_H
#define FUZZ_PROJECT_NAME "basebundleinstallerrenamemoduledir_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# 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

View File

@ -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>