diff --git a/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp index 7ce03fcb382be0cefd174e280d900555bd7bb472..353667672847c4f3492f8ab7b5102dfa2fdc39e9 100644 --- a/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp +++ b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp @@ -73,6 +73,9 @@ void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) @@ -131,6 +134,9 @@ void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) @@ -189,6 +195,9 @@ void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } } // namespace SecurityComponent } // namespace Security diff --git a/frameworks/security_component/src/sec_comp_base.cpp b/frameworks/security_component/src/sec_comp_base.cpp index 3d121ec00930cf2835908eb91d1b51eba54eee78..468b96e8429a014b90a992c1cf2527ea27ad3093 100644 --- a/frameworks/security_component/src/sec_comp_base.cpp +++ b/frameworks/security_component/src/sec_comp_base.cpp @@ -64,6 +64,28 @@ const std::string JsonTagConstants::JSON_BG_TAG = "bg"; const std::string JsonTagConstants::JSON_WINDOW_ID = "windowId"; const std::string JsonTagConstants::JSON_DISPLAY_ID = "displayId"; const std::string JsonTagConstants::JSON_CROSS_AXIS_STATE = "crossAxisState"; +const std::string JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG = "hasNonCompatileChange"; +const std::string JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG = "blurRadius"; +const std::string JsonTagConstants::JSON_IS_BORDER_COVERED_TAG = "isBorderCovered"; + +bool SecCompBase::ParseNonCompatibleChange(const nlohmann::json& json) +{ + std::string tag = JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG; + if ((json.find(tag) == json.end()) || !json.at(tag).is_boolean()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + hasNonCompatileChange_ = json.at(tag).get(); + + if (!ParseDimension(json, JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG, blurRadius_)) { + return false; + } + if (!ParseBool(json, JsonTagConstants::JSON_IS_BORDER_COVERED_TAG, isBorderCovered_)) { + return false; + } + + return true; +} bool SecCompBase::ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res) { @@ -341,6 +363,7 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) if (!ParseCrossAxisState(jsonSrc, JsonTagConstants::JSON_CROSS_AXIS_STATE)) { return false; } + ParseNonCompatibleChange(jsonSrc); return true; } @@ -402,6 +425,9 @@ void SecCompBase::ToJson(nlohmann::json& jsonRes) const jsonRes[JsonTagConstants::JSON_WINDOW_ID] = windowId_; jsonRes[JsonTagConstants::JSON_DISPLAY_ID] = displayId_; jsonRes[JsonTagConstants::JSON_CROSS_AXIS_STATE] = crossAxisState_; + jsonRes[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = hasNonCompatileChange_; + jsonRes[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = blurRadius_; + jsonRes[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = isBorderCovered_; } std::string SecCompBase::ToJsonStr() const diff --git a/interfaces/inner_api/security_component/include/sec_comp_base.h b/interfaces/inner_api/security_component/include/sec_comp_base.h index 44b493a78ec5ca1884665ca180a7730d245a220d..3f2949c7d39f188cef39f855ef6ce368f62cd458 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_base.h +++ b/interfaces/inner_api/security_component/include/sec_comp_base.h @@ -80,6 +80,9 @@ public: static const std::string JSON_WINDOW_ID; static const std::string JSON_DISPLAY_ID; static const std::string JSON_CROSS_AXIS_STATE; + static const std::string JSON_NON_COMPATIBLE_CHANGE_TAG; + static const std::string JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG; + static const std::string JSON_IS_BORDER_COVERED_TAG; }; class __attribute__((visibility("default"))) SecCompBase { @@ -132,6 +135,9 @@ public: int32_t icon_ = UNKNOWN_ICON; SecCompBackground bg_ = SecCompBackground::UNKNOWN_BG; + bool hasNonCompatileChange_ = false; + double blurRadius_ = 0.0; + bool isBorderCovered_ = false; int32_t windowId_ = 0; uint64_t displayId_ = 0; int32_t nodeId_ = 0; @@ -140,6 +146,7 @@ protected: virtual bool IsTextIconTypeValid() = 0; virtual bool IsCorrespondenceType() = 0; private: + bool ParseNonCompatibleChange(const nlohmann::json& json); bool ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res); bool ParseColor(const nlohmann::json& json, const std::string& tag, SecCompColor& res); bool ParseBool(const nlohmann::json& json, const std::string& tag, bool& res); 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 944f141c39f890a131b59e0286bc604be84f236b..88ae01b040c434fb9961efb1d863a689440b3711 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 @@ -457,7 +457,7 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(std::shared_ptrGetType()); return SC_SERVICE_ERROR_COMPONENT_INFO_INVALID; } - if (report && (report->isClipped_)) { + if (report && (report->isClipped_ || report->hasNonCompatileChange_)) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLIP_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_BUNDLE_NAME", bundleName, "COMPONENT_INFO", jsonComponent.dump().c_str()); diff --git a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp index 75db0fce98012b4220dc9e09c4ab0862def7688f..65e39c5fe7283974362895abcb82d5d629cc1916 100644 --- a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp +++ b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp @@ -73,6 +73,9 @@ void ServiceTestCommon::BuildLocationComponentJson(nlohmann::json& jsonComponent jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) @@ -131,6 +134,9 @@ void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) @@ -189,6 +195,9 @@ void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } } // namespace SecurityComponent } // namespace Security diff --git a/test/fuzztest/security_component/common/fuzz_common.cpp b/test/fuzztest/security_component/common/fuzz_common.cpp index 741833f7dc91a2b0450c24dd685be0cc9b30ab92..c4118e80f5130a7b0fa7b3d3bdf91c07430642f6 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -111,6 +111,9 @@ std::string CompoRandomGenerator::ConstructLocationJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; return jsonComponent.dump(); } @@ -155,6 +158,9 @@ std::string CompoRandomGenerator::ConstructSaveJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; return jsonComponent.dump(); } @@ -198,6 +204,9 @@ std::string CompoRandomGenerator::ConstructPasteJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; + jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; return jsonComponent.dump(); }