Skip to content

Ability to check if a dependency is too new (missing enforcement part of min-publish-age) #17246

Description

@linus-mullvad

Problem

Getting (nightly) support for preventing cargo from upgrading dependencies to too new versions (-Zmin-publish-age) is a step in the right direction! #17009. But I can't find any way to enforce a don't-use-too-new-dependencies policies in repositories.

The new feature seems to focus on protecting the developer from accidentally upgrading to a too new dependency when modifying Cargo.lock locally. I see no way currently to integrate this in CI to let a project deny PRs and changes that tries to upgrade dependencies beyond the allowed point in time.

Without this I'm not sure how min-publish-age could benefit my projects, as I cannot easily protect my supply chain from too new dependencies.

Proposed Solution

Make cargo check and cargo build min-publish-age-aware and exit with a specific error code if any dependency in the dependency tree is too new. That would prevent anyone from ever compiling a too new dependency. This is arguably the important part, since a newly published malicious crate can only cause damage when actually built.

Also introduce a subcommand that only checks that the lockfile adheres to established configuration rules. This could run much faster in CI and would not need to check the actual code.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverA-new-lintArea: new lintC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.Z-min-publish-ageNightly: min-publish-age (RFC 3923)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions