Add cargo-auditable support for dependency SBOM embedding#3995
Open
tamasvajk wants to merge 1 commit intobazelbuild:mainfrom
Open
Add cargo-auditable support for dependency SBOM embedding#3995tamasvajk wants to merge 1 commit intobazelbuild:mainfrom
tamasvajk wants to merge 1 commit intobazelbuild:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
6e1ad2a to
2fb18e1
Compare
Embeds cargo-auditable compatible dependency metadata (.dep-v0 section) into Rust binaries and shared libraries. When enabled via --@rules_rust//rust/settings:auditable=true, the build generates a JSON dependency manifest, zlib-compresses it, and links it into the binary as a .dep-v0 ELF section. This enables vulnerability scanning tools like trivy/syft to extract dependency information from compiled binaries. Key changes: - New auditable_injector tool that generates platform-appropriate .dep-v0 object files from JSON dependency manifests - CrateInfo provider extended with pkg_name, version, and source fields - New bool_flag //rust/settings:auditable to control the feature - rust_binary and rust_shared_library gain an auditable_injector attribute - Analysis tests verify action graph correctness
2fb18e1 to
bf66b1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Embeds cargo-auditable compatible dependency metadata (
.dep-v0section) into Rust binaries and shared libraries built with rules_rust.When enabled via
--@rules_rust//rust/settings:auditable=true, the build:CrateInfoprovider graphThis enables vulnerability scanning tools like
cargo audit bin,trivy, andsyftto extract dependency information from compiled binaries without access to source code or build manifests.Changes
New build setting:
//rust/settings:auditable— bool flag, defaults tofalseCrateInfo provider extended with:
pkg_name— Cargo package name (extracted fromcrate-name=tag added by crate_universe)version— semver versionsource— crate source (CratesIo, Git, Local, Registry)New
auditable_injectortool (tools/auditable/):.dep-v0object files from JSON manifestsminiz_oxide0.9,object0.39Rule changes:
rust_binaryandrust_shared_librarygain anauditable_injectorattributerust/defs.bzlwrappers auto-set the injector viaselect()on the auditable flagrust_binarydirectly fromrust/private:rust.bzlto avoid a dependency cycleTesting
Analysis tests (
test/unit/auditable/):rust_librarynever gets auditable actionsInjector unit tests (
tools/auditable/main.rs, 16 tests):Noneis_wasm,is_apple,is_windows,is_32bit,riscv_features,leb128)End-to-end verification:
--@rules_rust//rust/settings:auditable=truecargo audit binsuccessfully reads the.dep-v0section and identifies all 21 dependencies