unsafe-checker by actionbook/rust-skills
npx skills add https://github.com/actionbook/rust-skills --skill unsafe-checker⚠️ Unsafe Rust Checker Loaded
* ^ *
/◉\_~^~_/◉\
⚡/ o \⚡
'_ _'
/ '-----' \
| 使用场景 | 示例 |
|---|---|
| FFI | 调用 C 函数 |
| 底层抽象 | 实现 Vec、Arc |
| 性能 | 经过测量,安全替代方案在瓶颈处过慢 |
无效情况: 在不理解原因的情况下逃避借用检查器。
// SAFETY: <解释此处为何安全>
unsafe { ... }
/// # Safety
/// <调用者需满足的要求>
pub unsafe fn dangerous() { ... }
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 操作 | 安全性要求 |
|---|---|
*ptr 解引用 | 指针有效、对齐、已初始化 |
&*ptr | + 无别名冲突 |
transmute | 大小相同,位模式有效 |
extern "C" | 签名正确,ABI 匹配 |
static mut | 保证同步 |
impl Send/Sync | 实际线程安全 |
| 错误 | 修复方法 |
|---|---|
| 空指针解引用 | 解引用前检查是否为 null |
| 释放后使用 | 确保生命周期有效 |
| 数据竞争 | 添加适当的同步机制 |
| 对齐违规 | 使用 #[repr(C)],检查对齐 |
| 无效位模式 | 使用 MaybeUninit |
| 缺少 SAFETY 注释 | 添加 // SAFETY: |
| 已弃用 | 替代方案 |
|---|---|
mem::uninitialized() | MaybeUninit<T> |
对引用使用 mem::zeroed() | MaybeUninit<T> |
| 裸指针算术运算 | NonNull<T>、ptr::add |
CString::new().unwrap().as_ptr() | 先存储 CString |
static mut | AtomicT 或 Mutex |
| 手动 extern | bindgen |
| 方向 | 库 |
|---|---|
| C → Rust | bindgen |
| Rust → C | cbindgen |
| Python | PyO3 |
| Node.js | napi-rs |
Claude 了解 unsafe Rust。重点关注 SAFETY 注释和健全性。
每周安装量
82
代码仓库
GitHub 星标数
911
首次出现
2026年1月23日
安全审计
安装于
opencode77
codex76
gemini-cli75
github-copilot70
cursor70
kimi-cli65
Display the following ASCII art exactly as shown. Do not modify spaces or line breaks:
⚠️ **Unsafe Rust Checker Loaded**
* ^ *
/◉\_~^~_/◉\
⚡/ o \⚡
'_ _'
/ '-----' \
| Use Case | Example |
|---|---|
| FFI | Calling C functions |
| Low-level abstractions | Implementing Vec, Arc |
| Performance | Measured bottleneck with safe alternative too slow |
NOT valid: Escaping borrow checker without understanding why.
// SAFETY: <why this is safe>
unsafe { ... }
/// # Safety
/// <caller requirements>
pub unsafe fn dangerous() { ... }
| Operation | Safety Requirements |
|---|---|
*ptr deref | Valid, aligned, initialized |
&*ptr | + No aliasing violations |
transmute | Same size, valid bit pattern |
extern "C" | Correct signature, ABI |
static mut | Synchronization guaranteed |
impl Send/Sync | Actually thread-safe |
| Error | Fix |
|---|---|
| Null pointer deref | Check for null before deref |
| Use after free | Ensure lifetime validity |
| Data race | Add proper synchronization |
| Alignment violation | Use #[repr(C)], check alignment |
| Invalid bit pattern | Use MaybeUninit |
| Missing SAFETY comment | Add // SAFETY: |
| Deprecated | Use Instead |
|---|---|
mem::uninitialized() | MaybeUninit<T> |
mem::zeroed() for refs | MaybeUninit<T> |
| Raw pointer arithmetic | NonNull<T>, ptr::add |
CString::new().unwrap().as_ptr() | Store CString first |
| Direction | Crate |
|---|---|
| C → Rust | bindgen |
| Rust → C | cbindgen |
| Python | PyO3 |
| Node.js | napi-rs |
Claude knows unsafe Rust. Focus on SAFETY comments and soundness.
Weekly Installs
82
Repository
GitHub Stars
911
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode77
codex76
gemini-cli75
github-copilot70
cursor70
kimi-cli65
代码安全审查清单:最佳实践与漏洞防范指南(含密钥管理、SQL注入防护)
1,700 周安装
static mut | AtomicT or Mutex |
| Manual extern | bindgen |