bounds_checking_function整改 Created-by: ding-qiaoqiao Commit-by: ding-qiaoqiao Merged-by: openharmony_ci Description: ### 关联的issue: https://gitcode.com/openharmony/security_security_component_manager/issues/412 ### 修改描述: c_utils仓去除public_external_deps标签整改 ### 测试用例(附上截图): TDD:  XTS:  手工用例:不涉及 ### 兼容性上库自检: - [x] 不涉及组件视觉效果发生变化 - [x] 不涉及组件布局调整 - [x] 不涉及组件交互体验发生变化 - [x] 不涉及组件动效发生变化 - [x] 不涉及组件无障碍、适老化、全球化规格变化 - [x] 不涉及API功能发生变化 - [x] 不涉及改变回调函数或生命周期的触发时机或时序,或删除生命周期和回调函数 - [x] 不涉及参数的规格发生了变化,例如取值范围缩小等 - [x] 不涉及对外接口新增权限校验 - [x] 不涉及接口的使用约束规格收紧,例如权限开放范围变化 - [x] 不涉及系统可创建的实例数量收紧 - [x] 不涉及修改了接口返回的数据 - [x] 未新增错误抛出,包括新增错误码、对已有的场景从不会抛错误码变成会抛出错误 - [x] 未修改已有的错误码,对于相同的输入原本抛出A错误码变成了抛出B错误码 - [x] 接口性能未出现明显劣化 ### 日志规范自检: - [x] 【规则】高频代码的正常流程中禁止打印日志 - [x] 【规则】在基本不可能发生的点必须要打印日志 - [x] 【规则】事件记录的日志使用who do what 主谓宾的形式打印 - [x] 【规则】状态变化的日志打印使用state_name:s1->s2, reason:msg的形式打印 - [x] 【规则】参数值的日志打印使用name1=value1, name2=value2…的形式打印 - [x] 【规则】代码运行成功的日志使用xxx successful的形式打印 - [x] 【规则】代码运行失败的日志使用xxx failed, please xxx的形式打印 ### 安全编码自检: - [x] 裸指针避免通过隐式转换构造为sptr - [x] json对象在取值之前必须先判断类型,避免类型不匹配 - [x] 序列化时必须对传入的数组大小进行校验,避免出现超大数组 - [x] 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 - [x] 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 - [x] 指针变量、表示资源描述符的变量、bool变量必须赋初值 - [x] readParcelable获取的对象使用前需要判空 - [x] 分配和释放内存的函数需要成对出现 - [x] 申请内存后异常退出前需要及时进行内存释放 - [x] 内存申请前必须对内存大小进行合法性校验 - [x] 内存分配后必须判断是否成功 - [x] 禁止使用realloc、alloc函数 - [x] 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 - [x] 禁止打印内存地址 - [x] 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 - [x] 禁止对有符号整数进行位操作符运算 - [x] 禁止对指针进行逻辑或位运算 - [x] 循环次数如果收外部数据控制,需要检验其合法性 - [x] 禁止使用内存操作类危险函数,需要使用安全函数 - [x] 谨慎使用不可重入函数 - [x] 必须检查安全函数的返回值,并进行正确处理 - [x] 禁止仅通过TokenType类型判断绕过权限校验 See merge request: openharmony/security_security_component_manager!435
Security Component Manager Service
Introduction
The security components are a set of ArkUI components provided by OpenHarmony, like <Button> and <Text>. You can integrate them to your application UI. When a security component is clicked, the application is granted temporary permissions and can access the user's private data without applying for permissions. This minimizes the interference of the authorization pop-up windows to users.
For example, if you integrate the LocationButton component into your application, you do not need to apply for the location permission. When the user clicks this component, the application can obtain the temporary location permission in the foreground and call the location service API to obtain location information.
The following figure illustrates the working mechanism of security components.
The security components are implemented by UX implementation and security component manager service. Integrated in the ArkUI framework, the UX implementation is responsible for drawing components. The security component manager service manages the security components, performs validity checks, and grants temporary permissions.
The security component manager service provides the following functions:
-
Provides native interfaces for registering or unregistering a security component, and granting temporary permissions to the application.
-
Checks the validity of security components. Only valid security components can be authorized successfully.
-
Provides native interfaces for the mediaLibrary service to query temporary permissions.
-
Provides APIs and adaptation layer for vendors to customize security enhancement functions.
Directory Structure
/base/security/security_component_manager
├── frameworks # Code of basic functionalities
│ ├── common # Common code
│ ├── enhance_adapter # Adaptation code for capability enhancement
│ └── security_component # Framework code of the security component service
├── interfaces # APIs
│ └── inner_api # Internal APIs
│ ├── enhance_kits # APIs for security component configuration
│ └── security_component # Security component service APIs
└── services # Services
└── security_component_service/sa
└── sa_main # System ability code of the security components
Usage
Available APIs
| API | Description |
|---|---|
| int32_t RegisterSecurityComponent(SecCompType type, std::string& componentInfo, int32_t& scId); | Registers a security component. |
| int32_t UpdateSecurityComponent(int32_t scId, std::string& componentInfo); | Updates security component information. |
| int32_t UnregisterSecurityComponent(int32_t scId); | Unregisters a security component. |
| int32_t ReportSecurityComponentClickEvent(SecCompInfo& SecCompInfo, sptr callerToken, OnFirstUseDialogCloseFunc&& callback, std::string& message); | Reports a click event to apply for temporary authorization. |
| bool VerifySavePermission(AccessToken::AccessTokenID tokenId); | Verifies saving permission. |
| int32_t PreRegisterSecCompProcess(); | Preregisters a security component. |
| bool IsServiceExist(); | Verifies whether security component service exists. |
| bool LoadService(); | Loads security component service. |
| bool IsSystemAppCalling(); | Verifies whether calling app is a system app. |
| bool HasCustomPermissionForSecComp(); | Verifies whether calling app has the permission "ohos.permission.CUSTOMIZE_SAVE_BUTTON". |
| int32_t SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen); | Sets enhanced configuration of the security component for multimodal services. |
| int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, uint8_t* enhanceData, uint32_t& enHancedataLen); | Obtains security enhancement data of the click event for multimodal services. |
