Signed-off-by: sunjiakun <sunjiakun5@huawei.com>
This commit is contained in:
sunjiakun 2024-09-28 11:58:11 +08:00
parent 141700e7c7
commit ba2fbd0e96
42 changed files with 2350 additions and 1 deletions

View File

@ -80,6 +80,7 @@ group("fuzztest") {
"fuzztest_information/remoteabilityinfo_fuzzer:RemoteAbilityInfoFuzzTest",
"fuzztest_others/GetExtResource_fuzzer:GetExtResourceFuzzTest",
"fuzztest_others/RemoveExtResource_fuzzer:RemoveExtResourceFuzzTest",
"fuzztest_others/accounthelper_fuzzer:AccountHelperFuzzTest",
"fuzztest_others/aginghandlerchain_fuzzer:AgingHandlerChainFuzzTest",
"fuzztest_others/agingrequest_fuzzer:AgingRequestFuzzTest",
"fuzztest_others/agingutil_fuzzer:AgingUtilFuzzTest",
@ -137,14 +138,17 @@ group("fuzztest") {
"fuzztest_others/basebundleinstalleruninstallbundlebyuninstallparam_fuzzer:BaseBundleInstallerUninstallBundleByUninstallParamFuzzTest",
"fuzztest_others/basebundleinstalleruninstallbundlemodule_fuzzer:BaseBundleInstallerUnInstallBundleModuleFuzzTest",
"fuzztest_others/beforeaddextresource_fuzzer:BeforeAddExtResourceFuzzTest",
"fuzztest_others/bmsbundleresourcehelper_fuzzer:BmsBundleResourceHelperFuzzTest",
"fuzztest_others/bmsecologicalrulemgrserviceclient_fuzzer:BmsEcologicalRulemgrServiceClientFuzzTest",
"fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest",
"fuzztest_others/bmskeyeventmgr_fuzzer:BmsKeyEventMgrFuzzTest",
"fuzztest_others/bundleagingmgr_fuzzer:BundleAgingMgrFuzzTest",
"fuzztest_others/bundlecloneinstaller_fuzzer:BundlecloneinstallerFuzzTest",
"fuzztest_others/bundleconnectabilitymgr_fuzzer:BundleConnectAbilityMgrFuzzTest",
"fuzztest_others/bundlemanagercallback_fuzzer:BundleManagerCallbackFuzzTest",
"fuzztest_others/bundlemanagercallbackproxy_fuzzer:BundleManagerCallbackProxyFuzzTest",
"fuzztest_others/bundlemanagercallbackstub_fuzzer:BundleManagerCallbackStubFuzzTest",
"fuzztest_others/bundlemutiuserinstaller_fuzzer:BundleMutiuserInstallerFuzzTest",
"fuzztest_others/checkfileparam_fuzzer:CheckFileParamFuzzTest",
"fuzztest_others/checkmoduleexist_fuzzer:CheckModuleExistFuzzTest",
"fuzztest_others/commonevent_fuzzer:CommonEventFuzzTest",
@ -194,14 +198,18 @@ group("fuzztest") {
"fuzztest_others/quickfixmgr_fuzzer:QuickFixMgrFuzzTest",
"fuzztest_others/quickfixstatuscallbackproxy_fuzzer:QuickFixStatusCallbackProxyFuzzTest",
"fuzztest_others/quickfixswitcher_fuzzer:QuickFixSwitcherFuzzTest",
"fuzztest_others/recentlyunusedagingmgr_fuzzer:RecentlyUnusedAgingMgrFuzzTest",
"fuzztest_others/removeextresourcesdb_fuzzer:RemoveExtResourcesDbFuzzTest",
"fuzztest_others/resetbundleresourceicon_fuzzer:ResetBundleResourceIconFuzzTest",
"fuzztest_others/rollback_fuzzer:RollBackFuzzTest",
"fuzztest_others/routerdatastoragerdb_fuzzer:RouterDataStorageRdbFuzzTest",
"fuzztest_others/routermaphelper_fuzzer:RouterMapHelperFuzzTest",
"fuzztest_others/savecurdynamicicon_fuzzer:SaveCurDynamicIconFuzzTest",
"fuzztest_others/sendbroadcast_fuzzer:SendBroadCastFuzzTest",
"fuzztest_others/servicecenterconnection_fuzzer:ServiceCenterConnectionFuzzTest",
"fuzztest_others/servicecenterstatuscallback_fuzzer:ServiceCenterStatusCallbackFuzzTest",
"fuzztest_others/servicecenterstatuscallbackstub_fuzzer:ServiceCenterStatusCallbackStubFuzzTest",
"fuzztest_others/shortcutdatastoragerdb_fuzzer:ShortCutDataStorageRdbFuzzTest",
"fuzztest_others/shortcutinfo_fuzzer:ShortcutInfoFuzzTest",
"fuzztest_others/switchquickfix_fuzzer:SwitchQuickFixFuzzTest",
"fuzztest_others/systemabilityhelper_fuzzer:SystemAbilityHelperFuzzTest",

View File

@ -25,7 +25,7 @@ using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
constexpr uint32_t CODE_MAX = 159;
constexpr uint32_t CODE_MAX = 164;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)

View File

@ -0,0 +1,140 @@
# 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = "bundle_framework/bundle_framework"
ohos_fuzztest("AccountHelperFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/accounthelper_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_install_sources
sources += bundle_mgr_source
sources += [ "accounthelper_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",
"kv_store:distributeddata_inner",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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/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:utd_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" ]
}
if (code_signature_enable) {
sources +=
[ "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp" ]
defines += [ "CODE_SIGNATURE_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 "accounthelper_fuzzer.h"
#include "account_helper.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)
{
int32_t id = 100;
bool isOsAccountExists = true;
AccountHelper::IsOsAccountExists(id, isOsAccountExists);
AccountHelper::GetCurrentActiveUserId();
AccountHelper::IsOsAccountVerified(id);
AccountHelper::GetOsAccountLocalIdFromUid(id);
return true;
}
} // namespace OHOS
// 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_ACCOUNTHELPER_FUZZER_H
#define TEST_FUZZTEST_ACCOUNTHELPER_FUZZER_H
#define FUZZ_PROJECT_NAME "accounthelper_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>10</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,193 @@
# Copyright (c) 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("BmsBundleResourceHelperFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/bmsbundleresourcehelper_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
]
sources = bundle_mgr_source
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
]
sources += [
"${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
]
sources += bundle_install_sources
sources += [ "bmsbundleresourcehelper_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${base_path}:appexecfwk_base",
"${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",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"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
defines = []
if (current_cpu == "arm64") {
defines += [ "USE_EXTENSION_DATA" ]
}
if (code_signature_enable) {
sources += [
"${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp",
"${services_path}/bundlemgr/src/code_sign_helper.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (global_i18n_enable) {
defines += [ "GLOBAL_I18_ENABLE" ]
external_deps += [ "i18n:intl_util" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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/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 (bundle_framework_bundle_resource) {
defines += [ "BUNDLE_FRAMEWORK_BUNDLE_RESOURCE" ]
external_deps += [ "ability_base:configuration" ]
if (bundle_framework_graphics) {
defines += [ "BUNDLE_FRAMEWORK_GRAPHICS" ]
external_deps += [
"ace_engine:drawable_descriptor",
"image_framework:image_native",
]
}
sources += bundle_resource
}
if (bundle_framework_overlay_install) {
sources += overlay_installation
defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:utd_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,82 @@
/*
* 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 "bmsbundleresourcehelper_fuzzer.h"
#include "bundle_resource_helper.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
const int32_t USERID = 100;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
BundleResourceHelper::BundleSystemStateInit();
BundleResourceHelper::RegisterConfigurationObserver();
BundleResourceHelper::RegisterCommonEventSubscriber();
std::string bundleName(data, size);
BundleResourceHelper::AddResourceInfoByBundleName(bundleName, USERID);
BundleResourceHelper::DeleteResourceInfo(bundleName);
BundleResourceHelper::DeleteAllResourceInfo();
std::vector<std::string> resourceNames;
BundleResourceHelper::GetAllBundleResourceName(resourceNames);
BundleResourceHelper::ParseBundleName(bundleName);
std::string moduleName(data, size);
BundleResourceHelper::SetOverlayEnabled(bundleName, moduleName, true, USERID);
int32_t appIndex = 0;
BundleResourceHelper::AddCloneBundleResourceInfo(bundleName, appIndex, USERID);
BundleResourceHelper::DeleteCloneBundleResourceInfo(bundleName, appIndex, USERID);
BundleResourceHelper::DeleteNotExistResourceInfo();
return true;
}
} // namespace OHOS
// 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_BMSBUNDLERESOURCEHELPER_FUZZER_H
#define TEST_FUZZTEST_BMSBUNDLERESOURCEHELPER_FUZZER_H
#define FUZZ_PROJECT_NAME "bmsbundleresourcehelper_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>10</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,140 @@
# 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = "bundle_framework/bundle_framework"
ohos_fuzztest("BmsKeyEventMgrFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/bmskeyeventmgr_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_install_sources
sources += bundle_mgr_source
sources += [ "bmskeyeventmgr_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",
"kv_store:distributeddata_inner",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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/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:utd_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" ]
}
if (code_signature_enable) {
sources +=
[ "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp" ]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
}

View File

@ -0,0 +1,67 @@
/*
* 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 "bmskeyeventmgr_fuzzer.h"
#include "bms_key_event_mgr.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)
{
BmsKeyEventMgr::ProcessMainBundleStatusFinally();
BmsKeyEventMgr::ProcessMainBundleInstallFailed("", 0);
return true;
}
} // namespace OHOS
// 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_BMSKEYEVENTMGR_FUZZER_H
#define TEST_FUZZTEST_BMSKEYEVENTMGR_FUZZER_H
#define FUZZ_PROJECT_NAME "bmskeyeventmgr_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>10</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,141 @@
# 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = "bundle_framework/bundle_framework"
ohos_fuzztest("BundleMutiuserInstallerFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/bundlemutiuserinstaller_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_install_sources
sources += bundle_mgr_source
sources += [ "bundlemutiuserinstaller_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",
"kv_store:distributeddata_inner",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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/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:utd_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" ]
}
if (code_signature_enable) {
sources +=
[ "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp" ]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
}

View File

@ -0,0 +1,76 @@
/*
* 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 "bundlemutiuserinstaller_fuzzer.h"
#include "bundle_multiuser_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;
const int32_t USERID = 100;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
std::shared_ptr<BundleMultiUserInstaller> installer = std::make_shared<BundleMultiUserInstaller>();
std::string bundleName(data, size);
installer->InstallExistedApp(bundleName, USERID);
installer->ProcessBundleInstall(bundleName, USERID);
installer->ResetInstallProperties();
InnerBundleInfo info;
int32_t uid = 1;
installer->CreateDataDir(info, USERID, uid);
installer->RemoveDataDir(bundleName, USERID);
installer->GetDataMgr();
return true;
}
} // namespace OHOS
// 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_BUNDLEMUTIUSERINSTALLER_FUZZER_H
#define TEST_FUZZTEST_BUNDLEMUTIUSERINSTALLER_FUZZER_H
#define FUZZ_PROJECT_NAME "bundlemutiuserinstaller_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>10</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,167 @@
# 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("RecentlyUnusedAgingMgrFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/recentlyunusedagingmgr_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_mgr_source
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
]
sources +=
[ "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp" ]
sources += bundle_install_sources
sources += [ "recentlyunusedagingmgr_fuzzer.cpp" ]
configs = [
"${services_path}/bundlemgr/test:bundlemgr_test_config",
"${inner_api_path}/appexecfwk_base:appexecfwk_base_sdk_config",
]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_kit/test:test",
"${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
"${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",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"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
defines = []
if (current_cpu == "arm64") {
defines += [ "USE_ARM64" ]
}
if (code_signature_enable) {
sources += [
"${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp",
"${services_path}/bundlemgr/src/code_sign_helper.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
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 (ability_runtime_enable) {
external_deps += [ "ability_runtime:ability_manager" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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/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/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:utd_client" ]
}
}

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,79 @@
/*
* 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 "recentlyunusedagingmgr_fuzzer.h"
#include "aging/aging_handler.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
constexpr uint8_t ENABLE = 2;
constexpr uint8_t CODE_MAX = 22;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
RecentlyUnuseBundleAgingHandler bundleAgingMgr;
AgingRequest request;
bundleAgingMgr.Process(request);
bundleAgingMgr.NeedContinue(request);
bundleAgingMgr.ProcessBundle(request);
bundleAgingMgr.UpdateUsedTotalDataBytes(request);
AgingBundleInfo agingBundle;
bundleAgingMgr.AgingClean(agingBundle, request);
bundleAgingMgr.CleanCache(agingBundle);
std::vector<std::string> caches;
bundleAgingMgr.GetCachePath(agingBundle, caches);
bundleAgingMgr.UnInstallBundle(std::string(data, size));
return true;
}
} // namespace OHOS
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
char* ch = (char*)malloc(size + 1);
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size + 1, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
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_RECENTLYUNUSEDAGINGMGR_FUZZER_H
#define TEST_FUZZTEST_RECENTLYUNUSEDAGINGMGR_FUZZER_H
#define FUZZ_PROJECT_NAME "recentlyunusedagingmgr_fuzzer"
#endif

View File

@ -0,0 +1,159 @@
# 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("RouterDataStorageRdbFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/routerdatastoragerdb_fuzzer"
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
"${services_path}/bundlemgr/include/navigation",
]
sources = bundle_mgr_source
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
sources +=
[ "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp" ]
sources += bundle_install_sources
sources += [ "routerdatastoragerdb_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",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"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
defines = []
if (code_signature_enable) {
sources += [
"${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp",
"${services_path}/bundlemgr/src/code_sign_helper.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
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_info_manager:distributed_device_profile_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (bundle_framework_default_app) {
sources += default_app
defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "../../../../services/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",
]
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:utd_client" ]
}
}

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,78 @@
/*
* 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 "routerdatastoragerdb_fuzzer.h"
#include "router_data_storage_rdb.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
constexpr uint8_t ENABLE = 2;
constexpr uint8_t CODE_MAX = 22;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
auto routerDataStorageRdb = std::make_shared<RouterDataStorageRdb>();
std::string bundleName(data, size);
std::string moduleName(data, size);
std::map<std::string, std::string> routerInfoMap;
std::vector<RouterItem> routerInfos;
routerDataStorageRdb->UpdateRouterInfo(bundleName, routerInfoMap);
routerDataStorageRdb->GetRouterInfo(bundleName, moduleName, routerInfos);
std::set<std::string> bundleNames;
routerDataStorageRdb->GetAllBundleNames(bundleNames);
routerDataStorageRdb->DeleteRouterInfo(bundleName);
routerDataStorageRdb->DeleteRouterInfo(bundleName, moduleName);
return true;
}
} // namespace OHOS
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
char* ch = (char*)malloc(size + 1);
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size + 1, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
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_ROUTERDATASTORAGERDB_FUZZER_H
#define TEST_FUZZTEST_ROUTERDATASTORAGERDB_FUZZER_H
#define FUZZ_PROJECT_NAME "routerdatastoragerdb_fuzzer"
#endif

View File

@ -0,0 +1,159 @@
# 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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("RouterMapHelperFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/routermaphelper_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
"${services_path}/bundlemgr/include/navigation",
]
sources = bundle_mgr_source
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
sources +=
[ "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp" ]
sources += bundle_install_sources
sources += [ "routermaphelper_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",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"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
defines = []
if (code_signature_enable) {
sources += [
"${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp",
"${services_path}/bundlemgr/src/code_sign_helper.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
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_info_manager:distributed_device_profile_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (bundle_framework_default_app) {
sources += default_app
defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "../../../../services/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",
]
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:utd_client" ]
}
}

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,83 @@
/*
* 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 "routermaphelper_fuzzer.h"
#include "router_map_helper.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
constexpr uint8_t ENABLE = 2;
constexpr uint8_t CODE_MAX = 22;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
BundleInfo info;
std::vector<RouterItem> routerArrayList;
std::vector<RouterItem> routerArray;
std::set<std::string> moduleNameSet;
RouterMapHelper::MergeRouter(info);
RouterMapHelper::MergeRouter(routerArrayList, routerArray, moduleNameSet);
std::string version1 = "1.0.0";
std::string version2 = "2.0.0";
RouterMapHelper::Compare(version1, version2);
SemVer semVer1(version1);
SemVer semVer2(version2);
RouterMapHelper::Compare(semVer1, semVer2);
RouterMapHelper::CompareIdentifiers(version1, version2);
RouterMapHelper::CompareMain(semVer1, semVer2);
RouterMapHelper::ComparePre(semVer1, semVer2);
RouterMapHelper::ExtractVersionFromOhmurl(version1);
return true;
}
} // namespace OHOS
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
char* ch = (char*)malloc(size + 1);
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size + 1, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
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_ROUTERMAPHELPER_FUZZER_H
#define TEST_FUZZTEST_ROUTERMAPHELPER_FUZZER_H
#define FUZZ_PROJECT_NAME "routermaphelper_fuzzer"
#endif

View File

@ -0,0 +1,140 @@
# Copyright (c) 2021-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.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
config("private_config") {
include_dirs = [ "${services_path}/bundlemgr/include" ]
}
module_output_path = fuzz_test_path
ohos_fuzztest("ShortCutDataStorageRdbFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/shortcutdatastoragerdb_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_mgr_source
sources += bundle_install_sources
sources += [ "shortcutdatastoragerdb_fuzzer.cpp" ]
sources += [ "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp" ]
configs = [
"${services_path}/bundlemgr/test:bundlemgr_test_config",
"${inner_api_path}/appexecfwk_base:appexecfwk_base_sdk_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
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
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:ability_start_options",
"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 (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
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" ]
}
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" ]
}
external_deps += [ "kv_store:distributeddata_inner" ]
configs += [ "../../../../services/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/rdb_data_manager.cpp",
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable) {
sources +=
[ "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp" ]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
}

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>10</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,86 @@
/*
* 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 "shortcutdatastoragerdb_fuzzer.h"
#include "shortcut_data_storage_rdb.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
const int32_t USERID = 100;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
std::shared_ptr<ShortcutDataStorageRdb> shortcutDataStorageRdb = std::make_shared<ShortcutDataStorageRdb>();
ShortcutInfo shortcutInfo;
shortcutInfo.id = "id_test1";
shortcutInfo.bundleName = "com.ohos.hello";
shortcutInfo.hostAbility = "hostAbility";
shortcutInfo.icon = "$media:16777224";
shortcutInfo.label = "shortcutLabel";
shortcutInfo.disableMessage = "shortcutDisableMessage";
shortcutInfo.isStatic = true;
shortcutInfo.isHomeShortcut = true;
shortcutInfo.isEnables = true;
bool isIdIllegal = false;
shortcutDataStorageRdb->AddDesktopShortcutInfo(shortcutInfo, USERID, isIdIllegal);
shortcutDataStorageRdb->DeleteDesktopShortcutInfo(shortcutInfo, USERID);
std::vector<ShortcutInfo> shortcutInfos;
shortcutDataStorageRdb->GetAllDesktopShortcutInfo(USERID, shortcutInfos);
shortcutDataStorageRdb->DeleteDesktopShortcutInfo(shortcutInfo.bundleName);
shortcutDataStorageRdb->DeleteDesktopShortcutInfo(shortcutInfo.bundleName, USERID, shortcutInfo.appIndex);
shortcutDataStorageRdb->ShortcutIdVerification(shortcutInfo, USERID);
shortcutDataStorageRdb->GetDesktopShortcutInfosByDefaultUserId(shortcutInfos);
return true;
}
} // namespace OHOS
// 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_SHORTCUTDATASTORAGERDB_FUZZER_H
#define TEST_FUZZTEST_SHORTCUTDATASTORAGERDB_FUZZER_H
#define FUZZ_PROJECT_NAME "shortcutdatastoragerdb_fuzzer"
#endif