From 7948fbdf2a1f43205f9b1a1136dcc51d9c4587aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=80=9D=E8=BF=9C?= Date: Thu, 19 Sep 2024 15:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4ipc=5Fcallbacks=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周思远 --- CODEOWNERS | 9 - rosen/modules/render_service_base/BUILD.gn | 17 -- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...agent_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...lback_ipc_interface_code_access_verifier.h | 46 ---- ...ack_ipc_interface_code_access_verifier.cpp | 39 --- .../buffer_available_callback_stub.cpp | 8 - .../buffer_available_callback_stub.h | 6 +- ...ack_ipc_interface_code_access_verifier.cpp | 40 --- .../buffer_clear_callback_stub.cpp | 8 - .../buffer_clear_callback_stub.h | 6 +- .../hgm_config_change_callback_stub.cpp | 8 - .../hgm_config_change_callback_stub.h | 6 +- ...ent_ipc_interface_code_access_verifier.cpp | 40 --- .../rs_application_agent_stub.cpp | 8 - .../ipc_callbacks/rs_application_agent_stub.h | 6 +- ...ack_ipc_interface_code_access_verifier.cpp | 48 ---- ...ack_ipc_interface_code_access_verifier.cpp | 40 --- ...ack_ipc_interface_code_access_verifier.cpp | 42 --- ...ack_ipc_interface_code_access_verifier.cpp | 42 --- .../rs_occlusion_change_callback_stub.cpp | 8 - .../rs_occlusion_change_callback_stub.h | 6 +- ...ack_ipc_interface_code_access_verifier.cpp | 40 --- .../rs_surface_buffer_callback_stub.cpp | 8 - .../rs_surface_buffer_callback_stub.h | 6 +- ...surface_occlusion_change_callback_stub.cpp | 9 - ...s_surface_occlusion_change_callback_stub.h | 6 +- .../rs_uiextension_callback_stub.cpp | 8 - .../rs_uiextension_callback_stub.h | 6 +- ...ack_ipc_interface_code_access_verifier.cpp | 40 --- .../screen_change_callback_stub.cpp | 8 - .../screen_change_callback_stub.h | 6 +- ...ack_ipc_interface_code_access_verifier.cpp | 40 --- .../surface_capture_callback_stub.cpp | 8 - .../surface_capture_callback_stub.h | 6 +- rosen/test/render_service/BUILD.gn | 1 - .../unittest/transaction/BUILD.gn | 25 ++ ...pc_interface_code_access_verifier_test.cpp | 221 +++++++++++++++ .../BUILD.gn | 61 ----- .../corpus/init | 14 - .../project.xml | 25 -- ...kipcinterfacecodeaccessverifier_fuzzer.cpp | 78 ------ ...ackipcinterfacecodeaccessverifier_fuzzer.h | 20 -- .../unittest/ipc_callbacks/BUILD.gn | 1 - .../buffer_available_callback_stub_test.cpp | 2 - .../buffer_clear_callback_stub_test.cpp | 2 - .../hgm_config_change_callback_stub_test.cpp | 3 - ...pc_interface_code_access_verifier_test.cpp | 84 ------ ...rs_occlusion_change_callback_stub_test.cpp | 3 - ...ce_occlusion_change_callback_stub_test.cpp | 2 - .../rs_uiextension_callback_stub_test.cpp | 2 - .../screen_change_callback_stub_test.cpp | 2 - .../surface_capture_callback_stub_test.cpp | 1 - .../unittest/memory/BUILD.gn | 10 - ...terface_code_access_verifier_base_test.cpp | 257 ------------------ 62 files changed, 256 insertions(+), 1596 deletions(-) delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp delete mode 100644 rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp create mode 100644 rosen/test/render_service/render_service/unittest/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier_test.cpp delete mode 100755 rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/BUILD.gn delete mode 100755 rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/corpus/init delete mode 100755 rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/project.xml delete mode 100755 rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.cpp delete mode 100755 rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.h delete mode 100644 rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier_test.cpp delete mode 100644 rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp diff --git a/CODEOWNERS b/CODEOWNERS index 9a696dced2..6f0e0a13da 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -13,23 +13,14 @@ # any change to rosen/modules/render_service_base*/*_ipc_interface_code*.h needs to be reviewed by @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_isync_transaction_controller_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/rs_isync_transaction_controller_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code.h @leonchan5 -foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_access_verifier_base.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_security_manager.h @leonchan5 foundation/graphic/graphic_2d/rosen/modules/render_service_base/include/ipc_security/rs_ipc_interface_code_underlying_type.h @leonchan5 diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index 325b6485c6..09b98ac526 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -149,35 +149,25 @@ ohos_source_set("render_service_base_src") { "src/delegate/rs_functional_delegate.cpp", #ipc_callbacks - "src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/buffer_available_callback_proxy.cpp", "src/ipc_callbacks/buffer_available_callback_stub.cpp", - "src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/buffer_clear_callback_proxy.cpp", "src/ipc_callbacks/buffer_clear_callback_stub.cpp", "src/ipc_callbacks/hgm_config_change_callback_proxy.cpp", "src/ipc_callbacks/hgm_config_change_callback_stub.cpp", - "src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/rs_application_agent_proxy.cpp", "src/ipc_callbacks/rs_application_agent_stub.cpp", - "src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp", - "src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp", - "src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp", - "src/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/rs_occlusion_change_callback_proxy.cpp", "src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp", "src/ipc_callbacks/rs_rt_refresh_callback.cpp", - "src/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/rs_surface_buffer_callback_proxy.cpp", "src/ipc_callbacks/rs_surface_buffer_callback_stub.cpp", "src/ipc_callbacks/rs_surface_occlusion_change_callback_proxy.cpp", "src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp", "src/ipc_callbacks/rs_uiextension_callback_proxy.cpp", "src/ipc_callbacks/rs_uiextension_callback_stub.cpp", - "src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/screen_change_callback_proxy.cpp", "src/ipc_callbacks/screen_change_callback_stub.cpp", - "src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/surface_capture_callback_proxy.cpp", "src/ipc_callbacks/surface_capture_callback_stub.cpp", @@ -344,25 +334,18 @@ ohos_source_set("render_service_base_src") { "src/common/rs_thread_looper_impl.cpp", #ipc_callbacks - "src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/buffer_available_callback_proxy.cpp", "src/ipc_callbacks/buffer_available_callback_stub.cpp", - "src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/buffer_clear_callback_proxy.cpp", "src/ipc_callbacks/buffer_clear_callback_stub.cpp", "src/ipc_callbacks/hgm_config_change_callback_proxy.cpp", "src/ipc_callbacks/hgm_config_change_callback_stub.cpp", - "src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp", - "src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp", - "src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/rs_occlusion_change_callback_proxy.cpp", "src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp", "src/ipc_callbacks/rs_surface_occlusion_change_callback_proxy.cpp", "src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp", - "src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/screen_change_callback_proxy.cpp", "src/ipc_callbacks/screen_change_callback_stub.cpp", - "src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp", "src/ipc_callbacks/surface_capture_callback_proxy.cpp", "src/ipc_callbacks/surface_capture_callback_stub.cpp", diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index 20d70d7f3b..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/buffer_available_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIBufferAvailableCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIBufferAvailableCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIBufferAvailableCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIBufferAvailableCallbackInterfaceCodeAccessVerifier(); - ~RSIBufferAvailableCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIBufferAvailableCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index 759b96d4fc..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_IBUFFER_CLEAR_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_IBUFFER_CLEAR_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/buffer_clear_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIBufferClearCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIBufferClearCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIBufferClearCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIBufferClearCallbackInterfaceCodeAccessVerifier(); - ~RSIBufferClearCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIBufferClearCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_IBUFFER_CLEAR_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h deleted file mode 100644 index 7dd923a6e0..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_IAPPLICATION_AGENT_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_IAPPLICATION_AGENT_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/iapplication_agent_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class IApplicationAgentInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = IApplicationAgentInterfaceCode; - static inline const std::string codeEnumTypeName_{"IApplicationAgentInterfaceCode"}; - - /* specify constructor and destructor here */ - IApplicationAgentInterfaceCodeAccessVerifier(); - ~IApplicationAgentInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(IApplicationAgentInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_IAPPLICATION_AGENT_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index 3e26a1a23b..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_RS_IHGM_CONFIG_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_RS_IHGM_CONFIG_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIHgmConfigChangeCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIHgmConfigChangeCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier(); - ~RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_RS_IHGM_CONFIG_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index 4f9d1e4a85..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIOcclusionChangeCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIOcclusionChangeCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier(); - ~RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index c5b288cfe5..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_SURFACE_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_SURFACE_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSISurfaceOcclusionChangeCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSISurfaceOcclusionChangeCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier(); - virtual ~RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_RS_IRENDER_SURFACE_OCCLUSION_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index ac276302b1..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_RS_IUIEXTENSION_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_RS_IUIEXTENSION_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/rs_iuiextension_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIUIExtensionCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIUIExtensionCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIUIExtensionCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIUIExtensionCallbackInterfaceCodeAccessVerifier(); - ~RSIUIExtensionCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIUIExtensionCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_RS_IUIEXTENSION_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index b31360cd19..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +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. - */ - -#ifndef ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSISurfaceBufferCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSISurfaceBufferCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSISurfaceBufferCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSISurfaceBufferCallbackInterfaceCodeAccessVerifier(); - ~RSISurfaceBufferCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSISurfaceBufferCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_ISURFACE_BUFFER_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index c1d92a4d89..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_ISCREEN_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_ISCREEN_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/screen_change_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSIScreenChangeCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSIScreenChangeCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSIScreenChangeCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSIScreenChangeCallbackInterfaceCodeAccessVerifier(); - ~RSIScreenChangeCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSIScreenChangeCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_ISCREEN_CHANGE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h b/rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h deleted file mode 100644 index d72287a1ff..0000000000 --- a/rosen/modules/render_service_base/include/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 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 ROSEN_RENDER_SERVICE_BASE_ISURFACE_CAPTURE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H -#define ROSEN_RENDER_SERVICE_BASE_ISURFACE_CAPTURE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H - -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "ipc_callbacks/surface_capture_callback_ipc_interface_code.h" - -namespace OHOS { -namespace Rosen { -class RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier : public RSInterfaceCodeAccessVerifierBase { -public: - /* - * specify the enum class of the associated interface code (i.e. CodeEnumType) here - * note that term **CodeEnumType** should not be changed - */ - using CodeEnumType = RSISurfaceCaptureCallbackInterfaceCode; - static inline const std::string codeEnumTypeName_{"RSISurfaceCaptureCallbackInterfaceCode"}; - - /* specify constructor and destructor here */ - RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier(); - ~RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier() noexcept override = default; - -protected: - /* specify exclusive verification rules here */ - bool IsExclusiveVerificationPassed(CodeUnderlyingType code) override; - -private: - DISALLOW_COPY_AND_MOVE(RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier); -}; -} // namespace Rosen -} // namespace OHOS -#endif // ROSEN_RENDER_SERVICE_BASE_ISURFACE_CAPTURE_CALLBACK_INTERFACE_CODE_ACCESS_VERIFIER_H diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 067afd7414..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIBufferAvailableCallbackInterfaceCodeAccessVerifier::RSIBufferAvailableCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIBufferAvailableCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_BUFFER_AVAILABLE): { - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.cpp index 90cff83f85..dd10fcb5d1 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.cpp @@ -22,11 +22,6 @@ namespace Rosen { int RSBufferAvailableCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSBufferAvailableCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIBufferAvailableCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -46,8 +41,5 @@ int RSBufferAvailableCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSBufferAvailableCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.h index 52b0b868c6..12947564fb 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_available_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/buffer_available_callback.h" -#include "ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/buffer_available_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSBufferAvailableCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index a01d7fe278..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIBufferClearCallbackInterfaceCodeAccessVerifier::RSIBufferClearCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIBufferClearCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_BUFFER_CLEAR): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.cpp index 62988ed203..922447ed7d 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.cpp @@ -22,11 +22,6 @@ namespace Rosen { int RSBufferClearCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSBufferClearCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIBufferClearCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -46,8 +41,5 @@ int RSBufferClearCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSBufferClearCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.h index 343a4e5077..1b8e574bd4 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/buffer_clear_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/buffer_clear_callback.h" -#include "ipc_callbacks/buffer_clear_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/buffer_clear_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSBufferClearCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.cpp index 900ab6f0e8..0c51de6b7d 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.cpp @@ -22,11 +22,6 @@ namespace Rosen { int RSHgmConfigChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSHgmConfigChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIHgmConfigChangeCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -58,8 +53,5 @@ int RSHgmConfigChangeCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSHgmConfigChangeCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.h index fbb918a5dd..8c33635a4c 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/hgm_config_change_callback_stub.h @@ -20,8 +20,7 @@ #include "common/rs_macros.h" #include "ipc_callbacks/rs_ihgm_config_change_callback.h" -#include "ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -31,9 +30,6 @@ public: ~RSHgmConfigChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 7dbe1bd164..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -IApplicationAgentInterfaceCodeAccessVerifier::IApplicationAgentInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool IApplicationAgentInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::COMMIT_TRANSACTION): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.cpp index cbb1a0f9bf..cabe9a0d68 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.cpp @@ -23,11 +23,6 @@ namespace Rosen { int RSApplicationAgentStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSApplicationAgentStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != IApplicationAgent::GetDescriptor()) { return ERR_INVALID_STATE; @@ -47,8 +42,5 @@ int RSApplicationAgentStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSApplicationAgentStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.h index a263b2d119..ee717e91ae 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_application_agent_stub.h @@ -20,8 +20,7 @@ #include #include "ipc_callbacks/iapplication_agent.h" -#include "ipc_callbacks/iapplication_agent_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/iapplication_agent_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -31,9 +30,6 @@ public: ~RSApplicationAgentStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 31d86c24e2..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier::RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_HGM_CONFIG_CHANGED): { - /* to implement access interception */ - break; - } - case static_cast(CodeEnumType::ON_HGM_REFRESH_RATE_MODE_CHANGED): { - /* to implement access interception */ - break; - } - case static_cast(CodeEnumType::ON_HGM_REFRESH_RATE_CHANGED): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 26901df66f..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier::RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_OCCLUSION_VISIBLE_CHANGED): { - hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_OCCLUSION_VISIBLE_CHANGED"); - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 0ee9c270e0..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier:: - RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed( - CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_SURFACE_OCCLUSION_VISIBLE_CHANGED): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 7a7df1be3b..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,42 +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 "ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIUIExtensionCallbackInterfaceCodeAccessVerifier:: - RSIUIExtensionCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIUIExtensionCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed( - CodeUnderlyingType code) -{ - bool hasPermission = false; - switch (code) { - case static_cast(CodeEnumType::ON_UIEXTENSION): { - hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_UIEXTENSION"); - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp index 09840c7d70..76e2d5ee27 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.cpp @@ -22,11 +22,6 @@ namespace Rosen { int RSOcclusionChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSOcclusionChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIOcclusionChangeCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -47,8 +42,5 @@ int RSOcclusionChangeCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSOcclusionChangeCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.h index 92ab296e0f..4d8f2587e4 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_occlusion_change_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/rs_iocclusion_change_callback.h" -#include "ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/rs_iocclusion_change_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSOcclusionChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index 1d68bb151b..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +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 "ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSISurfaceBufferCallbackInterfaceCodeAccessVerifier::RSISurfaceBufferCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSISurfaceBufferCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_FINISH): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.cpp index 7ea923d18c..154b989e7c 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.cpp @@ -21,11 +21,6 @@ namespace Rosen { int RSSurfaceBufferCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSSurfaceBufferCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSISurfaceBufferCallback::GetDescriptor()) { ROSEN_LOGE("RSSurfaceBufferCallbackStub: token ERR_INVALID_STATE"); @@ -53,8 +48,5 @@ int RSSurfaceBufferCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSSurfaceBufferCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.h index 1702454ea1..e8801ba006 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_buffer_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/rs_surface_buffer_callback.h" -#include "ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/rs_surface_buffer_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSSurfaceBufferCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp index f24188e40b..4adeae4d7c 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.cpp @@ -22,12 +22,6 @@ namespace Rosen { int RSSurfaceOcclusionChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSSurfaceOcclusionChangeCallbackStub::OnRemoteRequest " - "no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSISurfaceOcclusionChangeCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -49,8 +43,5 @@ int RSSurfaceOcclusionChangeCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSSurfaceOcclusionChangeCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.h index 7885256ed3..a57c44bb71 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_surface_occlusion_change_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/rs_isurface_occlusion_change_callback.h" -#include "ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSSurfaceOcclusionChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.cpp index 829239135e..bc242e632b 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.cpp @@ -22,11 +22,6 @@ namespace Rosen { int RSUIExtensionCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSUIExtensionCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIUIExtensionCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -48,8 +43,5 @@ int RSUIExtensionCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSUIExtensionCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.h index 9b36f69acb..e4c52dd934 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/rs_uiextension_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/rs_iuiextension_callback.h" -#include "ipc_callbacks/rs_iuiextension_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/rs_iuiextension_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSUIExtensionCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index a4f1f49ce5..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSIScreenChangeCallbackInterfaceCodeAccessVerifier::RSIScreenChangeCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSIScreenChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_SCREEN_CHANGED): { - hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_SCREEN_CHANGED"); - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.cpp index f38aa1a237..6c81a0bc2b 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.cpp @@ -20,11 +20,6 @@ namespace Rosen { int RSScreenChangeCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSScreenChangeCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSIScreenChangeCallback::GetDescriptor()) { return ERR_INVALID_STATE; @@ -46,8 +41,5 @@ int RSScreenChangeCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSScreenChangeCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.h index bb3f63885f..d8466a7f82 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/screen_change_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/screen_change_callback.h" -#include "ipc_callbacks/screen_change_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/screen_change_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSScreenChangeCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp deleted file mode 100644 index c97af5350b..0000000000 --- a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 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 "ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier::RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier() -{ - CheckCodeUnderlyingTypeStandardized(codeEnumTypeName_); -} - -bool RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code) -{ - bool hasPermission = true; - switch (code) { - case static_cast(CodeEnumType::ON_SURFACE_CAPTURE): { - /* to implement access interception */ - break; - } - default: { - break; - } - } - return hasPermission; -} -} // namespace Rosen -} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.cpp b/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.cpp index 9979f7e41b..464d356052 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.cpp +++ b/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.cpp @@ -21,11 +21,6 @@ namespace Rosen { int RSSurfaceCaptureCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - if (!securityManager_.IsInterfaceCodeAccessible(code)) { - RS_LOGE("RSSurfaceCaptureCallbackStub::OnRemoteRequest no permission to access codeID=%{public}u.", code); - return ERR_INVALID_STATE; - } - auto token = data.ReadInterfaceToken(); if (token != RSISurfaceCaptureCallback::GetDescriptor()) { ROSEN_LOGE("RSSurfaceCaptureCallbackStub: token ERR_INVALID_STATE"); @@ -47,8 +42,5 @@ int RSSurfaceCaptureCallbackStub::OnRemoteRequest( return ret; } - -const RSInterfaceCodeSecurityManager RSSurfaceCaptureCallbackStub::securityManager_ = \ - RSInterfaceCodeSecurityManager::CreateInstance(); } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.h b/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.h index a5e0be718e..867cc115a2 100644 --- a/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.h +++ b/rosen/modules/render_service_base/src/ipc_callbacks/surface_capture_callback_stub.h @@ -19,8 +19,7 @@ #include #include "common/rs_macros.h" #include "ipc_callbacks/surface_capture_callback.h" -#include "ipc_callbacks/surface_capture_callback_ipc_interface_code_access_verifier.h" -#include "ipc_security/rs_ipc_interface_code_security_manager.h" +#include "ipc_callbacks/surface_capture_callback_ipc_interface_code.h" namespace OHOS { namespace Rosen { @@ -30,9 +29,6 @@ public: ~RSSurfaceCaptureCallbackStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - static const RSInterfaceCodeSecurityManager securityManager_; }; } // namespace Rosen } // namespace OHOS diff --git a/rosen/test/render_service/BUILD.gn b/rosen/test/render_service/BUILD.gn index ea0a05510f..bbfca256d2 100755 --- a/rosen/test/render_service/BUILD.gn +++ b/rosen/test/render_service/BUILD.gn @@ -54,7 +54,6 @@ group("test") { "render_service_base/fuzztest/rsframereport_fuzzer:fuzztest", "render_service_base/fuzztest/rsfunctionaldelegate_fuzzer:fuzztest", "render_service_base/fuzztest/rsgpuoverdrawcanvaslistener_fuzzer:fuzztest", - "render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer:fuzztest", "render_service_base/fuzztest/rslineargradientblurshaderfilter_fuzzer:fuzztest", "render_service_base/fuzztest/rslistenedcanvas_fuzzer:fuzztest", "render_service_base/fuzztest/rslog_fuzzer:fuzztest", diff --git a/rosen/test/render_service/render_service/unittest/transaction/BUILD.gn b/rosen/test/render_service/render_service/unittest/transaction/BUILD.gn index b5be36de71..63bf3f50de 100644 --- a/rosen/test/render_service/render_service/unittest/transaction/BUILD.gn +++ b/rosen/test/render_service/render_service/unittest/transaction/BUILD.gn @@ -13,6 +13,7 @@ import("//build/test.gni") import("//foundation/graphic/graphic_2d/graphic_config.gni") +import("$graphic_2d_root/rosen/modules/render_service_base/config.gni") module_output_path = "graphic/rosen_engine/render_service/transaction" @@ -20,6 +21,7 @@ group("unittest") { testonly = true deps = [ + ":RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest", ":RSRenderServiceConnectionStubTest", ":RSRenderServiceStubTest", ] @@ -30,6 +32,28 @@ config("pipeline_test") { include_dirs = [ "$graphic_2d_root/rosen/modules/render_service/core" ] } +## Build RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest +ohos_unittest("RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest") { + module_out_path = module_output_path + sources = [ + "rs_irender_service_connection_ipc_interface_code_access_verifier_test.cpp", + ] + deps = [ ":rs_test_common" ] + external_deps = [] + if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) { + external_deps += [ "sensor:sensor_interface_native" ] + } + defines = [] + defines += gpu_defines + if (defined(enable_ipc_security) && enable_ipc_security) { + defines += [ "ENABLE_IPC_SECURITY" ] + external_deps += [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + ] + } +} + ## Build RSRenderServiceConnectionStubTest ohos_unittest("RSRenderServiceConnectionStubTest") { module_out_path = module_output_path @@ -63,6 +87,7 @@ config("rs_test_common_public_config") { "$graphic_2d_root/rosen/modules/hyper_graphic_manager/core/config", "$graphic_2d_root/rosen/modules/render_service/core", "$graphic_2d_root/rosen/modules/render_service_client/core", + "$graphic_2d_root/rosen/modules/render_service_base/include", "$graphic_2d_root/rosen/modules/render_service_base/src", "$graphic_2d_root/rosen/test/include", "$memmgr_plugin_root/interface/innerkits/include", diff --git a/rosen/test/render_service/render_service/unittest/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier_test.cpp b/rosen/test/render_service/render_service/unittest/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier_test.cpp new file mode 100644 index 0000000000..9053c746a9 --- /dev/null +++ b/rosen/test/render_service/render_service/unittest/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier_test.cpp @@ -0,0 +1,221 @@ +/* + * 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 +#include "platform/ohos/rs_irender_service_connection_ipc_interface_code_access_verifier.h" + +namespace OHOS::Rosen { +class RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest::SetUpTestCase() {} +void RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest::TearDownTestCase() {} +void RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest::SetUp() {} +void RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest::TearDown() {} + +/** + * @tc.name: IsInterfaceCodeAccessibleTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, IsInterfaceCodeAccessibleTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType code = 0; + ASSERT_EQ(verifier->IsInterfaceCodeAccessible(code), true); +} + +/** + * @tc.name: IsSystemCallingTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, IsSystemCallingTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + const std::string callingCode = "test"; + ASSERT_EQ(verifier->IsSystemCalling(callingCode), true); +} + +#ifdef ENABLE_IPC_SECURITY +/** + * @tc.name: CheckNativePermissionTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, CheckNativePermissionTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType interfaceName = + static_cast(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE); + auto permissions = verifier->GetPermissions(interfaceName); + auto tokenID = verifier->GetTokenID(); + for (auto& permission : permissions) { + ASSERT_EQ(verifier->CheckNativePermission(tokenID, permission), false); + } +} + +/** + * @tc.name: CheckHapPermissionTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, CheckHapPermissionTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType interfaceName = + static_cast(RSIRenderServiceConnectionInterfaceCode::TAKE_SURFACE_CAPTURE); + auto permissions = verifier->GetPermissions(interfaceName); + auto tokenID = verifier->GetTokenID(); + for (auto& permission : permissions) { + ASSERT_EQ(verifier->CheckHapPermission(tokenID, permission), false); + } +} + +/** + * @tc.name: PermissionEnumToStringTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, PermissionEnumToStringTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + PermissionType permission = PermissionType::CAPTURE_SCREEN; + ASSERT_TRUE(verifier->PermissionEnumToString(permission) != "unknown"); +} + +/** + * @tc.name: AddPermissionTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, AddPermissionTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType interfaceName = 0; + const std::string newPermission = "CAPTURE_SCREEN"; + ASSERT_EQ(verifier->AddPermission(interfaceName, newPermission), true); +} + +/** + * @tc.name: GetPermissionsTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, GetPermissionsTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType interfaceName = 0; + const std::string newPermission = "CAPTURE_SCREEN"; + auto ret = verifier->GetPermissions(interfaceName); + ASSERT_EQ(ret.empty(), true); + verifier->AddPermission(interfaceName, newPermission); + ret = verifier->GetPermissions(interfaceName); + ASSERT_EQ(ret.empty(), false); +} + +/** + * @tc.name: GetInterfacePermissionSizeTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, GetInterfacePermissionSizeTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + bool isPermissionSizeEmpty = (verifier->GetInterfacePermissionSize() == 0); + EXPECT_FALSE(isPermissionSizeEmpty); +} + +/** + * @tc.name: IsSystemAppTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, IsSystemAppTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + ASSERT_EQ(verifier->IsSystemApp(), false); +} +#endif + +/** + * @tc.name: CheckPermissionTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, CheckPermissionTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType code = 0; + ASSERT_EQ(verifier->CheckPermission(code), true); +} + +/** + * @tc.name: IsStylusServiceCallingTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, IsStylusServiceCallingTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + const std::string callingCode = "test"; +#ifdef ENABLE_IPC_SECURITY + ASSERT_EQ(verifier->IsStylusServiceCalling(callingCode), false); +#else + ASSERT_EQ(verifier->IsStylusServiceCalling(callingCode), true); +#endif +} + +/** + * @tc.name: IsCommonVerificationPassedTest001 + * @tc.desc: test + * @tc.type: FUNC + * @tc.require: issue#IAS6LQ + */ +HWTEST_F(RSIRenderServiceConnectionIpcInterfaceCodeAccessVerifierTest, IsCommonVerificationPassedTest001, + testing::ext::TestSize.Level1) +{ + auto verifier = std::make_unique(); + CodeUnderlyingType code = 0; + ASSERT_EQ(verifier->IsCommonVerificationPassed(code), true); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/BUILD.gn b/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/BUILD.gn deleted file mode 100755 index 506d746774..0000000000 --- a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/BUILD.gn +++ /dev/null @@ -1,61 +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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "graphic_2d/graphic_2d" - -##############################fuzztest########################################## -ohos_fuzztest( - "RSIsurfaceOcclusionChangeCallbackIpcInterfaceCodeAccessVerifierFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "../../../../../test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer" - include_dirs = [ - "../../../../../modules/render_service_base/src", - "../../../../../modules/2d_graphics/include", - "../../../../../modules/render_service_base/include", - ] - deps = [ - "../../../../../modules/2d_graphics:2d_graphics", - "../../../../../modules/render_service:librender_service", - "../../../../../modules/render_service_base:librender_service_base", - "../../../../../modules/render_service_base:librender_service_base_static", - "../../../../../modules/render_service_client:librender_service_client", - "../../../../../modules/render_service_client:render_service_client_src", - ] - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-Dprivate=public", - "-Dprotected=public", - ] - sources = [ "rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.cpp" ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":RSIsurfaceOcclusionChangeCallbackIpcInterfaceCodeAccessVerifierFuzzTest", - ] -} -############################################################################### diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/corpus/init b/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/corpus/init deleted file mode 100755 index e7c3fecd8d..0000000000 --- a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/corpus/init +++ /dev/null @@ -1,14 +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. - -FUZZ \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/project.xml b/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/project.xml deleted file mode 100755 index 61d63a0715..0000000000 --- a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.cpp b/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.cpp deleted file mode 100755 index 1ab513a71d..0000000000 --- a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.cpp +++ /dev/null @@ -1,78 +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 "rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ipc_callbacks/rs_isurface_occlusion_change_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS { -namespace Rosen { -namespace { -const uint8_t* g_data = nullptr; -size_t g_size = 0; -size_t g_pos; -} // namespace - -template -T GetData() -{ - T object {}; - size_t objectSize = sizeof(object); - if (g_data == nullptr || objectSize > g_size - g_pos) { - return object; - } - errno_t ret = memcpy_s(&object, objectSize, g_data + g_pos, objectSize); - if (ret != EOK) { - return {}; - } - g_pos += objectSize; - return object; -} -bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) -{ - if (data == nullptr) { - return false; - } - - // initialize - g_data = data; - g_size = size; - g_pos = 0; - uint32_t code = GetData(); - RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier - rsISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier; - rsISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier.IsExclusiveVerificationPassed(code); - return true; -} -} // namespace Rosen -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::Rosen::DoSomethingInterestingWithMyAPI(data, size); - return 0; -} diff --git a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.h b/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.h deleted file mode 100755 index edbfcc0d09..0000000000 --- a/rosen/test/render_service/render_service_base/fuzztest/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer/rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer.h +++ /dev/null @@ -1,20 +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. - */ -#ifndef RSISURFACEOCCLUSIONCHANGECALLBACKIPCINTERFACECODEACCESSVERIFIER_FUZZER_H -#define RSISURFACEOCCLUSIONCHANGECALLBACKIPCINTERFACECODEACCESSVERIFIER_FUZZER_H - -#define FUZZ_PROJECT_NAME "rsisurfaceocclusionchangecallbackipcinterfacecodeaccessverifier_fuzzer" - -#endif // RSISURFACEOCCLUSIONCHANGECALLBACKIPCINTERFACECODEACCESSVERIFIER_FUZZER_H \ No newline at end of file diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/BUILD.gn index aec8c9ee6b..dd325db4dc 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/BUILD.gn @@ -27,7 +27,6 @@ ohos_unittest("RSRenderServiceBaseIpcCallBacksTest") { "buffer_clear_callback_stub_test.cpp", "hgm_config_change_callback_proxy_test.cpp", "hgm_config_change_callback_stub_test.cpp", - "rs_ihgm_config_change_callback_ipc_interface_code_access_verifier_test.cpp", "rs_occlusion_change_callback_proxy_test.cpp", "rs_occlusion_change_callback_stub_test.cpp", "rs_rt_refresh_callback_test.cpp", diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_available_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_available_callback_stub_test.cpp index 984a8d96d5..3977329942 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_available_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_available_callback_stub_test.cpp @@ -57,7 +57,6 @@ HWTEST_F(RSBufferAvailableCallbackStubTest, OnRemoteRequest001, TestSize.Level1) int res = rsBufferAvailableCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); code = static_cast(RSIBufferAvailableCallbackInterfaceCode::ON_BUFFER_AVAILABLE); - EXPECT_TRUE(RSBufferAvailableCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); res = rsBufferAvailableCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); @@ -77,7 +76,6 @@ HWTEST_F(RSBufferAvailableCallbackStubTest, OnRemoteRequest002, TestSize.Level1) auto rsBufferAvailableCallbackStub = std::make_shared(); auto code = static_cast(RSIBufferAvailableCallbackInterfaceCode::ON_BUFFER_AVAILABLE); data.WriteInterfaceToken(RSIBufferAvailableCallback::GetDescriptor()); - EXPECT_TRUE(RSBufferAvailableCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsBufferAvailableCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_NONE); diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_clear_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_clear_callback_stub_test.cpp index 2030c69843..f2acfe5aa4 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_clear_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/buffer_clear_callback_stub_test.cpp @@ -57,7 +57,6 @@ HWTEST_F(RSBufferClearCallbackStubTest, OnRemoteRequest001, TestSize.Level1) int res = rsBufferClearCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); code = static_cast(RSIBufferClearCallbackInterfaceCode::ON_BUFFER_CLEAR); - EXPECT_TRUE(RSBufferClearCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); res = rsBufferClearCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); @@ -77,7 +76,6 @@ HWTEST_F(RSBufferClearCallbackStubTest, OnRemoteRequest002, TestSize.Level1) auto rsBufferClearCallbackStub = std::make_shared(); auto code = static_cast(RSIBufferClearCallbackInterfaceCode::ON_BUFFER_CLEAR); data.WriteInterfaceToken(RSIBufferClearCallback::GetDescriptor()); - EXPECT_TRUE(RSBufferClearCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsBufferClearCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_NONE); diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/hgm_config_change_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/hgm_config_change_callback_stub_test.cpp index f57735dbe1..f67a7fbf31 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/hgm_config_change_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/hgm_config_change_callback_stub_test.cpp @@ -117,7 +117,6 @@ HWTEST_F(RSHgmConfigChangeCallbackStubTest, OnRemoteRequest004, TestSize.Level1) auto code = static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_CONFIG_CHANGED); data.WriteInterfaceToken(RSIHgmConfigChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSHgmConfigChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(ERR_NONE, res); } @@ -135,7 +134,6 @@ HWTEST_F(RSHgmConfigChangeCallbackStubTest, OnRemoteRequest005, TestSize.Level1) auto code = static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_MODE_CHANGED); data.WriteInterfaceToken(RSIHgmConfigChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSHgmConfigChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(ERR_NONE, res); } @@ -153,7 +151,6 @@ HWTEST_F(RSHgmConfigChangeCallbackStubTest, OnRemoteRequest006, TestSize.Level1) auto code = static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_CHANGED); data.WriteInterfaceToken(RSIHgmConfigChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSHgmConfigChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(ERR_NONE, res); } diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier_test.cpp deleted file mode 100644 index 4edd768e64..0000000000 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier_test.cpp +++ /dev/null @@ -1,84 +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 "gtest/gtest.h" -#include "ipc_callbacks/rs_ihgm_config_change_callback_ipc_interface_code_access_verifier.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS::Rosen { -class RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; -}; - -void RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest::SetUpTestCase() {} -void RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest::TearDownTestCase() {} -void RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest::SetUp() {} -void RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest::TearDown() {} - -/** - * @tc.name: IsExclusiveVerificationPassed001 - * @tc.desc: Verify function IsExclusiveVerificationPassed incorrect code - * @tc.type: FUNC - */ -HWTEST_F(RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest, IsExclusiveVerificationPassed001, TestSize.Level1) -{ - RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier verifier; - ASSERT_TRUE(verifier.IsExclusiveVerificationPassed(-1)); -} - -/** - * @tc.name: IsExclusiveVerificationPassed002 - * @tc.desc: Verify function IsExclusiveVerificationPassed code: ON_HGM_CONFIG_CHANGED - * @tc.type: FUNC - */ -HWTEST_F(RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest, IsExclusiveVerificationPassed002, TestSize.Level1) -{ - auto code = static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_CONFIG_CHANGED); - RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier verifier; - ASSERT_TRUE(verifier.IsExclusiveVerificationPassed(code)); -} - -/** - * @tc.name: IsExclusiveVerificationPassed003 - * @tc.desc: Verify function IsExclusiveVerificationPassed code: ON_HGM_REFRESH_RATE_MODE_CHANGED - * @tc.type: FUNC - */ -HWTEST_F(RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest, IsExclusiveVerificationPassed003, TestSize.Level1) -{ - auto code = - static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_MODE_CHANGED); - RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier verifier; - ASSERT_TRUE(verifier.IsExclusiveVerificationPassed(code)); -} - -/** - * @tc.name: IsExclusiveVerificationPassed004 - * @tc.desc: Verify function IsExclusiveVerificationPassed code: ON_HGM_REFRESH_RATE_CHANGED - * @tc.type: FUNC - */ -HWTEST_F(RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifierTest, IsExclusiveVerificationPassed004, TestSize.Level1) -{ - auto code = static_cast(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_CHANGED); - RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier verifier; - ASSERT_TRUE(verifier.IsExclusiveVerificationPassed(code)); -} - -} // namespace OHOS::Rosen diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_occlusion_change_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_occlusion_change_callback_stub_test.cpp index 4b8b8b39d7..cf75c34d08 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_occlusion_change_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_occlusion_change_callback_stub_test.cpp @@ -57,7 +57,6 @@ HWTEST_F(RSOcclusionChangeCallbackStubTest, OnRemoteRequest001, TestSize.Level1) int res = rsOcclusionChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); code = static_cast(RSIOcclusionChangeCallbackInterfaceCode::ON_OCCLUSION_VISIBLE_CHANGED); - EXPECT_TRUE(RSOcclusionChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); res = rsOcclusionChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); @@ -77,7 +76,6 @@ HWTEST_F(RSOcclusionChangeCallbackStubTest, OnRemoteRequest002, TestSize.Level1) auto rsOcclusionChangeCallbackStub = std::make_shared(); auto code = static_cast(RSIOcclusionChangeCallbackInterfaceCode::ON_OCCLUSION_VISIBLE_CHANGED); data.WriteInterfaceToken(RSIOcclusionChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSOcclusionChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsOcclusionChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_NONE); @@ -96,7 +94,6 @@ HWTEST_F(RSOcclusionChangeCallbackStubTest, OnRemoteRequest003, TestSize.Level1) auto rsOcclusionChangeCallbackStub = std::make_shared(); uint32_t code = 1; data.WriteInterfaceToken(RSIOcclusionChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSOcclusionChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsOcclusionChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res != ERR_NONE); } diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_surface_occlusion_change_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_surface_occlusion_change_callback_stub_test.cpp index bacb7b09dc..27e13b63de 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_surface_occlusion_change_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_surface_occlusion_change_callback_stub_test.cpp @@ -81,7 +81,6 @@ HWTEST_F(RSSurfaceOcclusionChangeCallbackStubTest, OnRemoteRequest002, TestSize. uint32_t code = static_cast(RSISurfaceOcclusionChangeCallbackInterfaceCode::ON_SURFACE_OCCLUSION_VISIBLE_CHANGED); - EXPECT_TRUE(RSSurfaceOcclusionChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(res, ERR_INVALID_STATE); @@ -121,7 +120,6 @@ HWTEST_F(RSSurfaceOcclusionChangeCallbackStubTest, OnRemoteRequest004, TestSize. uint32_t code = static_cast(RSISurfaceOcclusionChangeCallbackInterfaceCode::ON_SURFACE_OCCLUSION_VISIBLE_CHANGED); data.WriteInterfaceToken(RSISurfaceOcclusionChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSSurfaceOcclusionChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(res, ERR_NONE); diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_uiextension_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_uiextension_callback_stub_test.cpp index 7c280b916c..8405b118c9 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_uiextension_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/rs_uiextension_callback_stub_test.cpp @@ -57,7 +57,6 @@ HWTEST_F(RSUIExtensionCallbackStubTest, OnRemoteRequest001, TestSize.Level1) int res = rsUiExtensionCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); code = static_cast(RSIUIExtensionCallbackInterfaceCode::ON_UIEXTENSION); - EXPECT_TRUE(RSUIExtensionCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); res = rsUiExtensionCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); @@ -77,7 +76,6 @@ HWTEST_F(RSUIExtensionCallbackStubTest, OnRemoteRequest002, TestSize.Level1) auto rsUiExtensionCallbackStub = std::make_shared(); auto code = static_cast(RSIUIExtensionCallbackInterfaceCode::ON_UIEXTENSION); data.WriteInterfaceToken(RSIUIExtensionCallback::GetDescriptor()); - EXPECT_TRUE(RSUIExtensionCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsUiExtensionCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_NONE); diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/screen_change_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/screen_change_callback_stub_test.cpp index 05ccbe379f..55b9c26377 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/screen_change_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/screen_change_callback_stub_test.cpp @@ -55,7 +55,6 @@ HWTEST_F(RSScreenChangeCallbackStubTest, OnRemoteRequest001, TestSize.Level1) ASSERT_NE(rsScreenChangeCallbackStub, nullptr); auto code = static_cast(RSIScreenChangeCallbackInterfaceCode::ON_SCREEN_CHANGED); data.WriteInterfaceToken(RSIScreenChangeCallback::GetDescriptor()); - EXPECT_TRUE(RSScreenChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsScreenChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_NONE); } @@ -90,7 +89,6 @@ HWTEST_F(RSScreenChangeCallbackStubTest, OnRemoteRequest003, TestSize.Level1) auto rsScreenChangeCallbackStub = std::make_shared(); ASSERT_NE(rsScreenChangeCallbackStub, nullptr); uint32_t code = static_cast(RSIScreenChangeCallbackInterfaceCode::ON_SCREEN_CHANGED); - EXPECT_TRUE(RSScreenChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = rsScreenChangeCallbackStub->OnRemoteRequest(code, data, reply, option); EXPECT_TRUE(res == ERR_INVALID_STATE); } diff --git a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/surface_capture_callback_stub_test.cpp b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/surface_capture_callback_stub_test.cpp index 69db6f0c75..21c6464a9e 100644 --- a/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/surface_capture_callback_stub_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/ipc_callbacks/surface_capture_callback_stub_test.cpp @@ -63,7 +63,6 @@ HWTEST_F(RSSurfaceCaptureCallbackStubTest, OnRemoteRequest001, TestSize.Level1) MessageOption option; uint32_t code = static_cast(RSISurfaceCaptureCallbackInterfaceCode::ON_SURFACE_CAPTURE); - EXPECT_TRUE(RSSurfaceCaptureCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code)); int res = stub->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(res, ERR_INVALID_STATE); diff --git a/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn b/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn index 7e6171cf74..265a089ba2 100644 --- a/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn +++ b/rosen/test/render_service/render_service_base/unittest/memory/BUILD.gn @@ -26,17 +26,7 @@ ohos_unittest("RSRenderServiceBaseMemoryTest") { defines += [ "USE_ROSEN_DRAWING" ] } - if (defined(enable_ipc_security) && enable_ipc_security) { - defines += [ "ENABLE_IPC_SECURITY" ] - external_deps += [ - "access_token:libaccesstoken_sdk", - "access_token:libtokenid_sdk", - "ipc:ipc_core", - ] - } - sources = [ - "rs_interface_code_access_verifier_base_test.cpp", "rs_memory_graphic_test.cpp", "rs_memory_track_test.cpp", "rs_tag_tracker_test.cpp", diff --git a/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp b/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp deleted file mode 100644 index 118afef3de..0000000000 --- a/rosen/test/render_service/render_service_base/unittest/memory/rs_interface_code_access_verifier_base_test.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2023 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 -#include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" -#include "platform/ohos/rs_irender_service_connection_ipc_interface_code_access_verifier.h" -#include "ipc_callbacks/buffer_available_callback_ipc_interface_code_access_verifier.h" - -namespace OHOS::Rosen { -class RSInterfaceCodeAccessVerifierBaseTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; -}; - -void RSInterfaceCodeAccessVerifierBaseTest::SetUpTestCase() {} -void RSInterfaceCodeAccessVerifierBaseTest::TearDownTestCase() {} -void RSInterfaceCodeAccessVerifierBaseTest::SetUp() {} -void RSInterfaceCodeAccessVerifierBaseTest::TearDown() {} - -/** - * @tc.name: IsSystemCallingTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsSystemCallingTest, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - const std::string callingCode = "test"; - ASSERT_EQ(verifier->IsSystemCalling(callingCode), true); -} - -/** - * @tc.name: CheckPermissionTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckPermissionTest001, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - CodeUnderlyingType code = 0; - ASSERT_EQ(verifier->CheckPermission(code), true); -} - -/** - * @tc.name: IsCommonVerificationPassedTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsCommonVerificationPassedTest, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - CodeUnderlyingType code = 0; - ASSERT_EQ(verifier->IsCommonVerificationPassed(code), true); -} - -/** - * @tc.name: IsStylusServiceCallingTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require:IAOZFC - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsStylusServiceCallingTest, testing::ext::TestSize.Level1) -{ - const std::string callingCode = "RSInterfaceCodeAccessVerifierBaseTest::IsStylusServiceCallingTest"; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsStylusServiceCalling(callingCode), true); -} -#ifdef ENABLE_IPC_SECURITY -/** - * @tc.name: IsInterfaceCodeAccessibleTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsInterfaceCodeAccessibleTest001, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType code = 0; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsInterfaceCodeAccessible(code), true); -} - -/** - * @tc.name: IsInterfaceCodeAccessibleTest002 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsInterfaceCodeAccessibleTest002, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType code = 0; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsInterfaceCodeAccessible(code), true); -} - -/** - * @tc.name: CheckNativePermissionTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckNativePermissionTest, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType interfaceName = 1.0; - auto verifier = std::make_unique(); - auto permissions = verifier->GetPermissions(interfaceName); - auto tokenID = verifier->GetTokenID(); - for (auto& permission : permissions) { - ASSERT_EQ(verifier->CheckNativePermission(tokenID, permission), true); - } -} - -/** - * @tc.name: CheckHapPermissionTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckHapPermissionTest, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType interfaceName = 1.0; - auto verifier = std::make_unique(); - auto permissions = verifier->GetPermissions(interfaceName); - auto tokenID = verifier->GetTokenID(); - for (auto& permission : permissions) { - ASSERT_EQ(verifier->CheckHapPermission(tokenID, permission), true); - } -} - -/** - * @tc.name: CheckPermissionTest002 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, CheckPermissionTest002, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType code = 0; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->CheckPermission(code), true); -} - -/** - * @tc.name: PermissionEnumToStringTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, PermissionEnumToStringTest001, testing::ext::TestSize.Level1) -{ - PermissionType permission = PermissionType::CAPTURE_SCREEN; - auto verifier = std::make_unique(); - ASSERT_TRUE(verifier->PermissionEnumToString(permission) != "unknown"); -} - - -/** - * @tc.name: AddPermissionTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, AddPermissionTest, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType interfaceName = 1.0; - const std::string newPermission = "CAPTURE_SCREEN"; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->AddPermission(interfaceName, newPermission), true); -} - -/** - * @tc.name: GetPermissionsTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, GetPermissionsTest, testing::ext::TestSize.Level1) -{ - CodeUnderlyingType interfaceName = 1.0; - const std::string newPermission = "CAPTURE_SCREEN"; - auto verifier = std::make_unique(); - auto ret = verifier->GetPermissions(interfaceName); - ASSERT_EQ(ret.empty(), true); - verifier->AddPermission(interfaceName, newPermission); - ret = verifier->GetPermissions(interfaceName); - ASSERT_EQ(ret.empty(), false); -} - -/** - * @tc.name: GetInterfacePermissionSizeTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, GetInterfacePermissionSizeTest, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->GetInterfacePermissionSize(), 0); -} - -/** - * @tc.name: IsSystemAppTest - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsSystemAppTest, testing::ext::TestSize.Level1) -{ - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsSystemApp(), false); -} - -/** - * @tc.name: IsSystemCallingTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsSystemCallingTest001, testing::ext::TestSize.Level1) -{ - const std::string callingCode = "RSIOcclusionChangeCallbackInterfaceCode::ON_OCCLUSION_VISIBLE_CHANGED"; - auto verifier = std::make_unique(); - bool res = verifier->IsSystemCalling(callingCode); - ASSERT_EQ(res, true); -} - -/** - * @tc.name: IsStylusServiceCallingTest001 - * @tc.desc: test - * @tc.type: FUNC - * @tc.require:IAOZFC - */ -HWTEST_F(RSInterfaceCodeAccessVerifierBaseTest, IsStylusServiceCallingTest001, testing::ext::TestSize.Level1) -{ - const std::string callingCode = "RSInterfaceCodeAccessVerifierBaseTest::IsStylusServiceCallingTest001"; - auto verifier = std::make_unique(); - ASSERT_EQ(verifier->IsStylusServiceCalling(callingCode), false); -} -#endif -} // namespace OHOS::Rosen \ No newline at end of file