skills/oh-distributed-security-design-review/SKILL.md
OpenHarmony分布式系统安全代码检视专用技能。当用户要求"检视代码安全实现"、"代码安全审查"、"安全代码review"或类似的分布式系统代码安全检视请求时触发。此技能提供18条OpenHarmony分布式业务安全设计规则的详细检视指导,涵盖授权控制、状态机、数据传输、权限管理、可信关系等安全领域。使用此技能可在通用网络安全规则基础上,针对OpenHarmony分布式系统进行专项安全检视。
npx skillsauth add openharmonyinsight/openharmony-skills oh-distributed-security-design-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
本技能提供OpenHarmony分布式业务安全代码检视的专业指导,包含18条安全设计规则和对应的检视要点。当检视分布式系统代码安全性时,在通用网络安全规则基础上,使用这些规则进行加强检视。
首先理解代码的业务场景和所在模块:
识别关键模块: 确定代码是否涉及以下模块
识别业务类型: 判断是否涉及以下安全敏感业务
确定角色: 识别代码是主体侧(客户端)还是客体侧(服务端)
根据代码涉及的业务类型,加载security_rules.md中对应的规则:
快速索引关键词:
对每个适用的安全规则,执行以下检视:
定位相关代码: 使用Grep搜索关键模式
Grep patterns examples:
- "auth", "authorize", "permission" for authorization checks
- "PIN", "secret", "key" for sensitive data
- "state", "status" for state machine
- "random", "generate" for secret generation
检查实现细节:
记录发现:
除了OpenHarmony特定规则外,还需检查通用安全实践:
生成结构化的安全检视报告,包含:
Bad Example:
// 客体侧直接使用主体侧传入的标志控制弹框
void handleAuthRequest(bool showPopup) {
if (!showPopup) {
// 直接跳过授权弹框
grantAccess();
}
}
Correct Approach:
// 客体侧独立决策是否需要授权
void handleAuthRequest() {
if (isSystemBusinessAndRegistered()) {
// 已注册的免授权业务
grantAccess();
} else {
// 默认必须弹框
showAuthorizationDialog();
}
}
Bad Example:
// 明文传输PIN码
message.pin_code = userPin;
sendToRemote(message);
Correct Approach:
// 加密后传输
encryptedPin = encryptPin(userPin, sessionKey);
message.encrypted_pin = encryptedPin;
sendToRemote(message);
Bad Example:
// 自行比对账号信息判断可信关系
bool isTrusted() {
return localAccount == remoteAccount;
}
Correct Approach:
// 依赖HiChain查询
bool isTrusted() {
CredentialType type = HiChain.queryCredentialType(remoteDevice);
return type == CredentialType.SAME_ACCOUNT;
}
Bad Example:
// 默认值放通
bool enableSecurityCheck = true; // 默认启用
Correct Approach:
// 默认值禁用
bool enableSecurityCheck = false; // 默认禁用,需显式启用
User request: "检视这段分布式设备管理代码的安全性"
Review process:
development
Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.
development
OpenHarmony PR full lifecycle workflow. Five modes: - Commit: standardized commit with DCO sign-off and Issue linking - Create PR: commit + push to fork + create Issue + create PR on upstream - Fix Codecheck: fetch gate CI codecheck defects from a PR and auto-fix them - Review PR: fetch a PR's changes to local for code review - Fix Review: fetch unresolved review comments from a PR and auto-fix them Triggers on: /oh-pr-workflow, "提交代码", "创建PR", "提个PR", "commit", "修复告警", "修复门禁", "修复codecheck", "fix codecheck", "review pr", "review这个pr", "看下这个pr", "检视pr", "修复review", "修复检视意见", "fix review", or a GitCode PR URL with fix/review intent.
testing
分析 HM Desktop PRD 文档,提取需求信息、验证完整性、检查章节顺序(需求来源→需求背景→需求价值分析→竞品分析→需求描述)、检查 KEP 定义、检测需求冲突并生成结构化分析报告。适用于用户请求:(1) 分析或审查 PRD 文档, (2) 从需求中提取 KEP 列表, (3) 检查 PRD 完整性或一致性, (4) 将需求映射到模块架构, (5) 验证 PRD 格式合规性, (6) 验证竞品分析章节完整性。关键词:PRD分析, requirement extraction, KEP验证, completeness check, chapter order validation, 竞品分析检查, analyze PRD, 需求提取, 完整性检查, 章节顺序验证
development
基于 PRD 文档自动生成鸿蒙系统设计文档,包括架构设计文档和功能设计文档。生成前会分析 OpenHarmony 存量代码结构,确保与现有架构兼容。架构设计文档第2章必须为竞品方案分析,位于需求背景之后。适用于用户请求:(1) 生成架构设计文档, (2) 生成功能设计文档, (3) 从 PRD 生成设计文档, (4) 创建系统架构设计, (5) 编写功能规格说明, (6) 分析 OH 代码结构。关键词:architecture design, functional design, design doc, 竞品方案分析, OpenHarmony code analysis, 架构设计, 功能设计, 设计文档生成, OH代码分析, analyze codebase, competitor analysis