删除ipc_callbacks权限校验

Signed-off-by: 周思远 <zhousiyuan8@huawei.com>
This commit is contained in:
周思远 2024-09-19 15:07:29 +08:00
parent a327353f01
commit 7948fbdf2a
62 changed files with 256 additions and 1596 deletions

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIBufferAvailableCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_BUFFER_AVAILABLE): {
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIBufferClearCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_BUFFER_CLEAR): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSIBufferClearCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool IApplicationAgentInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::COMMIT_TRANSACTION): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<IApplicationAgentInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -20,8 +20,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_HGM_CONFIG_CHANGED): {
/* to implement access interception */
break;
}
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_HGM_REFRESH_RATE_MODE_CHANGED): {
/* to implement access interception */
break;
}
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_HGM_REFRESH_RATE_CHANGED): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_OCCLUSION_VISIBLE_CHANGED): {
hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_OCCLUSION_VISIBLE_CHANGED");
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(
CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_SURFACE_OCCLUSION_VISIBLE_CHANGED): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIUIExtensionCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(
CodeUnderlyingType code)
{
bool hasPermission = false;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_UIEXTENSION): {
hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_UIEXTENSION");
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSIOcclusionChangeCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSISurfaceBufferCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_FINISH): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSISurfaceBufferCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<RSISurfaceOcclusionChangeCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<RSIUIExtensionCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSIScreenChangeCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_SCREEN_CHANGED): {
hasPermission = IsSystemCalling(codeEnumTypeName_ + "::ON_SCREEN_CHANGED");
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSIScreenChangeCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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<CodeEnumType>(codeEnumTypeName_);
}
bool RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier::IsExclusiveVerificationPassed(CodeUnderlyingType code)
{
bool hasPermission = true;
switch (code) {
case static_cast<CodeUnderlyingType>(CodeEnumType::ON_SURFACE_CAPTURE): {
/* to implement access interception */
break;
}
default: {
break;
}
}
return hasPermission;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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<RSISurfaceCaptureCallbackInterfaceCodeAccessVerifier>();
} // namespace Rosen
} // namespace OHOS

View File

@ -19,8 +19,7 @@
#include <iremote_stub.h>
#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

View File

@ -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",

View File

@ -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",

View File

@ -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 <gtest/gtest.h>
#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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
CodeUnderlyingType interfaceName =
static_cast<CodeUnderlyingType>(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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
CodeUnderlyingType interfaceName =
static_cast<CodeUnderlyingType>(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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
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<RSIRenderServiceConnectionInterfaceCodeAccessVerifier>();
CodeUnderlyingType code = 0;
ASSERT_EQ(verifier->IsCommonVerificationPassed(code), true);
}
} // namespace OHOS::Rosen

View File

@ -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",
]
}
###############################################################################

View File

@ -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

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -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 <climits>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <hilog/log.h>
#include <securec.h>
#include <unistd.h>
#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<class T>
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<uint32_t>();
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;
}

View File

@ -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

View File

@ -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",

View File

@ -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<uint32_t>(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<RSBufferAvailableCallbackStubMock>();
auto code = static_cast<uint32_t>(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);

View File

@ -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<uint32_t>(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<RSBufferClearCallbackStubMock>();
auto code = static_cast<uint32_t>(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);

View File

@ -117,7 +117,6 @@ HWTEST_F(RSHgmConfigChangeCallbackStubTest, OnRemoteRequest004, TestSize.Level1)
auto code = static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(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);
}

View File

@ -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<CodeUnderlyingType>(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<CodeUnderlyingType>(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<CodeUnderlyingType>(RSIHgmConfigChangeCallbackInterfaceCode::ON_HGM_REFRESH_RATE_CHANGED);
RSIHgmConfigChangeCallbackInterfaceCodeAccessVerifier verifier;
ASSERT_TRUE(verifier.IsExclusiveVerificationPassed(code));
}
} // namespace OHOS::Rosen

View File

@ -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<uint32_t>(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<RSOcclusionChangeCallbackStubMock>();
auto code = static_cast<uint32_t>(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<RSOcclusionChangeCallbackStubMock>();
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);
}

View File

@ -81,7 +81,6 @@ HWTEST_F(RSSurfaceOcclusionChangeCallbackStubTest, OnRemoteRequest002, TestSize.
uint32_t code =
static_cast<uint32_t>(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<uint32_t>(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);

View File

@ -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<uint32_t>(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<RSUIExtensionCallbackStubMock>();
auto code = static_cast<uint32_t>(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);

View File

@ -55,7 +55,6 @@ HWTEST_F(RSScreenChangeCallbackStubTest, OnRemoteRequest001, TestSize.Level1)
ASSERT_NE(rsScreenChangeCallbackStub, nullptr);
auto code = static_cast<uint32_t>(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<RSScreenChangeCallbackStubMock>();
ASSERT_NE(rsScreenChangeCallbackStub, nullptr);
uint32_t code = static_cast<uint32_t>(RSIScreenChangeCallbackInterfaceCode::ON_SCREEN_CHANGED);
EXPECT_TRUE(RSScreenChangeCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code));
int res = rsScreenChangeCallbackStub->OnRemoteRequest(code, data, reply, option);
EXPECT_TRUE(res == ERR_INVALID_STATE);
}

View File

@ -63,7 +63,6 @@ HWTEST_F(RSSurfaceCaptureCallbackStubTest, OnRemoteRequest001, TestSize.Level1)
MessageOption option;
uint32_t code = static_cast<uint32_t>(RSISurfaceCaptureCallbackInterfaceCode::ON_SURFACE_CAPTURE);
EXPECT_TRUE(RSSurfaceCaptureCallbackStubMock::securityManager_.IsInterfaceCodeAccessible(code));
int res = stub->OnRemoteRequest(code, data, reply, option);
ASSERT_EQ(res, ERR_INVALID_STATE);

View File

@ -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",

View File

@ -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 <gtest/gtest.h>
#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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
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<RSIBufferAvailableCallbackInterfaceCodeAccessVerifier>();
ASSERT_EQ(verifier->IsStylusServiceCalling(callingCode), false);
}
#endif
} // namespace OHOS::Rosen