Dependency auditing and supply chain
Quick answer
A Rust dependency can introduce vulnerabilities, malicious build-time behavior or unexpected licensing obligations. Review the resolved dependency graph, not just the crates you import directly.
Audit the actual build
Cargo.lock records resolved versions for a project. cargo tree helps explain transitive dependencies; cargo audit is a separately installed tool that compares resolved dependencies against known RustSec advisories. Pin the tool in CI after checking its compatibility, review advisory applicability and update carefully. A clean report does not prove a crate is trustworthy; build scripts and procedural macros may execute code during compilation. Review sources and minimize build privileges.
Manual terminal step; not executed. Expected behavior (environment dependent):
Dependency tree, or an error if resolution needs to change the lockfile.The command exposes dependencies for review; it is not a vulnerability scanner.
Manual terminal step; not executed. Expected behavior (environment dependent):
Advisory report or tool/network/database error; results depend on Cargo.lock and the advisory database.Do not treat tool failure as a clean audit. Installation and database freshness must be checked separately.
Common mistake
Do not blindly update or run an unfamiliar crate simply because an audit suggests a newer version.
Try it yourself
Choose a dependency in a local project, identify its parent with cargo tree and describe the review needed before upgrading.
Static examples for Rust 1.85.0, edition 2024. Run them locally in a disposable project; ByteMind execution support and these outputs have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Dependency auditing and supply chain — practice quiz
Choose one answer per question. Code examples are predictions; review explanations after attempting them.
Cargo audit reports no known advisory. Is that sufficient to trust a build script?
Dependency auditing and supply chain — example 1. Read the code; do not execute it for this question. Assume the lesson’s stated setup, compatible dependencies and toolchain, and a fresh disposable directory for file-creating examples. ```bash cargo tree --locked ``` Which outcome or interpretation best matches this example?
Dependency auditing and supply chain — example 2. Read the code; do not execute it for this question. Assume the lesson’s stated setup, compatible dependencies and toolchain, and a fresh disposable directory for file-creating examples. ```bash cargo audit ``` Which outcome or interpretation best matches this example?