A program that list statistics related to usage of unsafe Rust code in a Rust crate and all its dependencies.
This cargo plugin is based on the code from two other projects: https://github.com/icefoxen/cargo-osha and https://github.com/sfackler/cargo-tree.
Try to find and use a system-wide installed OpenSSL library:
cargo install cargo-geiger
Or, build and statically link OpenSSL as part of the cargo-geiger executable:
cargo install cargo-geiger --features vendored-openssl
Cargo.toml
you want to analyze.cargo geiger
When and why to use unsafe Rust is out of scope for this project, it is simply a tool that provides information to aid auditing and hopefully to guide dependency selection. It is however the opinion of the author of this project that libraries choosing to abstain from unsafe Rust usage when possible should be promoted.
This project is an attempt to create pressure against unnecessary usage of unsafe Rust in public Rust libraries.
https://en.wikipedia.org/wiki/Geiger_counter
Unsafe code and ionizing radiation have something in common, they are both inevitable in some situations and both should preferably be safely contained!
build.rs
are probably not detected.#![forbid(unsafe_code)]
should be a reliable alternative (implemented since
0.6.0). Please see the changelog.cargo
crate feature: vendored-openssl
. [#99]-Z
flag now requires quotes around
its list of sub arguments, other than that there should be no changes to
the CLI.#[forbid(unsafe_code)]
for it to count as crate-wide.--forbid-only
. This mode doesn't require any calls
to rustc
and only requires parsing the entry point .rs
files, making it
much faster than the normal mode..rs
source
files, used by the build, declare #![forbid(unsafe_code)]
. Crates like
this will be printed in green..rs
file, used by the build, does not declare #[forbid(unsafe_code)]
. Crates
like this will be printed in the default terminal foreground color.cargo
, to the new crate
[geiger]. Main github issue: [#30].Bugfix: Merge pull request [#33] from ajpaverd/windows_filepaths. Canonicalize file paths from walker.
Merge pull request [#38] from anderejd/updated-deps. Updated deps and fixed build errors.
Merge pull request [#28] from alexmaco/deps_upgrade. fix build on rust 1.30: upgrade petgraph to 0.4.13
Bugfix: Merge pull request [#29] from alexmaco/invalidutf8source. fix handling source files with invalid utf8: lossy conversion to string
--include-tests
. The test code is filted out by looking for the attribute
#[test]
on functions and #[cfg(test)]
on modules.rustc
calls and reads the .d
files generated by rustc
to
identify which .rs
files are used by the build. This allows a crate that
contains .rs
files with unsafe code usage to pass as "green" if the unsafe
code isn't used by the build.x/y
, where x
is the unsafe code used by the
build and y
is the total unsafe usage found in the crate.--compact
output format to avoid some code complexity. A new
and better compact mode can be added later if requested.