17 个版本 (7 个稳定版)
新版本 1.4.0 | 2024 年 8 月 21 日 |
---|---|
1.3.0 | 2024 年 7 月 29 日 |
1.0.2 | 2024 年 5 月 24 日 |
0.4.0 | 2024 年 2 月 9 日 |
0.2.1 | 2023 年 11 月 22 日 |
#77 在 Cargo 插件 中
每月 1,286 次下载
225KB
2K SLoC
cargo-unmaintained
在 Rust 项目中查找未维护的包
cargo-unmaintained
与 cargo-audit
类似。但是,cargo-unmaintained
使用启发式方法自动查找未维护的包,而不是依赖用户手动提交到 RustSec 咨询数据库。
cargo-unmaintained
将未维护的包 X 定义为满足以下 1 至 3 中的一个
-
X 的仓库已被存档(见下文 注释)。
-
X 不是其命名仓库的成员。
-
以下 a 和 b 都满足。
a. X 依赖于一个包 Y,该包的最新版本
- 与 X 依赖的版本不兼容
- 发布已超过一年(可配置值)
b. 要么 X 没有关联的仓库,要么其仓库的最后提交已超过一年(可配置值)。
截至 2024 年 6 月 17 日,RustSec 咨询数据库包含 98 个针对未维护包的有效咨询。使用上述条件,cargo-unmaintained
自动识别其中的 71 个(超过三分之二)。这些结果可以通过在此仓库中运行 rustsec_advisories
二进制文件进行复制。
注释
-
要检查包的仓库是否已存档,请设置环境变量
GITHUB_TOKEN_PATH
为包含一个 个人访问令牌 的文件的路径。如果未设置,此检查将被跳过。 -
上述条件仅当条件 1 或 2 适用时,才会将“叶”包(即没有依赖的包)视为未维护。
-
条件3中“一年以上”的资格目的是为了给包维护者一个更新他们包的机会。也就是说,X的一个依赖项的兼容性升级可能需要对X进行耗时的更改。如果没有这个检查,
cargo-unmaintained
会产生许多误报。 -
在RustSec咨询数据库中的27个包中,没有被
cargo-unmaintained
识别的- 8个无法构建
- 3个是存在但未归档的节点
- 1个在过去365天内进行了更新
- 15个因其他原因未被识别
输出
cargo-unmaintained
的输出包括自上次更新包的存储库以来经过的天数,以及导致该包被认为是不维护的依赖项。
例如,以下是在2023年11月11日运行cargo-unmaintained
在Cargo 0.74.0上产生的输出

安装
cargo install cargo-unmaintained
用法
Usage: cargo unmaintained [OPTIONS]
Options:
--color <WHEN> When to use color: always, auto, or never [default: auto]
--fail-fast Exit as soon as an unmaintained package is found
--max-age <DAYS> Age in days that a repository's last commit must not exceed for the
repository to be considered current; 0 effectively disables this check,
though ages are still reported [default: 365]
--no-cache Do not cache data on disk for future runs
--no-exit-code Do not set exit status when unmaintained packages are found
--no-warnings Do not show warnings
-p, --package <NAME> Check only whether package NAME is unmaintained
--tree Show paths to unmaintained packages
--verbose Show information about what cargo-unmaintained is doing
-h, --help Print help
-V, --version Print version
The `GITHUB_TOKEN_PATH` environment variable can be set to the path of a file containing a personal
access token. If set, cargo-unmaintained will use this token to authenticate to GitHub and check
whether packages' repositories have been archived.
Unless --no-exit-code is passed, the exit status is 0 if no unmaintained packages were found and no
irrecoverable errors occurred, 1 if unmaintained packages were found, and 2 if an irrecoverable
error occurred.
忽略包
如果一个工作空间的Cargo.toml
文件包含一个workspace.metadata.unmaintained.ignore
数组,则将忽略其中命名的所有包。示例
[workspace.metadata.unmaintained]
ignore = ["matchers"]
测试
由于这些测试是“受外部影响”的,即它们依赖于外部数据源,因此存储在一个单独的包ei
中。要运行这些附加测试,请使用以下命令
cargo test --package ei
已知问题
如果一个项目依赖于某个包的老版本,cargo-unmaintained
可能无法将该包标记为不维护(即可能产生假阴性)。以下是如何发生这种情况的概述。
- 项目依赖于X包的版本1,它没有依赖项。
- X包的版本2存在,并添加了Y包的版本1作为依赖项。
- Y包的版本2存在。
请注意,X包的版本1看起来是维护的,但版本2不是。忽略一些细节,版本2满足上述条件3。
cargo-unmaintained
并不总是在所有情况下检查是否使用的是包的最新版本,因为这将是成本昂贵的。这种选择的一个缺点是可能会产生假阴性。
请注意,不应以相应的方式出现假阳性。在标记包为不维护之前,cargo-unmaintained
会验证包的最新版本也将被认为是未维护的。
反目标
cargo-unmaintained
不是cargo-upgrade
的替代品。cargo-unmaintained
不应仅仅因为一个包需要升级就发出警告。
语义版本策略
我们保留更改缓存中存储的数据以及存储方式的权利,并将此类更改视为非破坏性。
许可
cargo-unmaintained
根据AGPLv3许可证许可和分发。如果您想寻求条款的例外,请联系我们。
依赖
~30–47MB
~833K SLoC