1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SECURITY_GUARD_CONFIG_DEFINE_H 17 #define SECURITY_GUARD_CONFIG_DEFINE_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS::Security::SecurityGuard { 23 using ModelCfg = struct { 24 uint32_t modelId; 25 std::string path; 26 std::string format; 27 uint32_t startMode; 28 std::vector<int64_t> preload; 29 std::vector<int64_t> eventList; 30 std::string permissions; 31 std::string dbTable; 32 uint32_t runningCntl; 33 std::vector<std::string> caller; 34 }; 35 36 enum class EventTypeEnum { 37 NORMALE_COLL = 0, 38 QUERY_COLL = 1, 39 START_STOP_COLL = 2, 40 SUBSCRIBE_COLL = 3 41 }; 42 43 using EventCfg = struct { 44 int64_t eventId; 45 std::string eventName; 46 uint32_t version; 47 uint32_t eventType; 48 uint32_t collectOnStart; 49 uint32_t dataSensitivityLevel; 50 uint32_t storageRamNums; 51 uint32_t storageRomNums; 52 int32_t storageTime; 53 std::vector<std::string> owner; 54 uint32_t source; 55 std::string dbTable; 56 std::string prog; 57 }; 58 59 using DataMgrCfgSt = struct { 60 uint32_t deviceRom; 61 uint32_t deviceRam; 62 uint32_t eventMaxRamNum; 63 uint32_t eventMaxRomNum; 64 }; 65 66 using EventContentSt = struct { 67 uint32_t status; 68 uint32_t cred; 69 std::string extra; 70 }; 71 72 using SecEvent = struct { 73 int64_t eventId; 74 std::string version; 75 std::string date; 76 std::string content; 77 int32_t eventType; 78 int32_t dataSensitivityLevel; 79 std::string owner; 80 int32_t userId; 81 std::string deviceId; 82 }; 83 84 using StartMode = enum { 85 NOT_SUPPORT, 86 START_ON_STARTUP, 87 START_ON_DEMAND 88 }; 89 90 using AppAttribute = enum { 91 NORMAL, 92 PAYMENT, 93 MALICIOUS, 94 MONITORING, 95 ATTRMAX 96 }; 97 98 using AppInfo = struct { 99 std::string appName; 100 std::string appHash; 101 std::vector<std::string> attrs; 102 int isGlobalApp; 103 int isUpdate; 104 }; 105 106 using DataSource = enum { 107 USER_SOURCE, 108 KERNEL_SOURCE, 109 MODEL_SOURCE, 110 HIVIEW_SOURCE 111 }; 112 113 using LoadMode = enum { 114 INIT_MODE, 115 UPDATE_MODE 116 }; 117 118 using PathIndex = enum { 119 EVENT_CFG_INDEX, 120 MODEL_CFG_INDEX 121 }; 122 123 const std::vector<std::string> CONFIG_CACHE_FILES = { 124 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/security_guard_event.cfg", 125 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/security_guard_model.cfg" 126 }; 127 128 const std::vector<std::string> CONFIG_UPTATE_FILES = { 129 "/data/service/el1/public/security_guard/security_guard_event.cfg", 130 "/data/service/el1/public/security_guard/security_guard_model.cfg" 131 }; 132 133 const std::vector<std::string> CONFIG_PRESET_FILES = { 134 "/system/etc/security_guard_event.cfg", 135 "/system/etc/security_guard_model.cfg" 136 }; 137 138 const std::string CONFIG_ROOT_PATH = "/data/app/el1/100/base/com.ohos.security.hsdr/cache/"; 139 } // namespace OHOS::Security::SecurityGuard 140 141 #endif // SECURITY_GUARD_CONFIG_DEFINE_H 142