Conversation
…ration test Co-authored-by: hxuhack <13302178+hxuhack@users.noreply.github.com>
Co-authored-by: hxuhack <13302178+hxuhack@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add cargo rapx audit command for unsafe APIs
Add Mar 3, 2026
cargo rapx audit unsafe-apis and cargo rapx audit std-unsafe-apis commands
Removed tests for the extract_safety_doc function.
hxuhack
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
audittop-level subcommand that enumerates allpub unsafeAPIs in either the current crate or the Rust standard library (std/core/alloc) and emits a stable JSON document to stderr.CLI
JSON schema
[ { "module": "crate_name::module_path", "name": "function_name", "params": [{ "name": "ptr", "ty": "*const u8" }], "safety_doc": "The pointer must be valid and non-null." } ]module– qualified module path (unsafe_apis_test,std::ptr, etc.)params– names sourced from HIR body params for local items;argNfallback for externalsafety_doc– text of the# Safety/## Safetydoc section, ornullImplementation
cli.rs– newAudit { kind: AuditKind }variant inCommands;AuditKind::{UnsafeApis, StdUnsafeApis}analysis/audit/mod.rs– new module with:UnsafeApiEntry/ParamInfoserde structsextract_safety_doc()– pure string parser for# Safetysections with anis_heading_stophelper; covered by 5 unit testsAuditUnsafeApis– iteratesmir_keys()(local) orget_all_std_fns_by_rustc_public(std), filters onpub+unsafe, emits JSON viaeprintln!lib.rs– dispatch branch forCommands::Audittests/audit/unsafe_apis_test/– fixture crate; integration test asserts JSON contains knownpub unsafe fn deref_rawwith its safety dochelp.rs/README.md– usage examples addedOriginal prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.