1# Copyright (c) 2025 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. 13 14import("../../../../os_account.gni") 15import("../../../../services/accountmgr/os_account_service.gni") 16 17#####################hydra-fuzz################### 18import("//build/config/features.gni") 19import("//build/ohos.gni") 20import("//build/test.gni") 21 22##############################fuzztest########################################## 23config("os_account_manager_service_test_config") { 24 include_dirs = [ 25 "${services_path}/accountmgr/test/mock/common", 26 "${services_path}/accountmgr/test/mock/os_account", 27 "${services_path}/accountmgr/include", 28 "${services_path}/accountmgr/include/osaccount", 29 "${common_path}/log/include", 30 "${common_path}/perf_stat/include", 31 "${innerkits_common}/include", 32 "${innerkits_path}/include", 33 ] 34} 35 36ohos_fuzztest("CreateOsAccountForDomainStubFuzzTest") { 37 module_out_path = fuzz_output_path 38 39 fuzz_config_file = "." 40 41 defines = [ 42 "ACCOUNT_LOG_TAG = \"OsAccountFuzzTest\"", 43 "LOG_DOMAIN = 0xD001B00", 44 ] 45 include_dirs = [ 46 "${os_account_path}/test/fuzztest/osaccount_stub/common", 47 "${app_account_services_path}/test/mock/common", 48 "${services_path}/accountmgr/include/domain_account", 49 "${app_account_innerkits_native_path}/include", 50 "${os_account_path}/frameworks/osaccount/core/include", 51 "${os_account_dfx_path}/data_dfx", 52 ] 53 cflags = [ 54 "-g", 55 "-O0", 56 "-Wno-unused-variable", 57 "-fno-omit-frame-pointer", 58 ] 59 cflags_cc = [ "-DACCOUNT_TEST" ] 60 if (use_libfuzzer) { 61 cflags_cc += [ "-DFUZZ_TEST" ] 62 } 63 if (has_user_idm_part) { 64 cflags_cc += [ "-DHAS_USER_IDM_PART" ] 65 } 66 if (target_cpu == "arm64") { 67 defines += [ "_ARM64_" ] 68 } 69 if (target_cpu == "arm") { 70 cflags += [ "-DBINDER_IPC_32BIT" ] 71 } 72 sources = [ "createosaccountfordomainstub_fuzzer.cpp" ] 73 sources += [ 74 "${app_account_services_path}/src/ability_manager_adapter/ability_manager_adapter.cpp", 75 "${app_account_services_path}/src/appaccount/app_account_control_manager.cpp", 76 "${app_account_services_path}/src/appaccount/app_account_manager_service.cpp", 77 "${app_account_services_path}/src/appaccount/inner_app_account_manager.cpp", 78 "${services_path}/accountmgr/test/mock/common/bundle_manager_adapter.cpp", 79 "${services_path}/accountmgr/test/mock/os_account/os_account_interface.cpp", 80 "${services_path}/accountmgr/test/mock/os_account/permission_kit.cpp", 81 ] 82 sources += [ 83 "${common_path}/utils/src/account_permission_manager.cpp", 84 "${domain_account_framework_path}/src/domain_account_callback_service.cpp", 85 "${domain_account_framework_path}/src/domain_account_common.cpp", 86 "${os_account_dfx_path}/data_dfx/data_size_report_adapter.cpp", 87 "${domain_account_framework_path}/src/domain_account_parcel.cpp", 88 "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp", 89 "${os_account_dfx_path}/hisysevent_adapter/account_hisysevent_adapter.cpp", 90 "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp", 91 "${services_path}/accountmgr/src/appaccount/os_account_state_subscriber.cpp", 92 ] 93 sources += account_service_sources_mock 94 sources += account_data_storage_source 95 sources += account_iam_source 96 sources += app_account_sources_mock 97 98 configs = [ 99 ":os_account_manager_service_test_config", 100 "${app_account_services_path}/test/mock:mock_accountmgr_config", 101 "${app_account_services_path}/test/mock:accountmgr_config", 102 ] 103 104 version_script = "${services_path}/accountmgr/libaccountmgr.map" 105 106 deps = [ 107 "${account_iam_framework_path}:account_iam_stub", 108 "${account_iam_framework_path}:account_iam_innerkits", 109 "${account_iam_framework_path}/test/unittest:account_iam_client_test", 110 "${account_test_common}:account_test_common_source_set", 111 "${common_path}:libaccount_common", 112 "${innerkits_native_path}:account_stub", 113 "${innerkits_native_path}:libaccountkits", 114 "${os_account_innerkits_native_path}:os_account_event_proxy", 115 "${os_account_innerkits_native_path}:os_account_event_stub", 116 "${os_account_innerkits_native_path}:os_account_innerkits", 117 "${os_account_innerkits_native_path}:os_account_state_reply_callback_stub", 118 "${os_account_innerkits_native_path}:os_account_stub", 119 ] 120 deps += [ 121 "${app_account_innerkits_native_path}:app_account_authenticator_callback_stub", 122 "${app_account_innerkits_native_path}:app_account_authenticator_proxy", 123 "${app_account_innerkits_native_path}:app_account_stub", 124 "${domain_account_framework_path}:domain_account_callback_proxy", 125 "${domain_account_framework_path}:domain_account_callback_stub", 126 "${domain_account_framework_path}:domain_account_stub", 127 ] 128 129 external_deps = [ 130 "ability_base:base", 131 "ability_base:want", 132 "ability_runtime:ability_manager", 133 "ability_runtime:app_manager", 134 "access_token:libtokensetproc_shared", 135 "bundle_framework:appexecfwk_base", 136 "bundle_framework:appexecfwk_core", 137 "cJSON:cjson", 138 "c_utils:utils", 139 "common_event_service:cesfwk_innerkits", 140 "config_policy:configpolicy_util", 141 "hilog:libhilog", 142 "ipc:ipc_single", 143 "kv_store:distributeddata_inner", 144 "openssl:libcrypto_shared", 145 "safwk:system_ability_fwk", 146 "samgr:samgr_proxy", 147 ] 148 149 external_deps += [ 150 "ability_runtime:wantagent_innerkits", 151 "access_token:libaccesstoken_sdk", 152 "access_token:libtokenid_sdk", 153 "access_token:libtokensetproc_shared", 154 "hicollie:libhicollie", 155 "hisysevent:libhisysevent", 156 "hitrace:hitrace_meter", 157 "init:libbegetutil", 158 "selinux_adapter:librestorecon", 159 "storage_service:storage_manager_sa_proxy", 160 "user_auth_framework:userauth_client", 161 ] 162 163 if (os_account_distributed_feature) { 164 cflags_cc += [ "-DENABLE_FILE_WATCHER" ] 165 sources += 166 [ "${services_path}/accountmgr/src/account_file_watcher_manager.cpp" ] 167 if (has_huks_part) { 168 external_deps += [ "huks:libhukssdk" ] 169 cflags_cc += [ "-DHAS_HUKS_PART" ] 170 } 171 } 172 173 if (os_account_support_lock_os_account) { 174 cflags_cc += [ "-DSUPPORT_LOCK_OS_ACCOUNT" ] 175 } 176 177 if (os_account_support_domain_accounts) { 178 cflags_cc += [ "-DSUPPORT_DOMAIN_ACCOUNTS" ] 179 } 180 181 if (security_guard_enabled) { 182 external_deps += [ 183 "security_guard:libsg_collect_sdk", 184 "time_service:time_client", 185 ] 186 } 187} 188