1# Copyright (c) 2023 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("//base/security/security_guard/security_guard.gni") 15import("//build/ohos.gni") 16 17ohos_shared_library("sg_collect_service") { 18 subsystem_name = "security" 19 part_name = "security_guard" 20 version_script = "sg_collect_service.map" 21 22 configs = [ 23 "${sg_root_dir}/services/risk_classify:security_guard_model_configs", 24 "${sg_root_dir}/resource/config/build:coverage_flags", 25 ] 26 27 defines = [] 28 defines += [ 29 "SECURITY_GUARD_EVENT_CFG_SOURCE = \"${security_guard_event_cfg_source}\"", 30 "SECURITY_GUARD_MODEL_CFG_SOURCE = \"${security_guard_model_cfg_source}\"", 31 "SECURITY_GUARD_EVENT_GROUP_CFG_SOURCE = \"${security_guard_event_group_cfg_source}\"", 32 "SECURITY_GUARD_CONFIG_UPDATE_TRUST_LIST_SOURCE = \"${security_guard_config_update_trust_list_source}\"", 33 "SECURITY_GUARD_COLLECTOR_CFG_SOURCE = \"${security_guard_collector_cfg_source}\"", 34 "SECURITY_GUARD_EVENT_FILTER_PATH = \"${security_guard_event_filter_path}\"", 35 "SECURITY_GUARD_EVENT_WRAPPER_PATH = \"${security_guard_event_wrapper_path}\"", 36 ] 37 if (security_guard_trim_model_analysis) { 38 defines += [ "SECURITY_GUARD_TRIM_MODEL_ANALYSIS" ] 39 } 40 include_dirs = [ 41 "${target_gen_dir}", 42 "${sg_root_dir}/interfaces/inner_api/collect/include", 43 "${sg_root_dir}/frameworks/common/collect/include", 44 "${sg_root_dir}/interfaces/inner_api/collector/include", 45 "${sg_root_dir}/frameworks/common/collector/include", 46 47 "${sg_root_dir}/interfaces/inner_api/common/include", 48 "${sg_root_dir}/interfaces/inner_api/classify/include", 49 "${sg_root_dir}/frameworks/common/classify/include", 50 "${sg_root_dir}/services/bigdata/include", 51 "${sg_root_dir}/services/config_manager/include", 52 "${sg_root_dir}/services/data_collect/sa/include", 53 "${sg_root_dir}/services/data_collect/store/include", 54 "${sg_root_dir}/frameworks/common/constants/include", 55 "${sg_root_dir}/frameworks/common/json/include", 56 "${sg_root_dir}/frameworks/common/task_handler/include", 57 "${sg_root_dir}/frameworks/common/database/include", 58 "${sg_root_dir}/frameworks/common/log/include", 59 "${sg_root_dir}/frameworks/common/utils/include", 60 "${sg_root_dir}/services/collector_manager/include", 61 "${sg_root_dir}/services/risk_classify/model_manager/include", 62 ] 63 64 sources = [ 65 "${sg_root_dir}/frameworks/common/collect/src/security_event_filter.cpp", 66 "${sg_root_dir}/frameworks/common/collector/src/security_collector_event_filter.cpp", 67 "${sg_root_dir}/frameworks/common/collector/src/security_collector_subscribe_info.cpp", 68 "${sg_root_dir}/frameworks/common/json/src/json_cfg.cpp", 69 "${sg_root_dir}/frameworks/common/utils/src/security_guard_utils.cpp", 70 "${sg_root_dir}/services/data_collect/sa/acquire_data_callback_proxy.cpp", 71 "${sg_root_dir}/services/data_collect/sa/acquire_data_subscribe_manager.cpp", 72 "${sg_root_dir}/services/data_collect/sa/data_collect_manager_callback_proxy.cpp", 73 "${sg_root_dir}/services/data_collect/sa/data_collect_manager_service.cpp", 74 "${sg_root_dir}/services/data_collect/sa/data_format.cpp", 75 "${sg_root_dir}/services/data_collect/sa/security_event_query_callback_proxy.cpp", 76 "${sg_root_dir}/services/data_collect/store/src/database_helper.cpp", 77 "${sg_root_dir}/services/data_collect/store/src/database_manager.cpp", 78 "${sg_root_dir}/services/data_collect/store/src/file_system_store_helper.cpp", 79 "${sg_root_dir}/services/data_collect/store/src/risk_event_rdb_helper.cpp", 80 ] 81 82 sanitize = { 83 integer_overflow = true 84 ubsan = true 85 boundary_sanitize = true 86 cfi = true 87 cfi_cross_dso = true 88 debug = false 89 } 90 branch_protector_ret = "pac_ret" 91 92 deps = [ 93 "${sg_root_dir}/frameworks/common/collector:libsg_collector_sdk", 94 "${sg_root_dir}/services/bigdata:sg_bigdata_stamp", 95 "${sg_root_dir}/services/collector_manager:security_collector_manager", 96 "${sg_root_dir}/services/config_manager:sg_config_data_manager", 97 "${sg_root_dir}/services/data_collect:sg_collect_service_database", 98 "${sg_root_dir}/services/data_collect/idl:data_collect_manager_idl_sa_stub", 99 "${sg_root_dir}/services/risk_classify/model_manager:sg_model_manager_stamp", 100 ] 101 102 external_deps = [ 103 "access_token:libaccesstoken_sdk", 104 "access_token:libtokenid_sdk", 105 "c_utils:utils", 106 "ffrt:libffrt", 107 "hilog:libhilog", 108 "hisysevent:libhisysevent", 109 "hisysevent:libhisyseventmanager", 110 "ipc:ipc_core", 111 "json:nlohmann_json_static", 112 "safwk:system_ability_fwk", 113 "samgr:samgr_proxy", 114 "sqlite:sqlite", 115 "zlib:libz", 116 "os_account:os_account_innerkits", 117 ] 118 if (security_guard_enable_device_id) { 119 defines += [ "SECURITY_GUARD_ENABLE_DEVICE_ID" ] 120 external_deps += [ 121 "device_manager:devicemanagersdk", 122 ] 123 } 124} 125 126ohos_shared_library("sg_collect_service_database") { 127 subsystem_name = "security" 128 part_name = "security_guard" 129 130 configs = [ 131 "${sg_root_dir}/services/risk_classify:security_guard_model_configs", 132 "${sg_root_dir}/resource/config/build:coverage_flags", 133 ] 134 135 include_dirs = [ 136 "${sg_root_dir}/frameworks/common/database/include", 137 "${sg_root_dir}/frameworks/common/log/include", 138 "${sg_root_dir}/services/data_collect/store/include", 139 "${sg_root_dir}/interfaces/inner_api/classify/include", 140 "${sg_root_dir}/frameworks/common/classify/include", 141 "${sg_root_dir}/frameworks/common/constants/include", 142 ] 143 144 sources = [ 145 "${sg_root_dir}/services/data_collect/store/src/database.cpp", 146 "${sg_root_dir}/services/data_collect/store/src/generic_values.cpp", 147 "${sg_root_dir}/services/data_collect/store/src/sg_sqlite_helper.cpp", 148 "${sg_root_dir}/services/data_collect/store/src/sqlite_helper.cpp", 149 "${sg_root_dir}/services/data_collect/store/src/statement.cpp", 150 "${sg_root_dir}/services/data_collect/store/src/variant_value.cpp", 151 ] 152 153 sanitize = { 154 integer_overflow = true 155 ubsan = true 156 boundary_sanitize = true 157 cfi = true 158 cfi_cross_dso = true 159 debug = false 160 } 161 branch_protector_ret = "pac_ret" 162 163 deps = [] 164 165 cflags_cc = [ "-DSQLITE_DLCLOSE_ENABLE " ] 166 external_deps = [ 167 "c_utils:utils", 168 "hilog:libhilog", 169 "sqlite:sqlite", 170 ] 171} 172