-
Notifications
You must be signed in to change notification settings - Fork 2
feat: auto-generate authority pattern list from std's MIR #53
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
The authority pattern list in classify_authority() (capsec-deep) and build_registry() (cargo-capsec) is manually maintained. When Rust adds new I/O functions to std, we don't detect them with proper category labels (FS/NET/ENV/PROC) until someone manually adds the pattern. The FFI catch-all (is_foreign_item()) still detects them, but only as generic FFI findings without meaningful categorization.
Proposal
Use --deep on the standard library itself to auto-generate the authority registry. The MIR driver can already trace every std function that transitively calls a foreign function. The output is effectively the definitive list of all authority-bearing functions in std.
Approach
- Run
capsec-driveronstd(viaRUSTC_WRAPPERon a dummy crate that depends on std) - For each finding, extract the call chain:
std::fs::read→ ... →libc::read - Categorize by the top-level
stdmodule (std::fs::*→ FS,std::net::*→ NET, etc.) - Output a generated
authority_registry.rsor JSON file that replaces the hand-maintainedbuild_registry()andclassify_authority()tables - Run this as a CI job pinned to each Rust release — diff the output against the current registry and open a PR if new functions appear
Benefits
- Zero manual maintenance — new
stdI/O functions get proper category labels automatically - Catches functions we've missed (e.g.,
std::fs::File::sync_all,std::fs::hard_linkwere missing from the syntactic registry) - Single source of truth derived from the compiler itself
- Could also run on popular crates (tokio, reqwest, hyper) to auto-generate patterns for third-party I/O
Open questions
- Should the generated list replace
build_registry()entirely, or supplement it? - How to handle
stdfunctions that call FFI but aren't really "authority" (e.g., allocator internals)? - What Rust edition/version to pin the generation to?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request