已合并
aa命令新增权限 #20276
hanchen45创建于 12 天前
aa命令新增权限 #20276
已合并
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 hanchen45 的贡献)afwk_helper
12 天前 评论:
12 天前 评论:
开始进行AI检视!
AI review has been started, please wait...


afwk_helper
12 天前 评论:
12 天前 评论:
| check type | result | report |
|---|---|---|
| start ai_review | pass | - |


12 天前 关联了issue:[新需求]: aa命令新增权限校验
12 天前 添加了label:waiting_on_author
openharmony_ci
12 天前 评论:
12 天前 评论:
感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接。
Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.


此处折叠了62条消息 查看更多
openharmony_dcp
2 天前 评论:
2 天前 评论:
你因提交次数过多被限制提交,为保障上库效率、避免资源浪费,请先观看学习视频:https://dcp.openharmony.cn/workbench/video/videoDisplay


2 天前 关闭了关联的issue
2 天前 合入了pull request,合并节点 SHA:93a5216293b57636a10bd40395ff6ecf5dfe7c76
2 天前 删除了label:waiting_for_review
2 天前 添加了label:merged
IssueNo:
Description:
稳定性自检:
安全编码自检:
TDD Result:
XTS Result:
是否已执行L0用例
AI检视评分(使用本地代码检视skills扫描):
代码检视报告 — commit d05199a "aa命令新增权限"(Round 2 / 指定提交)
报告元数据
codecheck_report: schema_version: "1.0" scope: "commit 435d7f86 — aa命令新增权限" round: 2 commit_id: "435d7f8645aba2db180b841336d993f141d720f5" change_id: "N/A" report_id: "435d7f86-R2" date: "2026-09-01" gate_decision: "approve" risk_level: "low" score: 92 dimensions_required: ["security-scanner", "logic-scanner", "input-scanner"] dimensions_executed: ["security-scanner", "logic-scanner", "input-scanner"] findings_total: 4 findings_by_severity: {P0: 0, P1: 0, P2: 0, P3: 4} gate_blockers: [] must_fix: [] followups: ["CC-04", "CC-05", "CC-07", "CC-08"]1. 门禁结论
一句话结论:
IsLocalDebugOtherAppsCall()实现正确(devMode 短路 +GetCallingTokenID+VerifyPermissionByTokenId),7 个服务端 gate 的"并列放行"模式一致且 fail-closed;StartAbility(731) gate 经评估确认会误拦截正常调用方的合法拉起,intentionally 不添加;剩余 4 项 P3 均为 DFX 日志改进和同类入口完整性观察,不阻塞上库。3. 必须立即处理(P0/P1)
无。
4. 建议本轮或下一补档处理(P2/P3)
isShellCall但下发isShellOrLocalDebug,local-debug 调用者时日志与实际值不一致isShellOrLocalDebugisLocalDebugOtherAppsCall变量值IsLocalDebugOtherAppsCall(),调试工具无法 stop-serviceIsLocalDebugOtherAppsCall(),aa force-stop时退出原因未记录但 kill 成功5. 分维度速览
IsLocalDebugOtherAppsCall()实现正确:身份来自IPCSkeleton::GetCallingTokenID()(非 parcel),devMode 短路在前(fail-closed),权限校验经AccessTokenKit::VerifyAccessToken;7 个 gate 均为纯增量 OR 放行,不收紧 shell/SA 基线;StartAbility(731) gate 经评估确认会误拦截正常调用方,intentionally 不添加IsLocalDebugOtherAppsCall()内置 devMode 门控,与 shell 路径的 devMode 要求一致执行;VerifyKillProcessPermissionCommon新分支位置正确(SA/shell 之后、VerifyAPL 之前)specifiedFullTokenId使用IPCSkeleton::GetCallingUid()校验 DMS_UID(IPC-006 合规);MemoryLevelInfo::ReadFromParcel有 size 上限和 level 值域校验6. 关键发现详情
[CC-04] NotifyProcMemoryLevel 日志与下发值不一致 (P3, scanner=LOG+SEC+INP)
services/appmgr/src/app_mgr_service_inner.cpp:4493-4495NotifyProcMemoryLevel→isShellOrLocalDebug = isShellCall || isLocalDebugOtherAppsCall= true → 日志打印isShellCall=0但下游收到1bool isShellOrLocalDebug = isShellCall || isLocalDebugOtherAppsCall; TAG_LOGD(AAFwkTag::APPMGR, "isShellCall %{public}d", isShellCall); // ← 打印 isShellCall return appRunningManager_->NotifyProcMemoryLevel(procLevelMap, isShellOrLocalDebug); // ← 下发 OR 值isShellOrLocalDebug,或同时打印两者。[CC-05] NotifyProcMemoryLevel 失败日志遗漏新增判定变量 (P3, scanner=LOG)
services/appmgr/src/app_mgr_service_inner.cpp:4485-4486TAG_LOGE缺少isLocalDebugOtherAppsCall值if (!(isMemmgrCall || (isShellCall && isDevelopMode) || isLocalDebugOtherAppsCall)) { TAG_LOGE(AAFwkTag::APPMGR, "Permission check failed: ... isMemmgrCall=%{public}d, " "isShellCall=%{public}d, isDevelopMode=%{public}d", ...); // ← 缺少 isLocalDebugOtherAppsCall }isLocalDebugOtherAppsCall。[CC-07] StopServiceAbility 同类 gate 缺失 IsLocalDebugOtherAppsCall (P3, scanner=SEC)
services/abilitymgr/src/ability_manager_service.cpp:9169aa stop-service→StopServiceAbility→ gate 仅检查isSaCall || isShellCall,调试工具被拒aa stop-service对调试工具不可用。该入口有独立的 abilityRecord 校验作为后备防护,非安全问题。|| IsLocalDebugOtherAppsCall(),与其他 7 个入口保持一致。[CC-08] RecordProcessExitReason gate 缺失 — kill 审计链断裂 (P3, scanner=SEC)
services/abilitymgr/src/ability_manager_service.cpp:3786aa force-stop -p <pid> -r <reason>→RecordProcessExitReason(gate 拒绝,返回 ERR_PERMISSION_DENIED)→KillProcess(VerifyKillProcessPermissionCommon放行,成功)→ 进程被杀死但退出原因未记录hisysevent中APP_EXIT_REASON事件缺失。kill 操作本身成功,仅影响故障归因数据完整性。RecordProcessExitReason的 gate 中追加|| IsLocalDebugOtherAppsCall(),保持 DFR 审计链完整。附录:Round 1 → Round 2 变更说明
移除项
StartSelfUIAbility内部直调、ability_delegator测试框架等),intentionally 不添加。该入口依赖 interceptor chain + 可见性检查 + callerToken 授权,非本权限的设计职责。降级/排除项
RunAsHelpCommand的客户端 gate 是 UX 便利,真实防护在服务端 7 个 gateVerifyKillProcessPermissionCommon放行 local-debug 是 by-design debug 能力,devMode +LOCAL_DEBUG_OTHER_APPS权限双重门控,权限授予策略由 access_token 框架管控HandleStartNativeProcessForDebugger未做SanitizeWantParams是预存问题,非本提交引入(本提交仅扩展权限,未改变 Want 处理逻辑)KillProcessWithReasonInner是独立 kill 路径,有自身的PERMISSION_KILL_APP_PROCESSES+IsShellCall校验,调试工具经aa force-stop走VerifyKillProcessPermissionCommon路径IsAllowLocalDebugOtherAppsvsIsLocalDebugOtherAppsCall设计差异是 intentional——前者用于AttachAppDebug(需debugFromLocal标志),后者用于通用 gate(不需该标志),适用场景不同GetAppRunningUniqueIdByPid的 pid 未绑定调用者是 by-design debug 信息访问,devMode + 权限双重门控DumpState/DumpSysState信息暴露是 by-design debug 能力,各子函数已有按 callerUid 的可见性过滤aa help行为回归是 intentional(commit 有意添加 gate)token_setproc.h未使用是观察项,无安全影响MemoryLevelInfo::ReadFromParcel死代码是预存问题保留项(均为 P3 观察项)