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 DataMgrCfgSt = struct { 73 uint32_t deviceRom; 74 uint32_t deviceRam; 75 uint32_t eventMaxRamNum; 76 uint32_t eventMaxRomNum; 77 std::string prog; 78 }; 79 80 using EventContentSt = struct { 81 uint32_t status; 82 uint32_t cred; 83 std::string extra; 84 }; 85 86 using SecEvent = struct { 87 int64_t eventId; 88 std::string version; 89 std::string date; 90 std::string content; 91 int32_t eventType; 92 int32_t dataSensitivityLevel; 93 std::string owner; 94 int32_t userId; 95 std::string deviceId; 96 }; 97 98 using StartMode = enum { 99 NOT_SUPPORT, 100 START_ON_STARTUP, 101 START_ON_DEMAND 102 }; 103 104 using DataSource = enum { 105 USER_SOURCE, 106 KERNEL_SOURCE, 107 MODEL_SOURCE, 108 HIVIEW_SOURCE 109 }; 110 111 using LoadMode = enum { 112 INIT_MODE, 113 UPDATE_MODE 114 }; 115 116 using PathIndex = enum { 117 EVENT_CFG_INDEX, 118 MODEL_CFG_INDEX, 119 SIG_RULE_CFG_INDEX, 120 URL_RULE_CFG_INDEX, 121 RELATED_EVENT_ANALYSIS_CFG_INDEX 122 }; 123 124 const std::vector<std::string> CONFIG_CACHE_FILES = { 125 "/data/test/unittest/resource/security_guard/security_guard/security_guard_cache_event.cfg", 126 "/data/test/unittest/resource/security_guard/security_guard/security_guard_cache_model.cfg", 127 }; 128 129 const std::vector<std::string> CONFIG_UPTATE_FILES = { 130 "/data/test/unittest/resource/security_guard_update_event.cfg", 131 "/data/test/unittest/resource/security_guard_update_model.cfg", 132 }; 133 134 const std::vector<std::string> CONFIG_PRESET_FILES = { 135 "/data/test/unittest/resource/security_guard_preset_event.cfg", 136 "/data/test/unittest/resource/security_guard_preset_model.cfg" 137 }; 138 139 const std::string CONFIG_ROOT_PATH = "/data/test/unittest/resource/"; 140 } // namespace OHOS::Security::SecurityGuard 141 142 #endif // SECURITY_GUARD_CONFIG_DEFINE_H 143