mirror of
https://github.com/openharmony/security_access_token.git
synced 2026-08-24 06:33:12 -04:00
b9249d031e
fix ai security warnning Created-by: xia-bubai Commit-by: xia-bubai Merged-by: openharmony_ci Description: ### 关联的issue: https://gitcode.com/openharmony/security_access_token/issues/3551 1、TDD:  2、XTS: 3、手工用例(自验证步骤/预期结果/实际结果): - [x] 不涉及API功能发生变化 - [x] 不涉及改变回调函数或生命周期的触发时机或时序,或删除生命周期和回调函数 - [x] 不涉及参数的规格发生了变化,例如取值范围缩小等 - [x] 不涉及对外接口新增权限校验 - [x] 不涉及接口的使用约束规格收紧,例如权限开放范围变化 - [x] 不涉及系统可创建的实例数量收紧 - [x] 不涉及修改了接口返回的数据 - [x] 未新增错误抛出,包括新增错误码、对已有的场景从不会抛错误码变成会抛出错误 - [x] 未修改已有的错误码,对于相同的输入原本抛出A错误码变成了抛出B错误码 - [x] 接口性能未出现明显劣化 - [x] 是否需要合入权限定义 - [x] 仅向系统服务开放的权限(availableType为SERVICE的权限)不允许合入global_system_resources仓 - [x] 非SERVICE的权限与global_system_resources联合构建,即两笔pr关联同一个issue - [x] 填入必要参数name/grantMode/availableLevel/since/provisionEnable/distributedSceneEnable, 且与global_system_resources中声明(如果有)一致 - [x] 声明权限生效的设备平台范围deviceTypes,以列表方式声明("deviceTypes" : [ "xxx", "xxx"]),权限在所有设备通用为"general",非全平台生效按需填写,包括但不限于"phone"、"wearable"、"tablet"、"2in1"、"tv"、"car" - [x] 裸指针避免通过隐式转换构造为sptr - [x] json对象在取值之前必须先判断类型,避免类型不匹配 - [x] 序列化时必须对传入的数组大小进行校验,避免出现超大数组 - [x] 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 - [x] 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 - [x] 指针变量、表示资源描述符的变量、bool变量必须赋初值 - [x] readParcelable获取的对象使用前需要判空 - [x] 分配和释放内存的函数需要成对出现 - [x] 申请内存后异常退出前需要及时进行内存释放 - [x] 内存申请前必须对内存大小进行合法性校验 - [x] 内存分配后必须判断是否成功 - [x] 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 - [x] 禁止打印内存地址 - [x] 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 - [x] 禁止对有符号整数进行位操作符运算 - [x] 循环次数如果收外部数据控制,需要检验其合法性 - [x] 必须检查安全函数的返回值,并进行正确处理 - [x] 【规则】高频代码的正常流程中禁止打印日志 - [x] 【规则】在基本不可能发生的点必须要打印日志 - [x] 【规则】事件记录的日志使用who do what 主谓宾的形式打印 - [x] 【规则】状态变化的日志打印使用state_name:s1->s2, reason:msg的形式打印 - [x] 【规则】参数值的日志打印使用name1=value1, name2=value2…的形式打印 See merge request: openharmony/security_access_token!4825 AI[0%] Human Fixed[0%] Human[0%] AI Adopted[0%] Change-Id: I4a1dd9c4dfadde61215018bdf4218530f6219e8c
264 lines
8.9 KiB
Plaintext
264 lines
8.9 KiB
Plaintext
# Copyright (c) 2022-2026 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.
|
|
import("//build/ohos.gni")
|
|
|
|
access_token_path = "//base/security/access_token"
|
|
access_token_innerkit_path =
|
|
"//base/security/access_token/interfaces/innerkits/accesstoken"
|
|
module_output_path_interface_privacy =
|
|
"access_token/access_token/interface_privacy"
|
|
module_output_path_interface_access_token =
|
|
"access_token/access_token/interface_access_token"
|
|
module_output_path_service_privacy = "access_token/access_token/service_privacy"
|
|
module_output_path_service_access_token =
|
|
"access_token/access_token/service_access_token"
|
|
module_output_path_unittest_accesstoken = "access_token/access_token"
|
|
module_output_path_unittest_privacy = "access_token/privacy"
|
|
module_output_path_unittest_atm_tools = "access_token/tools"
|
|
|
|
declare_args() {
|
|
access_token_camera_float_window_enable = true
|
|
access_token_with_distributed_capability = true
|
|
access_token_enhance_capability = true
|
|
access_token_enable_manual_test = false
|
|
access_token_support_subprofile = false
|
|
access_token_privacy_bundle_start_stop_enable = false
|
|
}
|
|
|
|
# External dependencies for each feature flag
|
|
access_token_external_deps = []
|
|
|
|
access_token_cflags_cc = [ "-DHILOG_ENABLE" ]
|
|
|
|
# TEMP_PERMISSION_BACKGROUND_REVOKE_CAMERA_MIC_ENABLE is intentionally not enabled by default.
|
|
# Define it only when camera/microphone PERMISSION_ALLOW_THIS_TIME should be revoked
|
|
# on background transition and continuous-task state changes.
|
|
|
|
if (defined(product_name) &&
|
|
(product_name == "rk3568" || product_name == "standard")) {
|
|
access_token_cflags_cc +=
|
|
[ "-DACCESS_TOKEN_DEFAULT_MAX_QUERY_RESULT_SIZE=10000" ]
|
|
} else {
|
|
access_token_cflags_cc +=
|
|
[ "-DACCESS_TOKEN_DEFAULT_MAX_QUERY_RESULT_SIZE=20000" ]
|
|
}
|
|
|
|
if (use_libfuzzer) {
|
|
access_token_cflags_cc += [ "-DFUZZ_ENABLE" ]
|
|
}
|
|
|
|
if (access_token_enhance_capability == true) {
|
|
access_token_cflags_cc += [ "-DENHANCE_CAPABILITY" ]
|
|
}
|
|
|
|
if (access_token_enable_manual_test == true) {
|
|
access_token_cflags_cc += [ "-DENHANCE_MANUAL_TEST" ]
|
|
}
|
|
|
|
if (access_token_camera_float_window_enable == true) {
|
|
access_token_cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ]
|
|
}
|
|
|
|
if (access_token_support_subprofile) {
|
|
access_token_cflags_cc += [ "-DACCESS_TOKEN_SUPPORT_SUBPROFILE" ]
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
(defined(global_parts_info.distributedhardware_device_manager) &&
|
|
access_token_with_distributed_capability == true)) {
|
|
token_sync_enable = true
|
|
access_token_cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ]
|
|
access_token_external_deps += [ "device_manager:devicemanagersdk" ]
|
|
} else {
|
|
token_sync_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.security_dlp_permission_service)) {
|
|
dlp_permission_enable = true
|
|
access_token_cflags_cc += [ "-DSUPPORT_SANDBOX_APP" ]
|
|
} else {
|
|
dlp_permission_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.ability_ability_base)) {
|
|
ability_base_enable = true
|
|
} else {
|
|
ability_base_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.hiviewdfx_hicollie)) {
|
|
hicollie_enable = true
|
|
access_token_cflags_cc += [ "-DHICOLLIE_ENABLE" ]
|
|
access_token_external_deps += [ "hicollie:libhicollie" ]
|
|
} else {
|
|
hicollie_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.hiviewdfx_hitrace_native)) {
|
|
hiviewdfx_hitrace_native_enable = true
|
|
access_token_cflags_cc += [ "-DHITRACE_NATIVE_ENABLE" ]
|
|
access_token_external_deps += [ "hitrace:hitrace_meter" ]
|
|
} else {
|
|
hiviewdfx_hitrace_native_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.multimedia_audio_framework)) {
|
|
audio_framework_enable = true
|
|
access_token_cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ]
|
|
access_token_external_deps += [ "audio_framework:audio_client" ]
|
|
} else {
|
|
audio_framework_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.multimedia_camera_framework)) {
|
|
camera_framework_enable = true
|
|
access_token_cflags_cc += [ "-DCAMERA_FRAMEWORK_ENABLE" ]
|
|
access_token_external_deps += [ "camera_framework:camera_framework" ]
|
|
} else {
|
|
camera_framework_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.ability_ability_runtime)) {
|
|
ability_runtime_enable = true
|
|
access_token_cflags_cc += [ "-DABILITY_RUNTIME_ENABLE" ]
|
|
} else {
|
|
ability_runtime_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.security_security_component_enhance)) {
|
|
security_component_enhance_enable = true
|
|
access_token_cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
|
|
access_token_external_deps += [ "ipc:ipc_single" ]
|
|
} else {
|
|
security_component_enhance_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.customization_config_policy)) {
|
|
customization_config_policy_enable = true
|
|
access_token_cflags_cc += [ "-DCUSTOMIZATION_CONFIG_POLICY_ENABLE" ]
|
|
access_token_external_deps += [ "config_policy:configpolicy_util" ]
|
|
} else {
|
|
customization_config_policy_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.theme_screenlock_mgr)) {
|
|
theme_screenlock_mgr_enable = true
|
|
access_token_cflags_cc += [ "-DTHEME_SCREENLOCK_MGR_ENABLE" ]
|
|
access_token_external_deps += [ "screenlock_mgr:screenlock_client" ]
|
|
} else {
|
|
theme_screenlock_mgr_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.notification_common_event_service)) {
|
|
common_event_service_enable = true
|
|
access_token_cflags_cc += [ "-DCOMMON_EVENT_SERVICE_ENABLE" ]
|
|
access_token_external_deps += [ "common_event_service:cesfwk_innerkits" ]
|
|
} else {
|
|
common_event_service_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.notification_eventhandler)) {
|
|
eventhandler_enable = true
|
|
access_token_cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
|
|
access_token_external_deps += [ "eventhandler:libeventhandler" ]
|
|
} else {
|
|
eventhandler_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.resourceschedule_background_task_mgr)) {
|
|
access_token_background_task_mgr_continuous_task_enable = true
|
|
access_token_cflags_cc += [ "-DBGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
|
|
} else {
|
|
access_token_background_task_mgr_continuous_task_enable = false
|
|
}
|
|
|
|
if (!defined(global_parts_info) ||
|
|
defined(global_parts_info.appsecurityprivacy_security_privacy_server)) {
|
|
access_token_app_security_privacy_service_enable = true
|
|
access_token_cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ]
|
|
} else {
|
|
access_token_app_security_privacy_service_enable = false
|
|
}
|
|
|
|
if (defined(global_parts_info) &&
|
|
defined(global_parts_info.resourceschedule_memmgr_override)) {
|
|
memory_manager_enable = true
|
|
access_token_cflags_cc += [ "-DMEMORY_MANAGER_ENABLE" ]
|
|
access_token_external_deps += [ "memmgr:memmgrclient" ]
|
|
} else {
|
|
memory_manager_enable = false
|
|
}
|
|
|
|
if (defined(global_parts_info) &&
|
|
defined(global_parts_info.security_security_guard)) {
|
|
security_guard_enable = true
|
|
access_token_cflags_cc += [ "-DSECURITY_GUARD_ENABLE" ]
|
|
access_token_external_deps += [ "security_guard:libsg_collect_sdk" ]
|
|
} else {
|
|
security_guard_enable = false
|
|
}
|
|
|
|
if ("${target_platform}" == "watch" || "${target_platform}" == "wearable") {
|
|
lite_device_enable = true
|
|
access_token_cflags_cc += [ "-DDYNAMIC_CLOSE_LIBS" ]
|
|
} else {
|
|
lite_device_enable = false
|
|
access_token_cflags_cc += [ "-DREMOTE_PRIVACY_ENABLE" ]
|
|
}
|
|
|
|
if ("${target_platform}" == "pc" || "${target_platform}" == "tablet" ||
|
|
"${target_platform}" == "phone" || use_libfuzzer) {
|
|
access_token_manage_user_policy_enable = true
|
|
access_token_cflags_cc += [ "-DSUPPORT_MANAGE_USER_POLICY" ]
|
|
} else {
|
|
access_token_manage_user_policy_enable = false
|
|
}
|
|
|
|
if (access_token_privacy_bundle_start_stop_enable) {
|
|
access_token_cflags_cc += [ "-DPRIVACY_BUNDLE_START_STOP_ENABLE" ]
|
|
}
|
|
|
|
if (is_emulator) {
|
|
access_token_cflags_cc += [ "-DX86_EMULATOR_MODE" ]
|
|
}
|
|
|
|
if (defined(global_parts_info) &&
|
|
defined(global_parts_info.security_appverify)) {
|
|
access_token_cflags_cc += [ "-DIS_SUPPORT_HAP_RUNNING" ]
|
|
access_token_manager_hapverify_enable = true
|
|
access_token_external_deps += [ "appverify:libhapverify" ]
|
|
} else {
|
|
access_token_manager_hapverify_enable = false
|
|
}
|
|
|
|
if (defined(global_parts_info) && defined(global_parts_info.security_asset)) {
|
|
access_token_cflags_cc += [ "-DSAF_AGENT_FENCE_ENABLE" ]
|
|
saf_agent_fence_enable = true
|
|
access_token_external_deps += [ "asset:saf_agent_fence" ]
|
|
} else {
|
|
saf_agent_fence_enable = false
|
|
}
|