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 #include "bigdata.h"
17
18 #include "hisysevent.h"
19
20 namespace OHOS::Security::SecurityGuard {
21 namespace {
22 constexpr const char* CALLER_PID = "CALLER_PID";
23 constexpr const char* CALL_TIME = "CALL_TIME";
24 constexpr const char* EVENT_SIZE = "EVENT_SIZE";
25 constexpr const char* EVENT_INFO = "EVENT_INFO";
26 constexpr const char* RISK_STATUS = "RISK_STATUS";
27 constexpr const char* EVENT_ID = "EVENT_ID";
28 constexpr const char* SUB_RET = "SUB_RET";
29 constexpr const char* UNSUB_RET = "UNSUB_RET";
30 constexpr const char* CONFIG_PATH = "CONFIG_PATH";
31 constexpr const char* RET = "RET";
32 constexpr const char* FILE_OPERATION = "FILE_OPERATION";
33 constexpr const char* FILE_NAME = "FILE_NAME";
34 constexpr const char* ERR_MSG = "ERR_MSG";
35 }
36
ReportObtainDataEvent(const ObtainDataEvent & event)37 void BigData::ReportObtainDataEvent(const ObtainDataEvent &event)
38 {
39 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "OBTAIN_DATA",
40 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
41 CALL_TIME, event.time, EVENT_SIZE, event.size);
42 }
43
ReportClassifyEvent(const ClassifyEvent & event)44 void BigData::ReportClassifyEvent(const ClassifyEvent &event)
45 {
46 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "RISK_ANALYSIS",
47 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
48 CALL_TIME, event.time, EVENT_INFO, event.eventInfo, RISK_STATUS, event.status);
49 }
50
ReportSgSubscribeEvent(const SgSubscribeEvent & event)51 void BigData::ReportSgSubscribeEvent(const SgSubscribeEvent &event)
52 {
53 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_SUBSCRIBE",
54 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
55 CALL_TIME, event.time, EVENT_ID, event.eventId, SUB_RET, event.ret);
56 }
57
ReportSgUnsubscribeEvent(const SgUnsubscribeEvent & event)58 void BigData::ReportSgUnsubscribeEvent(const SgUnsubscribeEvent &event)
59 {
60 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_UNSUBSCRIBE",
61 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
62 CALL_TIME, event.time, UNSUB_RET, event.ret);
63 }
64
ReportConfigUpdateEvent(const ConfigUpdateEvent & event)65 void BigData::ReportConfigUpdateEvent(const ConfigUpdateEvent &event)
66 {
67 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_UPDATE_CONFIG",
68 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CONFIG_PATH, event.path,
69 CALL_TIME, event.time, RET, event.ret);
70 }
71
ReportSetMuteEvent(const SgSubscribeEvent & event)72 void BigData::ReportSetMuteEvent(const SgSubscribeEvent &event)
73 {
74 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_SET_MUTE",
75 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
76 CALL_TIME, event.time, EVENT_ID, event.eventId, RET, event.ret);
77 }
78
ReportSetUnMuteEvent(const SgSubscribeEvent & event)79 void BigData::ReportSetUnMuteEvent(const SgSubscribeEvent &event)
80 {
81 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_SET_UNMUTE",
82 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid,
83 CALL_TIME, event.time, EVENT_ID, event.eventId, RET, event.ret);
84 }
85
ReportFileSystemStoreEvent(const FileSystemStoreErrMesg & mesg)86 void BigData::ReportFileSystemStoreEvent(const FileSystemStoreErrMesg &mesg)
87 {
88 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_FILE_STORE_ERROE",
89 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, FILE_OPERATION, mesg.operation,
90 FILE_NAME, mesg.fileName, ERR_MSG, mesg.mesg);
91 }
92 }