From fbfe52cfef07af1aa64b8244902b619aeef8d0ca Mon Sep 17 00:00:00 2001 From: xxx Date: Wed, 12 Jul 2023 16:07:06 +0800 Subject: [PATCH] =?UTF-8?q?Description:=20=E6=B7=BB=E5=8A=A0log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match-id-8cf7c93aa5a6aa13f83ca66707aaac325f23f799 --- .../sa/sa_main/sec_comp_entity.cpp | 13 +++++++++++++ .../sa/sa_main/sec_comp_manager.cpp | 15 ++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp index 03977d5..58d6291 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp @@ -14,7 +14,10 @@ */ #include "sec_comp_entity.h" #include +#include "hisysevent.h" +#include "ipc_skeleton.h" #include "sec_comp_err.h" +#include "sec_comp_enhance_adapter.h" #include "sec_comp_info_helper.h" #include "sec_comp_log.h" @@ -62,6 +65,16 @@ bool SecCompEntity::CheckTouchInfo(const SecCompClickEvent& touchInfo) const SC_LOG_ERROR(LABEL, "touch point is not in component rect"); return false; } + + if (SecCompEnhanceAdapter::CheckExtraInfo(touchInfo) != SC_OK) { + SC_LOG_ERROR(LABEL, "HMAC checkout failed" + "touchX:%{public}f, touchY:%{public}f, timestamp:%{public}lu, dataSize:%{public}d", + touchInfo.touchX, touchInfo.touchY, touchInfo.timestamp, touchInfo.extraInfo.dataSize); + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", + HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", IPCSkeleton::GetCallingUid(), + "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId_, "SC_TYPE", componentInfo_->type_); + return false; + } return true; } } // namespace SecurityComponent diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index ec4e634..312ed23 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -285,7 +285,7 @@ int32_t SecCompManager::RegisterSecurityComponent(SecCompType type, const nlohmann::json& jsonComponent, const SecCompCallerInfo& caller, int32_t& scId) { DelayExitTask::GetInstance().Stop(); - + SC_LOG_DEBUG(LABEL, "PID: %{public}d, register security component", caller.pid); if (IsInMaliciousAppList(caller.pid)) { SC_LOG_ERROR(LABEL, "app is in MaliciousAppList, never allow it"); return SC_ENHANCE_ERROR_IN_MALICIOUS_LIST; @@ -326,6 +326,7 @@ int32_t SecCompManager::RegisterSecurityComponent(SecCompType type, int32_t SecCompManager::UpdateSecurityComponent(int32_t scId, const nlohmann::json& jsonComponent, const SecCompCallerInfo& caller) { + SC_LOG_DEBUG(LABEL, "PID: %{public}d, update security component", caller.pid); if (IsInMaliciousAppList(caller.pid)) { SC_LOG_ERROR(LABEL, "app is in MaliciousAppList, never allow it"); return SC_ENHANCE_ERROR_IN_MALICIOUS_LIST; @@ -363,6 +364,7 @@ int32_t SecCompManager::UpdateSecurityComponent(int32_t scId, const nlohmann::js int32_t SecCompManager::UnregisterSecurityComponent(int32_t scId, const SecCompCallerInfo& caller) { + SC_LOG_DEBUG(LABEL, "PID: %{public}d, unregister security component", caller.pid); if (scId < 0) { SC_LOG_ERROR(LABEL, "ScId is invalid"); return SC_SERVICE_ERROR_VALUE_INVALID; @@ -420,22 +422,13 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, return res; } - if (SecCompEnhanceAdapter::CheckExtraInfo(touchInfo) != SC_OK) { - SC_LOG_ERROR(LABEL, "check extra info failed, HMAC is invalid"); + if (!sc->CheckTouchInfo(touchInfo)) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", IPCSkeleton::GetCallingUid(), "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId, "SC_TYPE", sc->GetType()); AddAppToMaliciousAppList(caller.pid); return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } - - if (!sc->CheckTouchInfo(touchInfo)) { - SC_LOG_ERROR(LABEL, "touchInfo is invalid"); - HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", - HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", IPCSkeleton::GetCallingUid(), - "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId, "SC_TYPE", sc->GetType()); - return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; - } res = sc->GrantTempPermission(); if (res != SC_OK) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "TEMP_GRANT_FAILED",