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 a4f8215728d82adbb81815a8725069330f6ae1c3..a5d82f9bd5281328229d5e8553b3b2673ba648c1 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 495ed383908b2194a4755fd0176e3564a27be83a..cc3c275a23306ba954003fe38d622d1d8c6de211 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 bc741fb24bc395fa2fe7c5321e0e3411f9f220ee..caddc4792359255d65a1fbf0e54cb3264b947b10 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 0000000000000000000000000000000000000000..2a5044f85bb454f68845c0ec0cfdecde4c21ea6d --- /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 1a1b11e72839b4451bb7157845366bd17c2fb705..6f46d96fc43ee5b3c4095d6f4ec9318157e4848a 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 155871b3fe4bec3782a9f2305b5fc429207c00df..f1c83f917d017e71fb4333438b54e97545deece5 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 237549146b60a14d598f94790ecf8442135ce963..4da14b0e4e3ebd0f7cd60c98d0995782f1bccbeb 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 d8b2b0806e908a5077de1afeb5b9d96a04e21981..58f99ca75e881395506a52eaa76462177974622b 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 016c7ce06170651e240ec4f4570e249acb7994bb..a9f8a3c728d8e5fd442c7438005b290a30c95470 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 be12a5c505f91616e3b8fb9838eb0122b529d884..59f9729cb7b35c1659dba032ba6798cd641ed84a 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 90c4f592fae33252f50fb92f14dc0746b5a3fe5c..54bb4bfb2b12ceae0f75705c7a38cbf803848248 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 64e081b132ea05cefa3198bbef583181b1ac0fd6..4f5d9462e04b01aa656acf2305d21987a2c04d09 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 25dc18d1d388658d1e6525f7ab7235f66ee436b0..57eaeca21048a6ca58d292a088db0d5bd4eec976 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 dd91b59270f4b431fb9014a4549a74fea94801de..586a682710fd982ee555eda56b6173622f683ad5 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 814a51147a4d1a9c5a106566efd36fe3f0ea3836..1cfae21e66482756dee32cceac9ed64cbba17f7a 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 2f246fe2dd1472598073a87e6a623dd260e7cf71..23e517d73a01200b4fb7fa2f2e558e9fe4c88124 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 b8b520b01b240ed271b261f1df43cb2ba9ab9d98..46a7debafd5bff2fba98e3cae7abd38a494652f4 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 312052efa71745b2daa6c801bdf6839f82e9ec8a..2c36661e64261bb05116f42affc3617e5c2d9fe1 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 b2b63f10db7a501dd443ecf44cf53d139e669594..c98e09c30de5bead2e2f8378c0b490f5f89d0d1c 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 d21a8540508f0ac7e31e34a996e43c677268ae16..5f08d6e4f0c5d672e4ceedaa42cf2782587db453 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 d22d2784ee2fe5d1e5915d03a8a6ed2bd2cf4f17..68583d79f8d8e83dbd29452ebba1cc9bb59ec2e2 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 ef6cdf35cf8027c72fcd9a6db6d0fbd0d437809d..8f9eb4dc788689cdce4260d929e5684961b4b032 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 1027177d5cae28e8e127a6b48ca82532cec32d12..6e9836cd76d5937350866b6cb895a7b994c337f2 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 e466d31ce2193a6955828905d2f2e086c25b0a3d..ce47d94e77b72cdbffc1dcf75b82dd7e01ab6b12 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 86e1067f75ddfc94b52459fbf0c0d09f27e2359a..6c7b25353194818a31cf24b6abb80a70f6f2b9ca 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 715ad694d698ac7fb73df3a08e0b6b84ad403eea..a2127ba29a800cdca82619e77aee80dfc42a6618 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 d29dd44c994b6c83ce9d9820a91e64b64352841c..31c8006ac554627ab49990eb58b0ea0d8f75620d 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 55eb83a80aff40bef3e008ed025c20eef9513a7d..1c91e6d6f1bb39dcddbad51272dca9b1307f214c 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 fd8a6cbd919fe6f8dedb24b8fd426420f5700f68..71c41c9cd21e4be35b38be08d4b2fb4756076854 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 cd3d6068f5ffdf4cc178163db026c64677a7431b..d10cb59daa526ff5bdb906ef4ab6e284f0b6ec62 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 4bb290858d46a2529e1e96fba4b133e983c44135..1dfbacfa2f631b805d2101a5a80fdf009de1988b 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 5f0bde5e1b2ca3cbdad4a811c208be61177bfff5..774e00083889485d10a62a0051d2c196d4aef226 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 231b33c3ae744dc06b16621f3b3e070c2f12deae..3c717b393c905fd204a33dcf673d06fe26f3f5ee 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 809637c8f6fb4bd5e502b4ab66ef542c82460100..be90e0e210ea8d3653b6e267c219e72db2b212f2 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 529270157f9fcd88b61d39261e1d6dddfc5415d4..21cd6135459ea96dd910a82a57074c5a8c0e6c47 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; }