6月8日fuzz新增二

Signed-off-by: sunjiakun <sunjiakun5@huawei.com>
This commit is contained in:
sunjiakun 2024-06-08 18:00:29 +08:00
parent a978692857
commit 0598e99d0e
16 changed files with 913 additions and 0 deletions

View File

@ -78,6 +78,9 @@ group("fuzztest") {
"fuzztest_information/queryallabilityinfos_fuzzer:QueryAllAbilityInfosFuzzTest", "fuzztest_information/queryallabilityinfos_fuzzer:QueryAllAbilityInfosFuzzTest",
"fuzztest_information/querykeepalivebundleinfos_fuzzer:QueryKeepAliveBundleInfosFuzzTest", "fuzztest_information/querykeepalivebundleinfos_fuzzer:QueryKeepAliveBundleInfosFuzzTest",
"fuzztest_information/remoteabilityinfo_fuzzer:RemoteAbilityInfoFuzzTest", "fuzztest_information/remoteabilityinfo_fuzzer:RemoteAbilityInfoFuzzTest",
"fuzztest_others/GetExtResource_fuzzer:GetExtResourceFuzzTest",
"fuzztest_others/RemoveExtResource_fuzzer:RemoveExtResourceFuzzTest",
"fuzztest_others/appservicefwkinstallercheckfiletype_fuzzer:AppServiceFwkInstallerCheckFileTypeFuzzTest",
"fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest", "fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest",
"fuzztest_others/bundlecloneinstaller_fuzzer:BundlecloneinstallerFuzzTest", "fuzztest_others/bundlecloneinstaller_fuzzer:BundlecloneinstallerFuzzTest",
"fuzztest_others/commonevent_fuzzer:CommonEventFuzzTest", "fuzztest_others/commonevent_fuzzer:CommonEventFuzzTest",

View File

@ -0,0 +1,174 @@
# 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("GetExtResourceFuzzTest") {
use_exceptions = true
module_out_path = module_output_path
fuzz_config_file = "../../../fuzztest/fuzztest_others/GetExtResource_fuzzer"
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
"${services_path}/bundlemgr/include/extend_resource",
]
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 += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_service.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_installd_host_impl.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_bundle_status.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_clean_cache.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/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 += [ "GetExtResource_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library1:appService_v1_library1",
"${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/resourceManagerTest:resourceManagerTest",
"${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/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/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/test/mock/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_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" ]
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "extend_resource_manager_host_impl.h"
#include "GetExtResource_fuzzer.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
const std::string FUZZTEST_BUNDLE = "com.test.ext.resource";
}
bool fuzzelGetExtResourceCaseOne(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::string emptyBundleName;
std::vector<std::string> moduleNames;
auto ret = impl.GetExtResource(emptyBundleName, moduleNames);
if (ret == ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST) {
return true;
}
return false;
}
bool fuzzerlGetExtResourceCaseTwo(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::vector<std::string> moduleNames;
auto ret = impl.GetExtResource(FUZZTEST_BUNDLE, moduleNames);
if (ret == ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST) {
return true;
}
return false;
}
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
OHOS::fuzzelGetExtResourceCaseOne(data, size);
OHOS::fuzzerlGetExtResourceCaseTwo(data, size);
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_GETEXTRESOURCE_FUZZER_H
#define TEST_FUZZTEST_GETEXTRESOURCE_FUZZER_H
#define FUZZ_PROJECT_NAME "GetExtResource_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,175 @@
# 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("RemoveExtResourceFuzzTest") {
use_exceptions = true
module_out_path = module_output_path
fuzz_config_file =
"../../../fuzztest/fuzztest_others/RemoveExtResource_fuzzer"
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
"${services_path}/bundlemgr/include/extend_resource",
]
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 += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_service.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_installd_host_impl.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_bundle_status.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_clean_cache.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/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 += [ "RemoveExtResource_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library1:appService_v1_library1",
"${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/resourceManagerTest:resourceManagerTest",
"${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/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/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/test/mock/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_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" ]
}
}

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.
*/
#include "extend_resource_manager_host_impl.h"
#include "RemoveExtResource_fuzzer.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
const std::string FUZZTEST_BUNDLE = "com.test.ext.resource";
const std::string FUZZTEST_MODULE = "testModule";
}
bool fuzzelRemoveExtResourceCaseOne(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::string emptyBundleName;
std::vector<std::string> moduleNames;
auto ret = impl.RemoveExtResource(emptyBundleName, moduleNames);
if (ret == ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST) {
return true;
}
return false;
}
bool fuzzelRemoveExtResourceCaseTwo(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::vector<std::string> moduleNames;
auto ret = impl.RemoveExtResource(FUZZTEST_BUNDLE, moduleNames);
if (ret == ERR_EXT_RESOURCE_MANAGER_REMOVE_EXT_RESOURCE_FAILED) {
return true;
}
return false;
}
bool fuzzelRemoveExtResourceCaseThree(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::vector<std::string> moduleNames;
moduleNames.push_back(FUZZTEST_MODULE);
auto ret = impl.RemoveExtResource(FUZZTEST_BUNDLE, moduleNames);
if (ret == ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST) {
return true;
}
return false;
}
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
OHOS::fuzzelRemoveExtResourceCaseOne(data, size);
OHOS::fuzzelRemoveExtResourceCaseTwo(data, size);
OHOS::fuzzelRemoveExtResourceCaseThree(data, size);
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_REMOVEEXTRESOURCE_FUZZER_H
#define TEST_FUZZTEST_REMOVEEXTRESOURCE_FUZZER_H
#define FUZZ_PROJECT_NAME "RemoveExtResource_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,189 @@
# 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("AppServiceFwkInstallerCheckFileTypeFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/appservicefwkinstallercheckfiletype_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/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
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/test/mock/src/installd_service.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/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 += [ "appservicefwkinstallercheckfiletype_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library1:appService_v1_library1",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library2:appService_v1_library2",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version2_library1:appService_v2_library1",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version2_library2:appService_v2_library2",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/rightTest:rightTest",
"${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/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 (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 (current_cpu == "arm64") {
defines += [ "USE_BUNDLE_EXTENSION" ]
}
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 (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_quick_fix) {
include_dirs += [ "${services_path}/bundlemgr/src/include/quick_fix" ]
sources += quick_fix
defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
external_deps += [ "kv_store:distributeddata_inner" ]
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 (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 "app_service_fwk/app_service_fwk_installer.h"
#include "appservicefwkinstallercheckfiletype_fuzzer.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)
{
AppServiceFwkInstaller appServicefwk;
std::vector<std::string> hspPaths;
appServicefwk.CheckFileType(hspPaths);
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_APPSERVICEFWKINSTALLERCHECKFILETYPE_FUZZER_H
#define TEST_FUZZTEST_APPSERVICEFWKINSTALLERCHECKFILETYPE_FUZZER_H
#define FUZZ_PROJECT_NAME "appservicefwkinstallercheckfiletype_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>