1 /*
2  * Copyright (c) 2022 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_DEFINE_H
17 #define SECURITY_GUARD_DEFINE_H
18 
19 #include <string>
20 
21 namespace OHOS::Security::SecurityGuard {
22 using ErrorCode = enum {
23     SUCCESS,
24     FAILED,
25     NO_PERMISSION,
26     NO_SYSTEMCALL,
27     STREAM_ERROR,
28     FILE_ERR,
29     BAD_PARAM,
30     JSON_ERR,
31     NULL_OBJECT,
32     TIME_OUT,
33     NOT_FOUND,
34     TASK_ERR,
35     READ_ERR,
36     WRITE_ERR,
37     DB_CHECK_ERR,
38     DB_LOAD_ERR,
39     DB_OPT_ERR,
40     DB_INFO_ERR,
41     DUPLICATE,
42 };
43 
44 using SecurityModel = struct {
45     std::string devId;
46     uint32_t modelId;
47     std::string param;
48     std::string result;
49 };
50 
51 using ObatinDataEvent = struct {
52     int32_t pid;
53     std::string time;
54     int32_t size;
55     std::string extend;
56 };
57 
58 using ClassifyEvent = struct {
59     int32_t pid;
60     std::string time;
61     std::string eventInfo;
62     std::string status;
63     std::string extend;
64 };
65 
66 using SgSubscribeEvent = struct {
67     int32_t pid;
68     std::string time;
69     int64_t eventId;
70     int32_t ret;
71     std::string extend;
72 };
73 
74 using SgUnsubscribeEvent = struct {
75     int32_t pid;
76     std::string time;
77     int32_t ret;
78     std::string extend;
79 };
80 
81 using ConfigUpdateEvent = struct {
82     std::string path;
83     std::string time;
84     int32_t ret;
85 };
86 
87 using RequestCondition = struct {
88     std::vector<int64_t> riskEvent;
89     std::vector<int64_t> auditEvent;
90     std::string beginTime;
91     std::string endTime;
92 };
93 
94 using RequestRiskDataCallback = std::function<int32_t(std::string &, std::string &, uint32_t, const std::string &)>;
95 using ResultCallback = std::function<int32_t (const std::string &devId, uint32_t modelId, const std::string &result)>;
96 
97 const size_t MAX_QUERY_EVENT_SIZE = 1000;
98 } // namespace OHOS::Security::SecurityGuard
99 
100 #endif // SECURITY_GUARD_DEFINE_H
101