mirror of
https://github.com/openharmony/security_security_component_manager.git
synced 2026-08-24 22:51:27 -04:00
!391 merge master into master
feat: Add claude.md Created-by: harylee Commit-by: Haryslee Merged-by: openharmony_ci Description: ### 关联的issue: https://gitcode.com/openharmony/security_security_component_manager/issues/358 ### 修改描述: add claude.md ### 测试用例(附上截图): TDD: NA XTS: NA 手工用例: NA ### 兼容性上库自检: - [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!391
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Overview
|
||||
|
||||
This is the OpenHarmony Security Component Manager Service - a system ability (SA ID: 3506) that allows applications to access temporary permissions through UI components without permanent authorization. When a user clicks a security component (e.g., PasteButton, SaveButton), the app receives temporary permission to access sensitive data.
|
||||
|
||||
## Build System
|
||||
|
||||
This project uses OpenHarmony's GN (Generate Ninja) build system.
|
||||
|
||||
**Main build files:**
|
||||
- `BUILD.gn` - Main build configuration
|
||||
- `security_component.gni` - Feature flags for enhancement capabilities
|
||||
- `bundle.json` - Component metadata and dependencies
|
||||
|
||||
**Build targets:**
|
||||
- `security_component_build_module` - Main service module
|
||||
- `security_component_build_module_test` - Unit tests
|
||||
- `security_component_build_fuzz_test` - Fuzz tests
|
||||
|
||||
**Build commands:**
|
||||
```bash
|
||||
# Build main service
|
||||
./build.sh --product-name <product> --build-variant root --build-target security_component_manager
|
||||
|
||||
# Build tests
|
||||
./build.sh --product-name <product> --build-variant root --build-target security_component_build_module_test
|
||||
./build.sh --product-name <product> --build-variant root --build-target security_component_build_fuzz_test
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
The codebase follows OpenHarmony's System Ability pattern with three main layers:
|
||||
|
||||
### 1. Service Layer (`services/security_component_service/sa/`)
|
||||
- `SecCompService` - Main SystemAbility class, inherits from `SystemAbility`
|
||||
- `SecCompManager` - Core business logic manager (singleton pattern)
|
||||
- `SecCompEntity` - Represents individual security components
|
||||
- `AppStateObserver` - Monitors app lifecycle (foreground/background transitions)
|
||||
|
||||
### 2. Framework Layer (`frameworks/`)
|
||||
- `security_component/` - Core framework implementation
|
||||
- `enhance_adapter/` - Adaptation layer for vendor enhancements
|
||||
- `common/` - Shared utilities and base classes
|
||||
|
||||
### 3. Interface Layer (`interfaces/inner_api/`)
|
||||
- `security_component/` - Main service APIs (register, update, unregister, report click)
|
||||
- `enhance_kits/` - Enhancement configuration APIs
|
||||
- `security_component_common/` - Common utilities and definitions
|
||||
|
||||
## Component Types
|
||||
|
||||
- `PasteButton` - Clipboard access
|
||||
- `SaveButton` - Save operations
|
||||
|
||||
## Testing
|
||||
|
||||
**Unit tests:** `frameworks/*/test/` and `services/*/test/unittest/`
|
||||
**Fuzz tests:** `test/fuzztest/security_component/` - Tests all major APIs
|
||||
**Test mocks:** `test/fuzztest/security_component/mock/`
|
||||
|
||||
## Important Design Patterns
|
||||
|
||||
- **Singleton**: `SecCompManager` manages global state
|
||||
- **Observer**: `AppStateObserver` for app lifecycle events
|
||||
- **Factory**: Component creation and type handling
|
||||
- **Delayed tasks**: `DelayExitTask` for cleanup operations
|
||||
|
||||
## Dependencies
|
||||
|
||||
Key OpenHarmony components:
|
||||
- `samgr` - System Ability Manager
|
||||
- `ipc_core` - IPC communication
|
||||
- `access_token` - Permission tokens
|
||||
- `ability_runtime` - Application lifecycle
|
||||
- `window_manager` - Window management
|
||||
- `hilog` - Logging
|
||||
- `hisysevent` - System events
|
||||
Reference in New Issue
Block a user