1# Copyright (c) 2023-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. 13 14import("//build/config/features.gni") 15import("//build/ohos.gni") 16import("//build/test.gni") 17import("../../../common/config/common.gni") 18module_output_path = "enterprise_device_management/enterprise_device_management" 19 20config("module_private_config") { 21 visibility = [ ":*" ] 22 include_dirs = [ "../" ] 23} 24 25config("edm_config") { 26 visibility = [ ":*" ] 27 include_dirs = [ 28 "../../../services/edm/include", 29 "../../../services/edm/include/connection", 30 "../../../services/edm/include/database", 31 "../../../services/edm/include/strategy", 32 "../../../services/edm_plugin/include/utils", 33 "../../../framework/extension/include", 34 "../../../services/edm_plugin/include", 35 "../../../services/edm_plugin/include/network", 36 "../../../services/edm_plugin/include/network/executer", 37 "../../../services/edm_plugin/include/network/rule", 38 "../../../services/edm_plugin/include/utils", 39 ] 40} 41 42ohos_static_library("edmservice_fuzz_static") { 43 testonly = true 44 sources = [ 45 "../../../services/edm/src/admin.cpp", 46 "../../../services/edm/src/admin_manager.cpp", 47 "../../../services/edm/src/admin_policies_storage_rdb.cpp", 48 "../../../services/edm/src/application_state_observer.cpp", 49 "../../../services/edm/src/connection/enterprise_admin_connection.cpp", 50 "../../../services/edm/src/connection/enterprise_admin_proxy.cpp", 51 "../../../services/edm/src/connection/enterprise_bundle_connection.cpp", 52 "../../../services/edm/src/connection/enterprise_conn_manager.cpp", 53 "../../../services/edm/src/connection/enterprise_update_connection.cpp", 54 "../../../services/edm/src/database/edm_rdb_data_manager.cpp", 55 "../../../services/edm/src/database/edm_rdb_open_callback.cpp", 56 "../../../services/edm/src/device_policies_storage_rdb.cpp", 57 "../../../services/edm/src/enterprise_device_mgr_ability.cpp", 58 "../../../services/edm/src/enterprise_device_mgr_stub.cpp", 59 "../../../services/edm/src/permission_manager.cpp", 60 "../../../services/edm/src/plugin_manager.cpp", 61 "../../../services/edm/src/policy_manager.cpp", 62 "../../../services/edm/src/strategy/enhance_execute_strategy.cpp", 63 "../../../services/edm/src/strategy/replace_execute_strategy.cpp", 64 "../../../services/edm/src/strategy/single_execute_strategy.cpp", 65 "../../../services/edm/src/user_policy_manager.cpp", 66 "../../../services/edm_plugin/src/utils/install_param_serializer.cpp", 67 "../../../services/edm_plugin/src/utils/installer_callback.cpp", 68 "../../../services/edm_plugin/src/utils/operate_device_param_serializer.cpp", 69 "../../../services/edm_plugin/src/utils/password_policy_serializer.cpp", 70 "../../../services/edm_plugin/src/utils/uninstall_param_serializer.cpp", 71 ] 72 73 public_configs = [ 74 ":edm_config", 75 "../../../common/config:coverage_flags", 76 ] 77 78 defines = [] 79 80 if (target_cpu == "arm64") { 81 defines += [ "_ARM64_" ] 82 print("defines _ARM64_") 83 } 84 85 if (target_cpu == "x86_64") { 86 defines += [ "_X86_64_" ] 87 print("defines _X86_64_") 88 } 89 90 defines += [ "EDM_FUZZ_TEST" ] 91 defines += [ "COMMON_EVENT_SERVICE_EDM_ENABLE" ] 92 93 public_external_deps = [ 94 "ability_base:want", 95 "ability_runtime:app_manager", 96 "ability_runtime:extension_manager", 97 "ability_runtime:wantagent_innerkits", 98 "access_token:libaccesstoken_sdk", 99 "access_token:libtokenid_sdk", 100 "bundle_framework:appexecfwk_base", 101 "bundle_framework:appexecfwk_core", 102 "cJSON:cjson", 103 "c_utils:utils", 104 "hilog:libhilog", 105 "init:libbegetutil", 106 "ipc:ipc_core", 107 "jsoncpp:jsoncpp", 108 "relational_store:native_rdb", 109 "safwk:system_ability_fwk", 110 ] 111 112 external_deps = [ 113 "ability_base:want", 114 "ability_runtime:app_manager", 115 "ability_runtime:extension_manager", 116 "access_token:libaccesstoken_sdk", 117 "access_token:libtokenid_sdk", 118 "bundle_framework:appexecfwk_base", 119 "cJSON:cjson", 120 "c_utils:utils", 121 "common_event_service:cesfwk_innerkits", 122 "hilog:libhilog", 123 "init:libbegetutil", 124 "ipc:ipc_core", 125 "jsoncpp:jsoncpp", 126 "relational_store:native_rdb", 127 "safwk:system_ability_fwk", 128 "user_auth_framework:userauth_client", 129 ] 130 131 deps = [ 132 "../../../common/external:edm_external_adapters", 133 "../../../common/native:edm_commom", 134 "../../../interfaces/inner_api:edmservice_kits", 135 "../../../interfaces/inner_api/plugin_kits:plugin_kits", 136 ] 137 138 if (enterprise_device_management_support_all) { 139 defines += [ "EDM_SUPPORT_ALL_ENABLE" ] 140 sources += [ 141 "../../../services/edm_plugin/src/allowed_install_bundles_plugin.cpp", 142 "../../../services/edm_plugin/src/bundle_install_plugin.cpp", 143 "../../../services/edm_plugin/src/disallow_modify_datetime_plugin.cpp", 144 "../../../services/edm_plugin/src/disallowed_install_bundles_plugin.cpp", 145 "../../../services/edm_plugin/src/disallowed_uninstall_bundles_plugin.cpp", 146 "../../../services/edm_plugin/src/get_device_encryption_status_plugin.cpp", 147 "../../../services/edm_plugin/src/get_device_info_plugin.cpp", 148 "../../../services/edm_plugin/src/get_display_version_plugin.cpp", 149 "../../../services/edm_plugin/src/get_security_patch_tag_plugin.cpp", 150 "../../../services/edm_plugin/src/install_plugin.cpp", 151 "../../../services/edm_plugin/src/ntp_server_plugin.cpp", 152 "../../../services/edm_plugin/src/operate_device_plugin.cpp", 153 "../../../services/edm_plugin/src/password_policy_plugin.cpp", 154 "../../../services/edm_plugin/src/power_policy_plugin.cpp", 155 "../../../services/edm_plugin/src/screen_off_time_plugin.cpp", 156 "../../../services/edm_plugin/src/uninstall_plugin.cpp", 157 ] 158 159 if (os_account_edm_enable) { 160 external_deps += [ 161 "os_account:libaccountkits", 162 "os_account:os_account_innerkits", 163 ] 164 public_external_deps += [ 165 "os_account:libaccountkits", 166 "os_account:os_account_innerkits", 167 ] 168 sources += [ 169 "../../../services/edm_plugin/src/add_os_account_plugin.cpp", 170 "../../../services/edm_plugin/src/disallow_add_local_account_plugin.cpp", 171 "../../../services/edm_plugin/src/disallow_add_os_account_by_user_plugin.cpp", 172 ] 173 defines += [ "OS_ACCOUNT_EDM_ENABLE" ] 174 } 175 176 if (screenlock_mgr_edm_enable) { 177 external_deps += [ "screenlock_mgr:screenlock_client" ] 178 public_external_deps += [ "screenlock_mgr:screenlock_client" ] 179 sources += [ "../../../services/edm_plugin/src/lock_screen_plugin.cpp" ] 180 } 181 182 if (power_manager_edm_enable && screenlock_mgr_edm_enable) { 183 external_deps += [ "power_manager:powermgr_client" ] 184 public_external_deps += [ "power_manager:powermgr_client" ] 185 sources += [ 186 "../../../services/edm_plugin/src/reboot_plugin.cpp", 187 "../../../services/edm_plugin/src/shutdown_plugin.cpp", 188 ] 189 } 190 191 if (update_service_edm_enable) { 192 external_deps += [ "update_service:updateservicekits" ] 193 public_external_deps += [ "update_service:updateservicekits" ] 194 sources += [ "../../../services/edm_plugin/src/reset_factory_plugin.cpp" ] 195 } 196 197 if (wifi_edm_enable) { 198 external_deps += [ "wifi:wifi_sdk" ] 199 public_external_deps += [ "wifi:wifi_sdk" ] 200 sources += [ 201 "../../../services/edm_plugin/src/is_wifi_active_plugin.cpp", 202 "../../../services/edm_plugin/src/set_wifi_disabled_plugin.cpp", 203 "../../../services/edm_plugin/src/set_wifi_profile_plugin.cpp", 204 "../../../services/edm_plugin/src/utils/wifi_device_config_serializer.cpp", 205 ] 206 defines += [ "WIFI_EDM_ENABLE" ] 207 } 208 209 if (netmanager_base_edm_enable && netmanager_ext_edm_enable) { 210 external_deps += [ 211 "netmanager_base:net_conn_manager_if", 212 "netmanager_base:netsys_controller", 213 "netmanager_ext:ethernet_manager_if", 214 ] 215 public_external_deps += [ 216 "netmanager_base:net_conn_manager_if", 217 "netmanager_base:netsys_controller", 218 "netmanager_ext:ethernet_manager_if", 219 ] 220 sources += [ 221 "../../../services/edm_plugin/src/disabled_network_interface_plugin.cpp", 222 "../../../services/edm_plugin/src/domain_filter_rule_plugin.cpp", 223 "../../../services/edm_plugin/src/firewall_rule_plugin.cpp", 224 "../../../services/edm_plugin/src/get_all_network_interfaces_plugin.cpp", 225 "../../../services/edm_plugin/src/get_ip_address_plugin.cpp", 226 "../../../services/edm_plugin/src/get_mac_plugin.cpp", 227 "../../../services/edm_plugin/src/global_proxy_plugin.cpp", 228 "../../../services/edm_plugin/src/iptables_rule_plugin.cpp", 229 "../../../services/edm_plugin/src/network/executer/domain_executer.cpp", 230 "../../../services/edm_plugin/src/network/executer/executer_factory.cpp", 231 "../../../services/edm_plugin/src/network/executer/executer_utils.cpp", 232 "../../../services/edm_plugin/src/network/executer/firewall_executer.cpp", 233 "../../../services/edm_plugin/src/network/executer/iexecuter.cpp", 234 "../../../services/edm_plugin/src/network/iptables_manager.cpp", 235 "../../../services/edm_plugin/src/network/rule/chain_rule.cpp", 236 "../../../services/edm_plugin/src/network/rule/domain_chain_rule.cpp", 237 "../../../services/edm_plugin/src/network/rule/firewall_chain_rule.cpp", 238 "../../../services/edm_plugin/src/network/rule/rule_utils.cpp", 239 "../../../services/edm_plugin/src/utils/domain_filter_rule_serializer.cpp", 240 "../../../services/edm_plugin/src/utils/firewall_rule_serializer.cpp", 241 "../../../services/edm_plugin/src/utils/http_proxy_serializer.cpp", 242 ] 243 } 244 245 if (ability_runtime_edm_enable) { 246 external_deps += [ "ability_runtime:ability_manager" ] 247 public_external_deps += [ "ability_runtime:ability_manager" ] 248 sources += [ 249 "../../../services/edm_plugin/src/disallowed_running_bundles_plugin.cpp", 250 "../../../services/edm_plugin/src/manage_auto_start_apps_plugin.cpp", 251 ] 252 } 253 254 if (certificate_manager_edm_enable) { 255 external_deps += [ "certificate_manager:cert_manager_sdk" ] 256 public_external_deps += [ "certificate_manager:cert_manager_sdk" ] 257 sources += [ "../../../services/edm_plugin/src/user_cert_plugin.cpp" ] 258 } 259 260 if (drivers_interface_usb_edm_enable && usb_manager_edm_enable) { 261 external_deps += [ "usb_manager:usbsrv_client" ] 262 public_external_deps += [ "usb_manager:usbsrv_client" ] 263 sources += [ 264 "../../../services/edm_plugin/src/allowed_usb_devices_plugin.cpp", 265 "../../../services/edm_plugin/src/disable_usb_plugin.cpp", 266 "../../../services/edm_plugin/src/utils/array_usb_device_id_serializer.cpp", 267 "../../../services/edm_plugin/src/utils/array_usb_device_type_serializer.cpp", 268 "../../../services/edm_plugin/src/utils/usb_policy_utils.cpp", 269 ] 270 } 271 272 if (drivers_interface_usb_edm_enable && storage_service_edm_enable && 273 usb_manager_edm_enable) { 274 external_deps += [ "storage_service:storage_manager_sa_proxy" ] 275 public_external_deps += [ "storage_service:storage_manager_sa_proxy" ] 276 sources += [ "../../../services/edm_plugin/src/usb_read_only_plugin.cpp" ] 277 } 278 279 if (audio_framework_edm_enable) { 280 external_deps += [ "audio_framework:audio_client" ] 281 public_external_deps += [ "audio_framework:audio_client" ] 282 sources += [ 283 "../../../services/edm_plugin/src/disable_hdc_plugin.cpp", 284 "../../../services/edm_plugin/src/disable_microphone_plugin.cpp", 285 "../../../services/edm_plugin/src/disable_printer_plugin.cpp", 286 "../../../services/edm_plugin/src/fingerprint_auth_plugin.cpp", 287 ] 288 } 289 290 if (common_event_service_edm_enable) { 291 external_deps += [ "common_event_service:cesfwk_innerkits" ] 292 public_external_deps += [ "common_event_service:cesfwk_innerkits" ] 293 sources += 294 [ "../../../services/edm_plugin/src/set_browser_policies_plugin.cpp" ] 295 defines += [ "COMMON_EVENT_SERVICE_EDM_ENABLE" ] 296 } 297 298 if (bluetooth_edm_enable) { 299 external_deps += [ "bluetooth:btframework" ] 300 public_external_deps += [ "bluetooth:btframework" ] 301 sources += [ 302 "../../../services/edm_plugin/src/allowed_bluetooth_devices_plugin.cpp", 303 "../../../services/edm_plugin/src/disable_bluetooth_plugin.cpp", 304 "../../../services/edm_plugin/src/get_bluetooth_info_plugin.cpp", 305 ] 306 } 307 308 if (location_edm_enable) { 309 external_deps += [ "location:locator_sdk" ] 310 public_external_deps += [ "location:locator_sdk" ] 311 sources += 312 [ "../../../services/edm_plugin/src/location_policy_plugin.cpp" ] 313 } 314 315 if (telephony_core_edm_enable) { 316 external_deps += [ "core_service:tel_core_service_api" ] 317 public_external_deps += [ "core_service:tel_core_service_api" ] 318 defines += [ "TELEPHONY_CORE_EDM_ENABLE" ] 319 } 320 } 321 322 if (pasteboard_edm_enable) { 323 external_deps += [ "pasteboard:pasteboard_client" ] 324 sources += [ 325 "../../../services/edm_plugin/src/utils/clipboard_policy_serializer.cpp", 326 "../../../services/edm_plugin/src/utils/clipboard_utils.cpp", 327 ] 328 } 329 330 sanitize = { 331 boundary_sanitize = true 332 cfi = true 333 cfi_cross_dso = true 334 debug = false 335 integer_overflow = true 336 ubsan = true 337 } 338 branch_protector_ret = "pac_ret" 339 subsystem_name = "customization" 340 part_name = "enterprise_device_management" 341} 342 343ohos_fuzztest("EnterpriseDeviceMgrStubMockFuzzTest") { 344 module_out_path = module_output_path 345 346 fuzz_config_file = "." 347 348 cflags = [ 349 "-g", 350 "-fno-omit-frame-pointer", 351 ] 352 353 include_dirs = [ 354 "../common/include", 355 "../../unittest/utils/include", 356 "../../../interfaces/inner_api/common/include", 357 "../../../interfaces/inner_api/device_settings/include", 358 ] 359 360 sources = [ 361 "../common/src/common_fuzzer.cpp", 362 "enterprise_device_mgr_stub_mock_fuzzer.cpp", 363 ] 364 365 configs = [ "../../../common/config:coverage_flags" ] 366 367 deps = [ 368 ":edmservice_fuzz_static", 369 "../../../common/external:edm_external_adapters", 370 "../../../common/native:edm_commom", 371 "../../../interfaces/inner_api/plugin_kits:plugin_kits", 372 "../../unittest/utils:edm_unittest_utils", 373 ] 374 375 external_deps = [ 376 "ability_base:want", 377 "ability_runtime:app_manager", 378 "access_token:libaccesstoken_sdk", 379 "access_token:libnativetoken", 380 "access_token:libtoken_setproc", 381 "bundle_framework:appexecfwk_base", 382 "bundle_framework:appexecfwk_core", 383 "c_utils:utils", 384 "hilog:libhilog", 385 "init:libbegetutil", 386 "ipc:ipc_core", 387 "relational_store:native_rdb", 388 "safwk:system_ability_fwk", 389 "samgr:samgr_proxy", 390 ] 391 392 subsystem_name = "customization" 393 part_name = "enterprise_device_management" 394} 395