Cargo-Geiger
Cargo-Geiger

原始链接: https://github.com/geiger-rs/cargo-geiger

**Cargo-geiger** 是一个 Rust cargo 插件,旨在扫描你的 crate 及其依赖项,提供有关 `unsafe` 代码使用情况的统计信息。正如其名——盖革计数器(Geiger counter)一样,该工具能够识别 `unsafe` 代码块所在的位置,帮助开发者确定人工安全审计的优先级。 该工具并不声称代码本身是不安全的;它主要提供用于风险评估的数据。它承认 `unsafe` 代码通常是 Rust 开发中不可或缺的一部分,应当在谨慎的监督下进行处理。 **安装与使用:** * **安装:** 通过 `cargo install --locked cargo-geiger` 进行安装。对于需要特定 OpenSSL 配置的系统,请使用 `--features vendored-openssl` 标志,或从 GitHub 下载预构建的二进制文件。 * **使用:** 在包含 `Cargo.toml` 文件的目录下执行 `cargo geiger` 即可生成报告。 该项目包含若干内部库(`cargo-geiger`、`cargo-geiger-serde` 和 `geiger`),用于处理分析和报告序列化。用户应查阅更新日志以获取最新信息,并请注意内部 API 可能不稳定。

Hacker News | 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 | 登录 Cargo-Geiger (github.com/geiger-rs) 4 分,作者:tosh,1 小时前 | 隐藏 | 过往 | 收藏 | 讨论 | 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

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:

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.

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

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:

Example output

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

See the changelog.

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

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

联系我们 contact @ memedata.com