Do Not Expose Raw Pointers in Public APIs

id: safety-06 original_id: P.UNS.SAS.06 level: P impact: HIGH Do Not Expose Raw Pointers in Public APIs Summary Public APIs should use safe abstractions (references, slices, smart pointers) instead of
阅读全文

FFI Best Practices and Patterns

FFI Best Practices and Patterns Examples of safe and idiomatic Rust-C interoperability. Pattern 1: Basic FFI Wrapper use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int, c_void}; use std::
阅读全文

Safe Abstraction Examples

Safe Abstraction Examples Examples of building safe APIs on top of unsafe code. Example 1: Simple Wrapper with Bounds Check /// A slice wrapper that provides unchecked access internally /// but safe a
阅读全文

Unsafe Rust Checker

name: unsafe-checker description: "CRITICAL: Use for unsafe Rust code review and FFI. Triggers on: unsafe, raw pointer, FFI, extern, transmute, *mut, const, union, #[repr(C)], libc, std::ffi, MaybeUni
阅读全文

Unsafe Checker - Quick Reference

Unsafe Checker - Quick Reference Auto-generated from rules/ Rule Summary by Section General Principles (3 rules) IDLevelTitle general-01PDo Not Abuse Unsafe to Escape Compiler Safety Checks general-02
阅读全文

Checklist: Before Writing Unsafe Code

Checklist: Before Writing Unsafe Code Use this checklist before writing any unsafe block or unsafe fn. 1. Do You Really Need Unsafe? Have you tried all safe alternatives? Can you restructure the code
阅读全文

Checklist: Reviewing Unsafe Code

Checklist: Reviewing Unsafe Code Use this checklist when reviewing code containing unsafe. 1. Surface-Level Checks Does every unsafe block have a // SAFETY: comment? Does every unsafe fn have # Safety
阅读全文