保存控件放开部分校验

Signed-off-by: AXYChen <chenmingyang14@huawei.com>
Change-Id: Ia58882935e8b6fb053c006be6d5e9928d6eb8cd3
This commit is contained in:
AXYChen
2025-07-28 11:32:09 +08:00
parent 160f149dd2
commit 830358d249
3 changed files with 30 additions and 26 deletions
@@ -238,11 +238,11 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent005, TestSize.Lev
{
system("param set sec.comp.enhance 1");
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 };
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -257,7 +257,7 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent005, TestSize.Lev
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message));
@@ -291,11 +291,11 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent001, Test
{
system("param set sec.comp.enhance 1");
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 };
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -311,7 +311,7 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent001, Test
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message));
@@ -370,13 +370,13 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent002, Test
HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent003, TestSize.Level0)
{
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
ASSERT_EQ(0, SetSelfTokenID(TestCommon::HAP_TOKEN_ID + g_token_sum));
g_token_sum ++;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -389,7 +389,7 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent003, Test
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
@@ -486,13 +486,13 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission001, TestSize.Level0)
{
system("param set sec.comp.enhance 1");
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
ASSERT_EQ(0, SetSelfTokenID(TestCommon::HAP_TOKEN_ID + g_token_sum));
g_token_sum ++;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 };
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -507,7 +507,7 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission001, TestSize.Level0)
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message));
@@ -530,11 +530,11 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission002, TestSize.Level0)
{
system("param set sec.comp.enhance 1");
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 };
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -549,7 +549,7 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission002, TestSize.Level0)
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message));
@@ -567,11 +567,11 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L
{
system("param set sec.comp.enhance 1");
nlohmann::json jsonRes;
TestCommon::BuildSaveComponentInfo(jsonRes);
std::string saveInfo = jsonRes.dump();
TestCommon::BuildPasteComponentInfo(jsonRes);
std::string pasteInfo = jsonRes.dump();
int32_t scId;
EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId));
EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId));
uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 };
struct SecCompClickEvent clickInfo = {
.type = ClickEventType::POINT_EVENT_TYPE,
@@ -586,7 +586,7 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L
ASSERT_NE(callback, nullptr);
auto token = callback->AsObject();
OnFirstUseDialogCloseFunc func = [] (int32_t) {};
SecCompInfo secCompInfo{ scId, saveInfo, clickInfo };
SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo };
std::string message;
EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message));
@@ -131,8 +131,8 @@ int32_t SecCompEntity::CheckClickInfo(SecCompClickEvent& clickInfo, int32_t supe
componentInfo_->rect_.y_ += superFoldOffsetY;
}
message.clear();
if (!WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_,
componentInfo_->rect_, message)) {
if ((GetType() != SecCompType::SAVE_COMPONENT) &&
!WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_, componentInfo_->rect_, message)) {
SC_LOG_ERROR(LABEL, "Component may be covered by other window");
if (!AllowToBypassSecurityCheck(message)) {
return SC_SERVICE_ERROR_CLICK_EVENT_INVALID;
@@ -139,6 +139,10 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level0)
touch.point.timestamp = static_cast<uint64_t>(
std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT;
ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK);
OHOS::Rosen::WindowManager::GetInstance().result_ = static_cast<OHOS::Rosen::WMError>(-1);
entity_->componentInfo_->type_ = SAVE_COMPONENT;
ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK);
}
/**