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 Field = struct { 24 std::string fieldName; 25 std::string fieldType; 26 std::string value; 27 }; 28 29 using Rule = struct { 30 int64_t eventId; 31 std::vector<Field> fields; 32 std::string fieldsRelation; 33 }; 34 35 using BuildInDetectionCfg = struct { 36 std::vector<Rule> rules; 37 std::string rulesRelation; 38 std::string trueResult; 39 std::string falseResult; 40 }; 41 42 using AppDetectionCfg = struct { 43 std::string detectionCategory; 44 std::string configFileName; 45 std::string trueResult; 46 std::string falseResult; 47 }; 48 49 using ModelCfg = struct { 50 uint32_t modelId; 51 std::string path; 52 std::string format; 53 uint32_t startMode; 54 std::vector<int64_t> preload; 55 std::vector<int64_t> eventList; 56 std::string permissions; 57 std::string dbTable; 58 uint32_t runningCntl; 59 std::vector<std::string> caller; 60 std::string type; 61 BuildInDetectionCfg config; 62 AppDetectionCfg appDetectionConfig; 63 }; 64 65 enum class EventTypeEnum { 66 NORMALE_COLL = 0, 67 QUERY_COLL = 1, 68 START_STOP_COLL = 2, 69 SUBSCRIBE_COLL = 3 70 }; 71 72 using EventCfg = struct { 73 int64_t eventId; 74 std::string eventName; 75 uint32_t version; 76 uint32_t eventType; 77 uint32_t collectOnStart; 78 uint32_t dataSensitivityLevel; 79 uint32_t storageRamNums; 80 uint32_t storageRomNums; 81 int32_t storageTime; 82 std::vector<std::string> owner; 83 uint32_t source; 84 std::string dbTable; 85 std::string prog; 86 }; 87 88 using DataMgrCfgSt = struct { 89 uint32_t deviceRom; 90 uint32_t deviceRam; 91 uint32_t eventMaxRamNum; 92 uint32_t eventMaxRomNum; 93 }; 94 95 using EventContentSt = struct { 96 uint32_t status; 97 uint32_t cred; 98 std::string extra; 99 }; 100 101 using SecEvent = struct { 102 int64_t eventId; 103 std::string version; 104 std::string date; 105 std::string content; 106 int32_t eventType; 107 int32_t dataSensitivityLevel; 108 std::string owner; 109 int32_t userId; 110 std::string deviceId; 111 }; 112 113 using StartMode = enum { 114 NOT_SUPPORT, 115 START_ON_STARTUP, 116 START_ON_DEMAND 117 }; 118 119 using DataSource = enum { 120 USER_SOURCE, 121 KERNEL_SOURCE, 122 MODEL_SOURCE, 123 HIVIEW_SOURCE 124 }; 125 126 using LoadMode = enum { 127 INIT_MODE, 128 UPDATE_MODE 129 }; 130 131 using PathIndex = enum { 132 EVENT_CFG_INDEX, 133 MODEL_CFG_INDEX, 134 SIG_RULE_CFG_INDEX, 135 URL_RULE_CFG_INDEX 136 }; 137 138 const std::vector<std::string> CONFIG_CACHE_FILES = { 139 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/security_guard_event.cfg", 140 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/security_guard_model.cfg", 141 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/signature_rule.cfg", 142 "/data/app/el1/100/base/com.ohos.security.hsdr/cache/security_guard/security_guard/url_rule.cfg" 143 }; 144 145 const std::vector<std::string> CONFIG_UPTATE_FILES = { 146 "/data/service/el1/public/security_guard/security_guard_event.cfg", 147 "/data/service/el1/public/security_guard/security_guard_model.cfg", 148 "/data/service/el1/public/security_guard/signature_rule.cfg", 149 "/data/service/el1/public/security_guard/url_rule.cfg" 150 }; 151 152 const std::vector<std::string> CONFIG_PRESET_FILES = { 153 "/system/etc/security_guard_event.cfg", 154 "/system/etc/security_guard_model.cfg" 155 }; 156 157 const std::string CONFIG_ROOT_PATH = "/data/app/el1/100/base/com.ohos.security.hsdr/cache/"; 158 } // namespace OHOS::Security::SecurityGuard 159 160 #endif // SECURITY_GUARD_CONFIG_DEFINE_H 161