#unsafe #cargo-subcommand #cargo #plugin

bin+lib cargo-geiger

Detects usage of unsafe Rust in a Rust crate and its dependencies

31 releases

0.11.7 Feb 1, 2024
0.11.6 Mar 31, 2023
0.11.5 Jan 9, 2023
0.11.4 Aug 1, 2022
0.4.0 Jul 23, 2018

#217 in Cargo plugins

Download history 68/week @ 2024-01-01 60/week @ 2024-01-08 40/week @ 2024-01-15 49/week @ 2024-01-22 214/week @ 2024-01-29 272/week @ 2024-02-05 149/week @ 2024-02-12 112/week @ 2024-02-19 120/week @ 2024-02-26 127/week @ 2024-03-04 108/week @ 2024-03-11 77/week @ 2024-03-18 52/week @ 2024-03-25 112/week @ 2024-04-01 80/week @ 2024-04-08 68/week @ 2024-04-15

315 downloads per month

Apache-2.0/MIT

255KB
6.5K SLoC

cargo-geiger ☢️

CI unsafe forbidden crates.io Crates.io

A tool that lists statistics related to the usage of unsafe Rust code in a Rust crate and all its dependencies.

This cargo plugin was originally based on the code from two other projects:

Installation

Try to find and use a system-wide installed OpenSSL library:

cargo install --locked cargo-geiger

Or, build and statically link OpenSSL as part of the cargo-geiger executable:

cargo install --locked cargo-geiger --features vendored-openssl

Alternatively pre-built binary releases are available from GitHub releases.

Usage

  1. Navigate to the same directory as the Cargo.toml you want to analyze.
  2. cargo geiger

Intended Use

This tool is not meant to advise directly whether the code ultimately is truly insecure or not.

The purpose of cargo-geiger is to provide statistical input to auditing e.g. with:

The use of unsafe is nuanced and necessary in some cases and any motivation to use it is outside the scope of cargo-geiger.

It is important that any reporting is handled with care:

Output example

Example output

Known issues

Libraries

Cargo Geiger exposes three libraries:

  • cargo-geiger - Unversioned and highly unstable library exposing the internals of the cargo-geiger binary. As such, any function contained within this library may be subject to change.
  • cargo-geiger-serde - A library containing the serializable report types
  • geiger - A library containing a few decoupled cargo components used by cargo-geiger

Changelog

See the changelog.

Why the name?

https://en.wikipedia.org/wiki/Geiger_counter

Unsafe code, like ionizing radiation, is unavoidable in some situations and should be safely contained!

Dependencies

~75MB
~1.5M SLoC