1# Copyright (c) 2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13import("//build/test.gni")
14import("../../../../appexecfwk.gni")
15import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
16
17module_output_path = fuzz_test_path
18
19ohos_fuzztest("BundleResMgrFuzzTest") {
20  fuzz_config_file = "../../../fuzztest/fuzztest_others/bundleresmgr_fuzzer"
21  use_exceptions = true
22  module_out_path = module_output_path
23  include_dirs = [
24    "//third_party/jsoncpp/include",
25    "//third_party/json/include",
26  ]
27  sources = bundle_mgr_source
28  sources += [
29    "${services_path}/bundlemgr/src/aot/aot_executor.cpp",
30    "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
31    "${services_path}/bundlemgr/src/installd/installd_operator.cpp",
32  ]
33
34  sources += [
35    "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp",
36    "${services_path}/bundlemgr/src/installd/installd_service.cpp",
37  ]
38
39  sources += bundle_install_sources
40
41  sources += [ "bundleresmgr_fuzzer.cpp" ]
42
43  configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
44  cflags = [
45    "-g",
46    "-O0",
47    "-Wno-unused-variable",
48    "-fno-omit-frame-pointer",
49  ]
50
51  deps = [
52    "${base_path}:appexecfwk_base",
53    "${core_path}:appexecfwk_core",
54  ]
55  deps += bundle_install_deps
56
57  external_deps = [
58    "ability_base:want",
59    "ability_runtime:app_manager",
60    "access_token:el5_filekey_manager_sdk",
61    "access_token:libprivacy_sdk",
62    "access_token:libtokenid_sdk",
63    "appspawn:hnpapi",
64    "appverify:libhapverify",
65    "bounds_checking_function:libsec_shared",
66    "common_event_service:cesfwk_innerkits",
67    "eventhandler:libeventhandler",
68    "hilog:libhilog",
69    "hitrace:hitrace_meter",
70    "init:libbegetutil",
71    "safwk:system_ability_fwk",
72    "samgr:samgr_proxy",
73    "selinux_adapter:librestorecon",
74  ]
75  external_deps += bundle_install_external_deps
76  defines = []
77  if (current_cpu == "arm64") {
78    defines += [ "USE_EXTENSION_DATA" ]
79  }
80  if (code_signature_enable) {
81    sources += [
82      "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp",
83      "${services_path}/bundlemgr/src/code_sign_helper.cpp",
84    ]
85    include_dirs += [ "${services_path}/bundlemgr/include" ]
86    external_deps += [
87      "bounds_checking_function:libsec_shared",
88      "code_signature:libcode_sign_utils",
89      "ets_runtime:libcompiler_service",
90    ]
91    defines += [ "CODE_SIGNATURE_ENABLE" ]
92  }
93  if (configpolicy_enable) {
94    external_deps += [ "config_policy:configpolicy_util" ]
95    defines += [ "CONFIG_POLOCY_ENABLE" ]
96  }
97  if (build_selinux) {
98    external_deps += [ "selinux_adapter:libhap_restorecon" ]
99  }
100  if (account_enable) {
101    external_deps += [ "os_account:os_account_innerkits" ]
102    defines += [ "ACCOUNT_ENABLE" ]
103  }
104  if (bundle_framework_free_install) {
105    sources += aging
106    sources += free_install
107    sources += distributed_manager
108    external_deps += [
109      "ability_runtime:ability_manager",
110      "ability_runtime:app_manager",
111      "battery_manager:batterysrv_client",
112      "device_usage_statistics:usagestatsinner",
113      "display_manager:displaymgr",
114      "power_manager:powermgr_client",
115      "syscap_codec:syscap_interface_shared",
116    ]
117    defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
118  }
119  if (global_resmgr_enable) {
120    defines += [ "GLOBAL_RESMGR_ENABLE" ]
121    external_deps += [ "resource_management:global_resmgr" ]
122  }
123  if (global_i18n_enable) {
124    defines += [ "GLOBAL_I18_ENABLE" ]
125    external_deps += [ "i18n:intl_util" ]
126  }
127  if (hicollie_enable) {
128    external_deps += [ "hicollie:libhicollie" ]
129    defines += [ "HICOLLIE_ENABLE" ]
130  }
131
132  if (hisysevent_enable) {
133    sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
134    external_deps += [ "hisysevent:libhisysevent" ]
135    defines += [ "HISYSEVENT_ENABLE" ]
136  }
137
138  if (storage_service_enable) {
139    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
140    defines += [ "STORAGE_SERVICE_ENABLE" ]
141  }
142
143  configs += [ "../../../../services/bundlemgr:rdb_config" ]
144  external_deps += [ "relational_store:native_rdb" ]
145  sources += [
146    "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
147    "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
148    "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
149    "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
150  ]
151  if (bundle_framework_app_control) {
152    defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
153    sources += [
154      "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
155      "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
156      "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
157      "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
158      "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
159    ]
160    include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
161    external_deps += [ "c_utils:utils" ]
162  }
163
164  if (bundle_framework_bundle_resource) {
165    defines += [ "BUNDLE_FRAMEWORK_BUNDLE_RESOURCE" ]
166    external_deps += [ "ability_base:configuration" ]
167    if (bundle_framework_graphics) {
168      defines += [ "BUNDLE_FRAMEWORK_GRAPHICS" ]
169      external_deps += [
170        "ace_engine:drawable_descriptor",
171        "image_framework:image_native",
172      ]
173    }
174    sources += bundle_resource
175  }
176
177  if (bundle_framework_overlay_install) {
178    sources += overlay_installation
179    defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
180  }
181
182  if (udmf_enabled) {
183    defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
184    external_deps += [ "udmf:utd_client" ]
185  }
186
187  if (bms_device_info_manager_part_enabled) {
188    external_deps += [
189      "device_info_manager:distributed_device_profile_common",
190      "device_info_manager:distributed_device_profile_sdk",
191    ]
192    defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
193  }
194}
195