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 AppAttribute = enum {
73     NORMAL,
74     PAYMENT,
75     MALICIOUS,
76     MONITORING,
77     ATTRMAX
78 };
79 
80 using AppInfo = struct {
81     std::string appName;
82     std::string appHash;
83     std::vector<std::string> attrs;
84     int isGlobalApp;
85     int isUpdate;
86 };
87 
88 using SecEvent = struct {
89     int64_t eventId;
90     std::string version;
91     std::string date;
92     std::string content;
93     int32_t eventType;
94     int32_t dataSensitivityLevel;
95     std::string owner;
96     int32_t userId;
97     std::string deviceId;
98 };
99 
100 using StartMode = enum {
101     NOT_SUPPORT,
102     START_ON_STARTUP,
103     START_ON_DEMAND
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/service/el1/public/security_guard/tmp/security_guard_event.cfg",
125     "/data/service/el1/public/security_guard/tmp/security_guard_model.cfg",
126     "/data/service/el1/public/security_guard/tmp/signature_rule.cfg",
127     "/data/service/el1/public/security_guard/tmp/url_rule.cfg",
128     "/data/service/el1/public/security_guard/tmp/local_app_attribute.json",
129     "/data/service/el1/public/security_guard/tmp/global_app_attribute.json",
130     "/data/service/el1/public/security_guard/tmp/related_event_analysis.json"
131 };
132 
133 const std::vector<std::string> CONFIG_UPTATE_FILES = {
134     "/data/service/el1/public/security_guard/security_guard_event.cfg",
135     "/data/service/el1/public/security_guard/security_guard_model.cfg",
136     "/data/service/el1/public/security_guard/signature_rule.cfg",
137     "/data/service/el1/public/security_guard/url_rule.cfg",
138     "/data/service/el1/public/security_guard/local_app_attr.json",
139     "/data/service/el1/public/security_guard/global_app_attr.json",
140     "/data/service/el1/public/security_guard/related_event_analysis.json"
141 };
142 
143 const std::vector<std::string> CONFIG_PRESET_FILES = {
144     "/system/etc/security_guard_event.cfg",
145     "/system/etc/security_guard_model.cfg"
146 };
147 
148 const std::string CONFIG_ROOT_PATH = "/data/service/el1/public/security_guard/";
149 } // namespace OHOS::Security::SecurityGuard
150 
151 #endif // SECURITY_GUARD_CONFIG_DEFINE_H
152