From 9ef2e1c626c34f5d3af03f00ec1d7bc1b7a08b06 Mon Sep 17 00:00:00 2001 From: GengYinzong Date: Tue, 22 Oct 2024 23:56:24 -0700 Subject: [PATCH] fix Signed-off-by: GengYinzong --- .../database/sandbox_manager_rdb_utils.cpp | 6 +- .../main/cpp/src/mac/mac_adapter.cpp | 13 +++++ .../unittest/sandbox_manager_service_test.cpp | 13 +++++ test/fuzztest/services/mock/event_handler.h | 58 +++++++++++++++++++ .../checkpersistpolicystub_fuzzer/BUILD.gn | 2 +- .../checkpersistpolicystub_fuzzer.cpp | 3 + .../checkpolicystub_fuzzer/BUILD.gn | 2 +- .../checkpolicystub_fuzzer.cpp | 3 + .../BUILD.gn | 2 +- .../cleanpersistpolicybypathstub_fuzzer.cpp | 3 + .../persistpolicystub_fuzzer/BUILD.gn | 2 +- .../persistpolicystub_fuzzer.cpp | 3 + .../persistpolicytokenstub_fuzzer/BUILD.gn | 2 +- .../persistpolicytokenstub_fuzzer.cpp | 4 +- .../sandbox_manager_service_fuzz.gni | 2 +- .../setpolicyasyncstub_fuzzer/BUILD.gn | 2 +- .../setpolicyasyncstub_fuzzer.cpp | 4 +- .../setpolicystub_fuzzer/BUILD.gn | 2 +- .../setpolicystub_fuzzer.cpp | 4 +- .../BUILD.gn | 2 +- .../startaccessingbytokenidstub_fuzzer.cpp | 3 + .../startaccessingpolicystub_fuzzer/BUILD.gn | 2 +- .../startaccessingpolicystub_fuzzer.cpp | 3 + .../stopaccessingpolicystub_fuzzer/BUILD.gn | 2 +- .../stopaccessingpolicystub_fuzzer.cpp | 3 + .../unpersistpolicystub_fuzzer/BUILD.gn | 2 +- .../unpersistpolicystub_fuzzer.cpp | 3 + .../unpersistpolicytokenstub_fuzzer/BUILD.gn | 2 +- .../unpersistpolicytokenstub_fuzzer.cpp | 3 + .../unsetallpolicybytokenstub_fuzzer/BUILD.gn | 2 +- .../unsetallpolicybytokenstub_fuzzer.cpp | 3 + .../unsetpolicyasyncstub_fuzzer/BUILD.gn | 2 +- .../unsetpolicyasyncstub_fuzzer.cpp | 3 + .../unsetpolicystub_fuzzer/BUILD.gn | 2 +- .../unsetpolilcystub_fuzzer.cpp | 3 + 35 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 test/fuzztest/services/mock/event_handler.h diff --git a/services/sandbox_manager/main/cpp/src/database/sandbox_manager_rdb_utils.cpp b/services/sandbox_manager/main/cpp/src/database/sandbox_manager_rdb_utils.cpp index a4f8215..a5d82f9 100644 --- a/services/sandbox_manager/main/cpp/src/database/sandbox_manager_rdb_utils.cpp +++ b/services/sandbox_manager/main/cpp/src/database/sandbox_manager_rdb_utils.cpp @@ -155,9 +155,9 @@ void ResultToGenericValues(const std::shared_ptr &resultSe resultSet->GetColumnType(columnIndex, type); if (type == NativeRdb::ColumnType::TYPE_INTEGER) { - size_t type_size = 0; - resultSet->GetSize(columnIndex, type_size); - if (type_size == sizeof(int64_t)) { + size_t typeSize = 0; + resultSet->GetSize(columnIndex, typeSize); + if (typeSize == sizeof(int64_t)) { int64_t data = 0; resultSet->GetLong(columnIndex, data); value.Put(columnName, data); diff --git a/services/sandbox_manager/main/cpp/src/mac/mac_adapter.cpp b/services/sandbox_manager/main/cpp/src/mac/mac_adapter.cpp index 495ed38..cc3c275 100644 --- a/services/sandbox_manager/main/cpp/src/mac/mac_adapter.cpp +++ b/services/sandbox_manager/main/cpp/src/mac/mac_adapter.cpp @@ -16,6 +16,7 @@ #include "mac_adapter.h" #include #include +#include #include #include #include @@ -94,6 +95,8 @@ bool MacAdapter::IsMacSupport() int32_t MacAdapter::SetSandboxPolicy(uint32_t tokenId, const std::vector &policy, uint64_t policyFlag, std::vector &result) { + SANDBOXMANAGER_LOG_INFO(LABEL, "set sandbox policy target:%{public}u flag:%{public}" PRIu64 ".", tokenId, + policyFlag); if (fd_ < 0) { SANDBOXMANAGER_LOG_ERROR(LABEL, "Not init yet."); return SANDBOX_MANAGER_MAC_NOT_INIT; @@ -113,6 +116,8 @@ int32_t MacAdapter::SetSandboxPolicy(uint32_t tokenId, const std::vector(policy[offset + i].path.c_str()); info.pathInfos[i].pathLen = policy[offset + i].path.length(); info.pathInfos[i].mode = policy[offset + i].mode; + SANDBOXMANAGER_LOG_INFO(LABEL, "set policy paths target:%{public}u path:%{public}s mode:%{public}d", + tokenId, info.pathInfos[i].path, info.pathInfos[i].mode); } if (ioctl(fd_, SET_POLICY_CMD, &info) < 0) { @@ -219,6 +224,8 @@ int32_t MacAdapter::CheckSandboxPolicy(uint32_t tokenId, const std::vector &policy, std::vector &result) { + SANDBOXMANAGER_LOG_INFO(LABEL, "unset sandbox policy target:%{public}u", tokenId); + if (fd_ < 0) { SANDBOXMANAGER_LOG_ERROR(LABEL, "Not init yet."); return SANDBOX_MANAGER_MAC_NOT_INIT; @@ -239,6 +246,8 @@ int32_t MacAdapter::UnSetSandboxPolicy(uint32_t tokenId, const std::vector(policy[offset + i].path.c_str()); info.pathInfos[i].pathLen = policy[offset + i].path.length(); info.pathInfos[i].mode = policy[offset + i].mode; + SANDBOXMANAGER_LOG_INFO(LABEL, "unset policy paths target:%{public}u path:%{public}s mode:%{public}d", + tokenId, info.pathInfos[i].path, info.pathInfos[i].mode); } if (ioctl(fd_, UN_SET_POLICY_CMD, &info) < 0) { @@ -272,6 +281,8 @@ int32_t MacAdapter::UnSetSandboxPolicy(uint32_t tokenId, const PolicyInfo &polic info.pathInfos[0].path = const_cast(policy.path.c_str()); info.pathInfos[0].pathLen = policy.path.length(); info.pathInfos[0].mode = policy.mode; + SANDBOXMANAGER_LOG_INFO(LABEL, "unset sandbox policy target:%{public}u path:%{public}s mode:%{public}d", tokenId, + info.pathInfos[0].path, info.pathInfos[0].mode); if (ioctl(fd_, UN_SET_POLICY_CMD, &info) < 0) { SANDBOXMANAGER_LOG_ERROR(LABEL, "Unset policy failed, errno=%{public}d.", errno); @@ -283,6 +294,8 @@ int32_t MacAdapter::UnSetSandboxPolicy(uint32_t tokenId, const PolicyInfo &polic int32_t MacAdapter::DestroySandboxPolicy(uint32_t tokenId) { + SANDBOXMANAGER_LOG_INFO(LABEL, "destroy sandbox policy target:%{public}u", tokenId); + if (fd_ < 0) { SANDBOXMANAGER_LOG_ERROR(LABEL, "Not init yet."); return SANDBOX_MANAGER_MAC_NOT_INIT; diff --git a/services/sandbox_manager/test/unittest/sandbox_manager_service_test.cpp b/services/sandbox_manager/test/unittest/sandbox_manager_service_test.cpp index bc741fb..caddc47 100644 --- a/services/sandbox_manager/test/unittest/sandbox_manager_service_test.cpp +++ b/services/sandbox_manager/test/unittest/sandbox_manager_service_test.cpp @@ -18,6 +18,9 @@ #include #include "access_token.h" #include "accesstoken_kit.h" +#define private public +#include "event_handler.h" +#undef private #include "hap_token_info.h" #include "nativetoken_kit.h" #include "policy_info.h" @@ -398,6 +401,16 @@ HWTEST_F(SandboxManagerServiceTest, SandboxManagerStub001, TestSize.Level1) EXPECT_EQ(SANDBOX_MANAGER_SERVICE_PARCEL_ERR, sandboxManagerService_->UnPersistPolicyInner(data, reply)); data.WriteParcelable(policyInfoVectorParcel); sandboxManagerService_->UnPersistPolicyInner(data, reply); + + if (sandboxManagerService_->unloadRunner_ != nullptr) { + sandboxManagerService_->unloadRunner_->queue_.reset(); + sandboxManagerService_->unloadRunner_ = nullptr; + } + if (sandboxManagerService_->unloadHandler_ != nullptr) { + sandboxManagerService_->unloadHandler_->eventRunner_.reset(); + sandboxManagerService_->unloadHandler_ = nullptr; + } + sleep(3); SetSelfTokenID(selfTokenId_); } diff --git a/test/fuzztest/services/mock/event_handler.h b/test/fuzztest/services/mock/event_handler.h new file mode 100644 index 0000000..2a5044f --- /dev/null +++ b/test/fuzztest/services/mock/event_handler.h @@ -0,0 +1,58 @@ +/* + * 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. + */ + +#ifndef SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H +#define SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H +#include +#include + +namespace OHOS { +namespace AppExecFwk { +enum class ThreadMode: uint32_t { + NEW_THREAD = 0, // for new thread mode, event handler create thread + FFRT, // for new thread mode, use ffrt +}; + +class EventRunner final { +public: + EventRunner() = default; + ~EventRunner() = default; + + static std::shared_ptr Create(bool inNewThread, ThreadMode mode) + { + return std::make_shared(); + } +}; + +class EventHandler { +public: + using Callback = std::function; + + explicit EventHandler(const std::shared_ptr &runner = nullptr) : runner_(runner) {}; + + void RemoveTask(const std::string &name) {}; + + bool PostTask(const Callback &callback, const std::string &name = std::string(), + int64_t delayTime = 0) + { + return true; + }; + +private: + std::shared_ptr runner_; +}; +} // AppExecFwk +} // OHOS +#endif // SANDBOX_MANAGER_EVENT_HANDLER_MOCK_H diff --git a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/BUILD.gn index 1a1b11e..6f46d96 100644 --- a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("CheckPersistPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [] diff --git a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp index 155871b..f1c83f9 100644 --- a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp @@ -22,7 +22,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -58,6 +60,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/BUILD.gn index 2375491..4da14b0 100644 --- a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("CheckPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [] diff --git a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp index d8b2b08..58f99ca 100644 --- a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp @@ -22,7 +22,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -57,6 +59,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/BUILD.gn index 016c7ce..a9f8a3c 100644 --- a/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("CleanPersistPolicyByPathStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [] diff --git a/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/cleanpersistpolicybypathstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/cleanpersistpolicybypathstub_fuzzer.cpp index be12a5c..59f9729 100644 --- a/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/cleanpersistpolicybypathstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/cleanpersistpolicybypathstub_fuzzer/cleanpersistpolicybypathstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private #include "token_setproc.h" using namespace OHOS::AccessControl::SandboxManager; @@ -60,6 +62,7 @@ static uint32_t FILE_MANAGER_TOKEN = 0; MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); SetSelfTokenID(SELF_TOKEN); return true; diff --git a/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/BUILD.gn index 90c4f59..54bb4bf 100644 --- a/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("PersistPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/persistpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/persistpolicystub_fuzzer.cpp index 64e081b..4f5d946 100644 --- a/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/persistpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/persistpolicystub_fuzzer/persistpolicystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -55,6 +57,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; diff --git a/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/BUILD.gn index 25dc18d..57eaeca 100644 --- a/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("PersistPolicyTokenStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/persistpolicytokenstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/persistpolicytokenstub_fuzzer.cpp index dd91b59..586a682 100644 --- a/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/persistpolicytokenstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/persistpolicytokenstub_fuzzer/persistpolicytokenstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -59,7 +61,7 @@ namespace OHOS { uint32_t code = static_cast(SandboxManagerInterfaceCode::PERSIST_PERMISSION_BY_TOKENID); MessageParcel reply; MessageOption option; - + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/sandbox_manager_service_fuzz.gni b/test/fuzztest/services/sandbox_manager/sandbox_manager_service_fuzz.gni index 814a511..1cfae21 100644 --- a/test/fuzztest/services/sandbox_manager/sandbox_manager_service_fuzz.gni +++ b/test/fuzztest/services/sandbox_manager/sandbox_manager_service_fuzz.gni @@ -22,6 +22,7 @@ sandbox_manager_include_dirs = [ "${sandbox_manager_path}/services/sandbox_manager/main/cpp/include/sensitive", "${sandbox_manager_path}/services/sandbox_manager/main/cpp/include/service", "${sandbox_manager_path}/services/sandbox_manager/main/cpp/include/mac", + "../../mock/", "../../../common/", ] @@ -58,7 +59,6 @@ sandbox_manager_external_deps = [ "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", - "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", "relational_store:native_rdb", diff --git a/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/BUILD.gn index 2f246fe..23e517d 100644 --- a/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("SetPolicyAsyncStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/setpolicyasyncstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/setpolicyasyncstub_fuzzer.cpp index b8b520b..46a7deb 100644 --- a/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/setpolicyasyncstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/setpolicyasyncstub_fuzzer/setpolicyasyncstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "policy_info_vector_parcel.h" #include "i_sandbox_manager.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -63,7 +65,7 @@ namespace OHOS { uint32_t code = static_cast(SandboxManagerInterfaceCode::SET_POLICY_ASYNC); MessageParcel reply; MessageOption option; - + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/BUILD.gn index 312052e..2c36661 100644 --- a/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("SetPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/setpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/setpolicystub_fuzzer.cpp index b2b63f1..c98e09c 100644 --- a/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/setpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/setpolicystub_fuzzer/setpolicystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "policy_info_vector_parcel.h" #include "i_sandbox_manager.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -63,7 +65,7 @@ namespace OHOS { uint32_t code = static_cast(SandboxManagerInterfaceCode::SET_POLICY); MessageParcel reply; MessageOption option; - + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/BUILD.gn index d21a854..5f08d6e 100644 --- a/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("StartAccessingByTokenidStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/startaccessingbytokenidstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/startaccessingbytokenidstub_fuzzer.cpp index d22d278..68583d7 100644 --- a/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/startaccessingbytokenidstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/startaccessingbytokenidstub_fuzzer/startaccessingbytokenidstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -54,6 +56,7 @@ const int32_t FOUNDATION_UID = 5523; MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); setuid(uid); return true; diff --git a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/BUILD.gn index ef6cdf3..8f9eb4d 100644 --- a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("StartAccessingPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp index 1027177..6e9836c 100644 --- a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -54,6 +56,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; diff --git a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/BUILD.gn index e466d31..ce47d94 100644 --- a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("StopAccessingPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp index 86e1067..6c7b253 100644 --- a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -54,6 +56,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/BUILD.gn index 715ad69..a2127ba 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("UnPersistPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp index d29dd44..31c8006 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -54,6 +56,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/BUILD.gn index 55eb83a..1c91e6d 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("UnpersistPolicyTokenStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp index fd8a6cb..71c41c9 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -59,6 +61,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; diff --git a/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/BUILD.gn index cd3d606..d10cb59 100644 --- a/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("UnsetAllPolicyByTokenStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/unsetallpolicybytokenstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/unsetallpolicybytokenstub_fuzzer.cpp index 4bb2908..1dfbacf 100644 --- a/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/unsetallpolicybytokenstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unsetallpolicybytokenstub_fuzzer/unsetallpolicybytokenstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_vector_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -48,6 +50,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/BUILD.gn index 5f0bde5..774e000 100644 --- a/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("UnsetPolicyAsyncStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/unsetpolicyasyncstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/unsetpolicyasyncstub_fuzzer.cpp index 231b33c..3c717b3 100644 --- a/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/unsetpolicyasyncstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unsetpolicyasyncstub_fuzzer/unsetpolicyasyncstub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -56,6 +58,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } diff --git a/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/BUILD.gn b/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/BUILD.gn index 809637c..be90e0e 100644 --- a/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/BUILD.gn @@ -17,7 +17,7 @@ import("../../../../../sandbox_manager.gni") import("../sandbox_manager_service_fuzz.gni") ohos_fuzztest("UnsetPolicyStubFuzzTest") { - module_out_path = module_output_path_interface_sandbox + module_out_path = module_output_path_service_sandbox fuzz_config_file = "." include_dirs = [ "../../../common" ] diff --git a/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/unsetpolilcystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/unsetpolilcystub_fuzzer.cpp index 5292701..21cd613 100644 --- a/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/unsetpolilcystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unsetpolicystub_fuzzer/unsetpolilcystub_fuzzer.cpp @@ -23,7 +23,9 @@ #include "i_sandbox_manager.h" #include "policy_info_parcel.h" #include "sandboxmanager_service_ipc_interface_code.h" +#define private public #include "sandbox_manager_service.h" +#undef private using namespace OHOS::AccessControl::SandboxManager; @@ -56,6 +58,7 @@ namespace OHOS { MessageParcel reply; MessageOption option; + DelayedSingleton::GetInstance()->Initialize(); DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); return true; } -- Gitee