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 DataMgrCfgSt = struct {
44     uint32_t deviceRom;
45     uint32_t deviceRam;
46     uint32_t eventMaxRamNum;
47     uint32_t eventMaxRomNum;
48     std::string prog;
49 };
50 
51 using EventContentSt = struct {
52     uint32_t status;
53     uint32_t cred;
54     std::string extra;
55 };
56 
57 using SecEvent = struct {
58     int64_t eventId;
59     std::string version;
60     std::string date;
61     std::string content;
62     int32_t eventType;
63     int32_t dataSensitivityLevel;
64     std::string owner;
65     int32_t userId;
66     std::string deviceId;
67 };
68 
69 using StartMode = enum {
70     NOT_SUPPORT,
71     START_ON_STARTUP,
72     START_ON_DEMAND
73 };
74 
75 using DataSource = enum {
76     USER_SOURCE,
77     KERNEL_SOURCE,
78     MODEL_SOURCE,
79     HIVIEW_SOURCE
80 };
81 
82 using LoadMode = enum {
83     INIT_MODE,
84     UPDATE_MODE
85 };
86 
87 using PathIndex = enum {
88     EVENT_CFG_INDEX,
89     MODEL_CFG_INDEX
90 };
91 
92 const std::vector<std::string> CONFIG_CACHE_FILES = {
93     "/data/service/el1/public/security_guard/test/tmp/security_guard_event.json",
94     "/data/service/el1/public/security_guard/test/tmp/security_guard_model.cfg",
95 };
96 
97 const std::vector<std::string> CONFIG_UPTATE_FILES = {
98     "/data/service/el1/public/security_guard/security_guard_event.json",
99     "/data/service/el1/public/security_guard/security_guard_model.cfg",
100 };
101 
102 const std::vector<std::string> CONFIG_PRESET_FILES = {
103     "/system/etc/security_guard_event.json",
104     "/system/etc/security_guard_model.cfg"
105 };
106 
107 const std::string CONFIG_ROOT_PATH = "/data/service/el1/public/security_guard/test/";
108 } // namespace OHOS::Security::SecurityGuard
109 
110 #endif // SECURITY_GUARD_CONFIG_DEFINE_H
111