mir-extractor
A Rust library for extracting MIR (Mid-level Intermediate Representation) from Rust crates and running security analysis rules against the extracted code.
This is the core analysis engine used by cargo-cola.
Requirements
- Nightly Rust toolchain (MIR extraction uses unstable compiler APIs)
- Target crate must compile successfully
Installation
[]
= "1.0"
Usage
use ;
use Path;
Features
Default
The default configuration provides MIR extraction and analysis without compiler integration.
hir-driver
Enables HIR (High-level Intermediate Representation) capture by linking against rustc internals. This provides richer type information for analysis but requires the exact nightly toolchain version specified in rust-toolchain.toml.
[]
= { = "1.0", = ["hir-driver"] }
When enabled, this feature also builds two internal binaries (hir-driver-wrapper and hir-spike) used for HIR capture. These are not intended for direct use.
API Overview
extract(path)- Extract MIR from a crate at the given pathanalyze(package)- Run built-in security rules against a MIR packageanalyze_with_engine(engine, package)- Run custom rulesRuleEngine- Configure and run security rulesFinding- A security finding with severity, location, and messageMirPackage- Extracted MIR data for a crate
License
MIT