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