From 0aadb3ce6837628d1c0c83c40dd148cf21d985a5 Mon Sep 17 00:00:00 2001 From: zhangya63 Date: Mon, 4 Aug 2025 20:31:04 +0800 Subject: [PATCH 1/3] first fork Signed-off-by: zhangya63 Change-Id: I58ad157343b391fa019c52d8d417f96ab213658e --- services/core/src/strong_auth_status_manager_impl.cpp | 2 +- .../userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp | 2 +- .../context/widgetcontext_fuzzer/widget_context_fuzzer.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/src/strong_auth_status_manager_impl.cpp b/services/core/src/strong_auth_status_manager_impl.cpp index ab26c07bc..d972e8d67 100644 --- a/services/core/src/strong_auth_status_manager_impl.cpp +++ b/services/core/src/strong_auth_status_manager_impl.cpp @@ -130,7 +130,7 @@ void StrongAuthStatusManagerImpl::SyncStrongAuthStatusForAllAccounts() { IAM_LOGI("start"); std::lock_guard lock(mutex_); - auto screenLockManager = ScreenLockManager::GetInstance(); + auto screenLockManager = ScreenLockManager::GetInstance(); IF_FALSE_LOGE_AND_RETURN(screenLockManager != nullptr); IF_FALSE_LOGE_AND_RETURN(strongAuthListener_ != nullptr); diff --git a/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp b/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp index 95f48fe34..6e82215b8 100644 --- a/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp +++ b/test/fuzztest/executors/userauthexecutor_fuzzer/user_auth_executor_fuzzer.cpp @@ -674,7 +674,7 @@ void FuzzFillPropertyToAttribute(std::shared_ptr parcel) Attributes::ATTR_NEXT_FAIL_LOCKOUT_DURATION, Attributes::ATTR_ROOT }; - Property property = {}; + Property property = {}; std::shared_ptr values = UserIam::Common::MakeShared(); g_frameworkExecutorCallback->FillPropertyToAttribute(keyList, property, values); IAM_LOGI("end"); diff --git a/test/fuzztest/services/context/widgetcontext_fuzzer/widget_context_fuzzer.cpp b/test/fuzztest/services/context/widgetcontext_fuzzer/widget_context_fuzzer.cpp index 0ad2235dd..962203e65 100644 --- a/test/fuzztest/services/context/widgetcontext_fuzzer/widget_context_fuzzer.cpp +++ b/test/fuzztest/services/context/widgetcontext_fuzzer/widget_context_fuzzer.cpp @@ -76,7 +76,7 @@ std::shared_ptr CreateWidgetContext(Parcel &parcel) para.authTypeList.push_back(static_cast(parcel.ReadInt32())); para.atl = static_cast(parcel.ReadUint32()); FillFuzzString(parcel, para.widgetParam.navigationButtonText); - para.callerType = parcel.ReadInt32(); + para.callerType = parcel.ReadInt32(); FillFuzzString(parcel, para.callingAppID); para.isPinExpired = parcel.ReadBool(); para.isOsAccountVerified = parcel.ReadBool(); @@ -333,7 +333,7 @@ void FuzzIsValidRotate(Parcel &parcel) } WidgetContext::WidgetRotatePara widgetRotatePara; - widgetRotatePara.isReload = parcel.ReadBool(); + widgetRotatePara.isReload = parcel.ReadBool(); widgetRotatePara.orientation = parcel.ReadUint32(); widgetRotatePara.needRotate = parcel.ReadUint32(); widgetRotatePara.alreadyLoad = parcel.ReadUint32(); @@ -382,7 +382,7 @@ void FuzzConnectExtension(Parcel &parcel) return; } WidgetContext::WidgetRotatePara widgetRotatePara; - widgetRotatePara.isReload = parcel.ReadBool(); + widgetRotatePara.isReload = parcel.ReadBool(); widgetRotatePara.orientation = parcel.ReadUint32(); widgetRotatePara.needRotate = parcel.ReadUint32(); widgetRotatePara.alreadyLoad = parcel.ReadUint32(); -- Gitee From 5e4baf74112df8220716d2fc8cc436df77046985 Mon Sep 17 00:00:00 2001 From: zhangya63 Date: Tue, 5 Aug 2025 09:37:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8ad8b244e43bfce7da40cdb3c51c1647daa06a23 --- .../napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp b/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp index a7bc7947d..aea1c81ad 100644 --- a/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp +++ b/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp @@ -144,7 +144,7 @@ void UserAccessCtrlCallbackV16::OnResult(int32_t result, const UserAuth::Attribu uv_loop_s *loop = nullptr; napi_status napiStatus = napi_get_uv_event_loop(env_, &loop); if (napiStatus != napi_ok || loop == nullptr) { - IAM_LOGE("napi_get_uv_event_loop fail"); + IAM_LOGE("napi_get_uv_event_loop fail, napiStatus=%{public}d", napiStatus); return; } std::shared_ptr resultHolder = Common::MakeShared(); -- Gitee From 633efdd1cdcf4abdb4d9ae63dd99290f3a17564e Mon Sep 17 00:00:00 2001 From: zhangya Date: Tue, 5 Aug 2025 01:40:25 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20fram?= =?UTF-8?q?eworks/js/napi/user=5Faccess=5Fctrl/src/user=5Faccess=5Fctrl=5F?= =?UTF-8?q?callback=5Fv16.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/user_access_ctrl_callback_v16.cpp | 185 ------------------ 1 file changed, 185 deletions(-) delete mode 100644 frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp diff --git a/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp b/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp deleted file mode 100644 index aea1c81ad..000000000 --- a/frameworks/js/napi/user_access_ctrl/src/user_access_ctrl_callback_v16.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "user_access_ctrl_callback_v16.h" - -#include - -#include "napi/native_node_api.h" - -#include "iam_check.h" -#include "iam_logger.h" -#include "iam_ptr.h" - -#define LOG_TAG "USER_ACCESS_CTRL_NAPI" - -namespace OHOS { -namespace UserIam { -namespace UserAccessCtrl { -namespace { -struct ResultCallbackV16Holder { - std::shared_ptr callback {nullptr}; - int32_t result {0}; - AuthToken authToken {}; - napi_env env {nullptr}; -}; -} - -UserAccessCtrlCallbackV16::UserAccessCtrlCallbackV16(napi_env env, napi_deferred promise) - : env_(env), promise_(promise) -{ - if (env_ == nullptr) { - IAM_LOGE("UserAccessCtrlCallbackV16 get null env"); - } -} - -UserAccessCtrlCallbackV16::~UserAccessCtrlCallbackV16() -{ -} - -napi_status UserAccessCtrlCallbackV16::ProcessAuthTokenResult(napi_env env, napi_value value, AuthToken authToken) -{ - IAM_LOGI("start"); - napi_status ret = UserAuth::UserAuthNapiHelper::SetUint8ArrayProperty(env, value, "challenge", authToken.challenge); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAuth::UserAuthNapiHelper::SetUint32Property(env, value, "authTrustLevel", authToken.authTrustLevel); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAuth::UserAuthNapiHelper::SetInt32Property(env, value, "authType", authToken.authType); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAuth::UserAuthNapiHelper::SetInt32Property(env, value, "tokenType", authToken.tokenType); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAuth::UserAuthNapiHelper::SetInt32Property(env, value, "userId", authToken.userId); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAccessCtrlNapiHelper::SetUint64Property(env, value, "timeInterval", authToken.timeInterval); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAccessCtrlNapiHelper::SetUint64Property(env, value, "secureUid", authToken.secureUid); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAccessCtrlNapiHelper::SetUint64Property(env, value, "enrolledId", authToken.enrolledId); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - ret = UserAccessCtrlNapiHelper::SetUint64Property(env, value, "credentialId", authToken.credentialId); - IF_FALSE_LOGE_AND_RETURN_VAL(ret == napi_ok, ret); - return ret; -} - -napi_status UserAccessCtrlCallbackV16::DoResultPromise(int32_t result, AuthToken authToken) -{ - if (promise_ == nullptr) { - return napi_ok; - } - IAM_LOGI("start"); - napi_value eventInfo; - napi_status ret = napi_create_object(env_, &eventInfo); - if (ret != napi_ok) { - IAM_LOGE("napi_create_object failed %{public}d", ret); - return ret; - } - if (UserAuth::UserAuthResultCode(result) == UserAuth::UserAuthResultCode::SUCCESS) { - ret = ProcessAuthTokenResult(env_, eventInfo, authToken); - if (ret != napi_ok) { - IAM_LOGE("ProcessAuthTokenResult failed %{public}d", ret); - return ret; - } - ret = napi_resolve_deferred(env_, promise_, eventInfo); - if (ret != napi_ok) { - IAM_LOGE("napi_resolve_deferred failed %{public}d", ret); - } - } else { - ret = napi_reject_deferred(env_, promise_, UserAuth::UserAuthNapiHelper::GenerateBusinessErrorV9(env_, - UserAuth::UserAuthResultCode(result))); - if (ret != napi_ok) { - IAM_LOGE("napi_reject_deferred failed %{public}d", ret); - } - } - return ret; -} - -void GetCallbackResult(const UserAuth::Attributes &extraInfo, std::shared_ptr resultHolder) -{ - if (!extraInfo.GetUint8ArrayValue(UserAuth::Attributes::ATTR_CHALLENGE, resultHolder->authToken.challenge)) { - IAM_LOGE("ATTR_CHALLENGE is null"); - } - if (!extraInfo.GetUint32Value(UserAuth::Attributes::ATTR_AUTH_TRUST_LEVEL, - resultHolder->authToken.authTrustLevel)) { - IAM_LOGE("ATTR_AUTH_TRUST_LEVEL is null"); - } - if (!extraInfo.GetInt32Value(UserAuth::Attributes::ATTR_AUTH_TYPE, resultHolder->authToken.authType)) { - IAM_LOGE("ATTR_AUTH_TYPE is null"); - } - if (!extraInfo.GetInt32Value(UserAuth::Attributes::ATTR_TOKEN_TYPE, resultHolder->authToken.tokenType)) { - IAM_LOGE("ATTR_TOKEN_TYPE is null"); - } - if (!extraInfo.GetInt32Value(UserAuth::Attributes::ATTR_USER_ID, resultHolder->authToken.userId)) { - IAM_LOGE("ATTR_USER_ID is null"); - } - if (!extraInfo.GetUint64Value(UserAuth::Attributes::ATTR_TOKEN_TIME_INTERVAL, - resultHolder->authToken.timeInterval)) { - IAM_LOGE("ATTR_TOKEN_TIME_INTERVAL is null"); - } - if (!extraInfo.GetUint64Value(UserAuth::Attributes::ATTR_SEC_USER_ID, resultHolder->authToken.secureUid)) { - IAM_LOGE("ATTR_SEC_USER_ID is null"); - } - if (!extraInfo.GetUint64Value(UserAuth::Attributes::ATTR_CREDENTIAL_DIGEST, resultHolder->authToken.enrolledId)) { - IAM_LOGE("ATTR_CREDENTIAL_DIGEST is null"); - } - if (!extraInfo.GetUint64Value(UserAuth::Attributes::ATTR_CREDENTIAL_ID, resultHolder->authToken.credentialId)) { - IAM_LOGE("ATTR_CREDENTIAL_ID is null"); - } -} - -void UserAccessCtrlCallbackV16::OnResult(int32_t result, const UserAuth::Attributes &extraInfo) -{ - IAM_LOGI("start, result:%{public}d", result); - uv_loop_s *loop = nullptr; - napi_status napiStatus = napi_get_uv_event_loop(env_, &loop); - if (napiStatus != napi_ok || loop == nullptr) { - IAM_LOGE("napi_get_uv_event_loop fail, napiStatus=%{public}d", napiStatus); - return; - } - std::shared_ptr resultHolder = Common::MakeShared(); - if (resultHolder == nullptr) { - IAM_LOGE("resultHolder is null"); - return; - } - resultHolder->callback = shared_from_this(); - resultHolder->result = UserAccessCtrlNapiHelper::GetResultCodeV16(result); - resultHolder->env = env_; - GetCallbackResult(extraInfo, resultHolder); - auto task = [resultHolder] () { - IAM_LOGI("start"); - if (resultHolder == nullptr || resultHolder->callback == nullptr) { - IAM_LOGE("resultHolder is invalid"); - return; - } - napi_handle_scope scope = nullptr; - napi_open_handle_scope(resultHolder->env, &scope); - if (scope == nullptr) { - IAM_LOGE("scope is invalid"); - return; - } - napi_status ret = resultHolder->callback->DoResultPromise(resultHolder->result, resultHolder->authToken); - if (ret != napi_ok) { - IAM_LOGE("DoResultPromise fail %{public}d", ret); - napi_close_handle_scope(resultHolder->env, scope); - return; - } - napi_close_handle_scope(resultHolder->env, scope); - }; - if (napi_status::napi_ok != napi_send_event(env_, task, napi_eprio_immediate)) { - IAM_LOGE("napi_send_event: Failed to SendEvent"); - } -} -} // namespace UserAccessCtrl -} // namespace UserIam -} // namespace OHOS \ No newline at end of file -- Gitee