Dsoftbus Safety Guard logo

Dsoftbus Safety Guard

Organization
openharmonyinsight
dsoftbus_safety_guard

OpenHarmony软总线代码安全检视专家 - 全面检查C/C++代码的安全编码规范和日志规范。 涵盖40+条安全规则,包括指针安全、内存管理、锁管理、敏感信息保护等关键领域。 提供跨文件调用分析和控制流分析,生成详细的代码审查报告。 仅在用户输入包含"软总线安全卫士"时触发。 ⚠️ 重要:此技能为只读审查工具,不修改源文件。

Overview

Publisheropenharmonyinsight
Repositoryopenharmony-skills
Skill namedsoftbus_safety_guard
Stars
36
Forks
7
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by openharmonyinsight on GitHub. Read the source before you install it.

Installation

Install the Dsoftbus Safety Guard AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/dsoftbus-security
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openharmonyinsight/openharmony-skills.git /tmp/openharmony-skills
mkdir -p .claude/skills
cp -r /tmp/openharmony-skills/skills/dsoftbus-security .claude/skills/dsoftbus_safety_guard
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dsoftbus Safety Guard in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dsoftbus Safety Guard on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dsoftbus Safety Guard is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

软总线安全卫士 - 代码审查技能

触发条件

⚠️ 此技能仅在用户输入包含"软总线安全卫士"时才会被调用

触发示例:

  • 软总线安全卫士 请审查这个文件:D:\code\example.c
  • 请使用软总线安全卫士检查这个目录
  • 软总线安全卫士 检视lnn_lane_dfx.c文件

技能概述

本技能是 OpenHarmony distributed soft bus (dsoftbus) 通信组件的专用代码审查工具,涵盖:

  • 日志规范检查:1条核心规则
  • 安全编码检查:40+条规则,覆盖11大类别
  • 通用代码质量检查:代码复杂度、可读性、并发安全等
  • 跨文件调用分析:调用链追踪、资源传递、数据流分析
  • 控制流分析:路径敏感分析、不可达代码检测

⚠️ 核心原则:本技能为只读代码审查工具,仅分析代码并生成报告,不修改任何源文件。

适用场景

  • OpenHarmony dsoftbus 组件代码
  • C/C++ 系统级通信代码
  • 涉及 IPC、网络通信、多线程的代码
  • 需要严格日志规范和安全编码的代码

快速参考:关键规则索引

根据代码特征快速定位相关规则:

代码特征相关规则
函数返回 SOFTBUS_ERR日志规范-1
指针位运算 (&, |, ^, ~, <<, >>)指针安全-1, 整数运算-2
*ptr 或 ptr-> 使用指针安全-3, 临时变量-1
arr[index] 访问数组下标-1,2
SoftBusMutexLock/SoftBusMutexUnlock锁管理-1,2,3
SoftBusSocketCreate/SoftBusSocketClosefd管理-1,2
malloc/free, new/delete内存管理-1~11
HILOG_INFO 打印敏感信息敏感信息-1,2,3
-无符号数递减 (i--)
memcpy_s, strcpy_s 等安全函数-1,2
路径操作 (., ..)外部输入-1
IPC 接口新增权限校验-1

📚 详细规则说明

每个规则的详细解释、代码示例和修复方案请查看:

  • 规则详解与示例 - 40+条规则的完整文档
    • 每条规则的问题描述、风险等级、问题示例、修复方案、检查要点
    • 包含完整代码示例和最佳实践
    • 包含格式化打印类型匹配表和常用安全函数列表

🏷️ 规则分类(快速索引)

💡 快速定位: 点击每个规则后的链接可查看详细说明和代码示例

1. 日志规范(1条)

2. 指针安全(4条)

3. 临时变量(3条)

4. 数组下标(2条)

5. 锁管理(3条)

6. fd 管理(2条)

7. 内存管理(11条)

8. 敏感信息(3条)

9. 整数运算(2条)

10. 循环变量(2条)

11. 安全函数(2条)

12. 权限校验(1条)

13. 外部输入校验(4条)

  • 路径规范化 → 详见
  • TLV 解析长度合法性 → 详见
  • 源 buffer 实际大小检查 → 详见
  • 完整校验方案 → 详见

14. 外部数据有效性(3条)

  • 基于外部输入的加减法/内存申请校验 → 详见
  • 默认长度校验 → 详见
  • TLV 格式长度校验 → 详见

15. 常见问题(5条)

  • 异常分支资源释放 → 详见
  • 宏定义资源泄漏 → 详见
  • 函数返回值一致性 → 详见
  • 格式化打印类型匹配 → 详见
  • 结构体字节对齐 → 详见

代码审查工作流

第一步:交互式选择检视范围

场景A:用户指定路径
  1. 检查该路径下是否有修改:git status --porcelain <path>
  2. 如果有修改,提供选项:
    • 全量检视该路径所有代码
    • 增量检视修改的代码(共N个文件)
  3. 如果无修改,直接执行全量检视
场景B:用户未指定路径
  1. 检查当前仓库是否有修改:git status --porcelain
  2. 提供选项:
    • 检视全仓代码
    • 指定检视路径
    • 检视本地修改的代码(共N个文件)
  3. 根据用户选择执行

第二步:代码规范检查

按照40+条规则逐项检查,参考:

  • 规则详解文档 - 每条规则的详细说明和代码示例
  • 使用 Grep 工具搜索违规模式
  • 结合上下文分析,避免误报

第三步:跨文件调用分析

核心能力:分析函数调用链,追踪跨文件的数据流和资源传递

  • 调用图构建
  • 跨文件资源追踪(malloc/free分离)
  • 跨文件数据流分析
  • 跨文件错误处理
  • 全局变量跨文件访问

第四步:控制流分析

核心能力:分析代码执行路径,识别不可达代码和路径敏感问题

  • 控制流图构建
  • 不可达代码检测
  • 路径敏感分析
  • 未初始化变量分析
  • 资源释放路径分析

第五步:生成修复建议

⚠️ 重要限制:仅生成修复建议代码到报告中,严禁直接修改源文件

对每个问题提供:

  • 完整的函数或代码块修复示例
  • 修改原因注释
  • 多种修复方案(如有)

第六步:生成检视报告

创建报告目录:d:/code-review-YYYYMMDD-HHMMSS/

报告文件:

  • code_review_report.md - 完整审查报告
  • code_fixes.patch - 所有修复代码(Git patch格式)
  • statistics.json - 统计数据

常见错误速查表

💡 详细检查方法: 每种错误模式的详细检查方法、代码示例和修复方案,请查看 检查清单

错误模式危险等级快速检测详见章节
空指针解引用🔴 严重*ptr 或 ptr-> 前无NULL检查指针安全-3
锁未释放🔴 严重return前未调用Unlock锁管理-1
内存泄漏🔴 严重malloc未配对free内存管理-2
敏感信息泄露🔴 严重日志打印密钥/udid敏感信息-1
数组越界🔴 严重arr[index] 未验证范围数组下标-1
无符号死循环🔴 严重uint32_t i--循环变量-1
指针位运算🟡 警告ptr & mask指针安全-1
整数溢出🟡 警告size + offset 未检查整数运算-1
返回SOFTBUS_ERR🟡 警告return SOFTBUS_ERR日志规范-1
未初始化变量🟡 警告声明未赋初值临时变量-1

检查原则

上下文分析

  • 检查时要看上下文,确认是否已有防护措施
  • 避免误报(如:全局变量可能在别处初始化)

灵活运用

  • 除40+条明确定义规则外,还需进行通用代码质量检查
  • 代码复杂度、可读性、并发安全、性能问题等

重点关注

  • 处理外部输入的代码路径
  • 宏定义中的资源使用
  • 条件编译中的问题代码
  • 高风险安全问题(空指针、内存泄漏、敏感信息泄露)

优先级排序

安全编码问题 > 日志规范问题
严重问题 > 警告问题 > 提示问题

核心限制

⚠️ 严禁修改源代码:

  • 本技能只读取和分析代码
  • 生成修复建议仅用于报告
  • 绝不直接修改任何源文件
  • 只读操作:仅使用 Read、Grep、Glob 等只读工具

📖 参考文档

详细规则说明

  • 规则详解与示例 - 40+条规则的详细解释和代码示例
    • 每条规则的问题描述、风险等级、问题示例、修复方案、检查要点
    • 包含完整代码示例和最佳实践
    • 包含格式化打印类型匹配表和常用安全函数列表

附加资源


使用技巧

  1. 快速定位问题:使用"快速参考"表格根据代码特征查找相关规则
  2. 深入学习规则:阅读 references/security_rules_explained.md 了解每条规则的详细说明和代码示例
  3. 分类审查:根据"规则分类"按类别逐项检查,避免遗漏
  4. 优先处理严重问题:参考"常见错误速查表"优先修复高危问题
  5. 使用工作流程:按照"代码审查工作流"系统性进行审查

报告要求

  • 报告自动生成:审查完成后自动在 d:/code-review-时间戳/ 目录生成报告
  • 报告目录格式:使用 YYYYMMDD-HHMMSS 格式的时间戳
  • 文件编码:报告文件使用 UTF-8 编码,确保中文正常显示
  • 修复代码仅供参考:所有修复代码只出现在报告文件的代码块中,不写入源代码目录

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Dsoftbus Safety Guard AI skill do?

OpenHarmony软总线代码安全检视专家 - 全面检查C/C++代码的安全编码规范和日志规范。 涵盖40+条安全规则,包括指针安全、内存管理、锁管理、敏感信息保护等关键领域。 提供跨文件调用分析和控制流分析,生成详细的代码审查报告。 仅在用户输入包含"软总线安全卫士"时触发。 ⚠️ 重要:此技能为只读审查工具,不修改源文件。

Why use Dsoftbus Safety Guard on TypingMind?

Because you install it once and use it with any model. Dsoftbus Safety Guard is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dsoftbus Safety Guard in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/dsoftbus-security. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Dsoftbus Safety Guard?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dsoftbus Safety Guard?

As many as you like. As long as a model supports skills, you can use Dsoftbus Safety Guard with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dsoftbus Safety Guard AI skill free?

It is published on GitHub by openharmonyinsight. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇