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.
Build release binaries with cargo auditable to embed dependency data #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Build release binaries with cargo auditable to embed dependency data #937
Changes from all commits
c78209dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
command -vguard defeats the version pin that the PR is built around.If any
cargo-auditableis already onPATHβ an older 0.6.x on a dev machine, a preinstalled one on a CI runner, whatever a future base image ships β the install is skipped and the build silently uses that version instead of 0.7.5. So the claim that "cargo-auditableis pinned to0.7.5in all build paths so every artifact embeds identically formatted data" doesn't actually hold for themakepath.Gate on the version rather than on presence:
(The dangling
# The cargo-auditable embedded data is sorted and timestamp-freecomment sits above the install target where it reads as a claim about the installer; it belongs next to thebuildtarget or in the reproducibility section.)Same pattern applies to
install-cargo-auditbelow. I realizeinstall-cargo-debalready usescommand -v, so this is pre-existing repo style β but the pin matters more here, since the whole point is byte-identical embedded metadata across build paths.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audit-binpasses vacuously when there is nothing to scan.The target doesn't depend on
build, and if$(BUILD_OUTPUT_DIR)doesn't exist (or is empty) the glob stays unexpanded as the literal stringtarget/.../*,[ -f ... ]is false, the loop body never runs,failstays0and the target exits0. A fresh checkout β or someone runningmake audit-binbeforemake build, or with a differentBUILD_PROFILE/BUILD_TARGETthan the one that was built β gets a green "audit passed" having scanned zero binaries. That's the worst failure mode for a security-scanning target.Also worth handling:
cargo audit binon a binary with no.dep-v0section falls back to guessing versions from panic strings, so stale non-auditable artifacts left intarget/produce low-confidence results silently mixed in with the real ones.Suggest counting what was scanned and failing if it's zero:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section says release builds go through
cargo auditable, but the "Reproducible builds" section immediately above (lines 157β176) tells users to run plaincargo build --releaseand shows a specific expectedsha256sum. Those two now describe divergent binaries: following the reproducible-builds instructions produces an artifact without the.dep-v0section, and one whose hash won't match anythingmake buildproduces. Worth reconciling the two sections so it's clear which command corresponds to the released artifact.Nit: "such as
trivy,grype,syft. Meaning that container imagesβ¦" β sentence fragment;syft, meaning that container imagesβ¦`.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth verifying once that the
.dep-v0section actually survives this build path.cargo-auditableinjects viaRUSTC_WORKSPACE_WRAPPER, and this stage inheritsRUSTC_WRAPPER=sccachefrombase(line 43), so cargo ends up chainingcargo-auditable β sccache β rustc. That chaining is supposed to work, but combined with thecargo chef cooklayer (line 66) building deps without the wrapper and the persistent sccache mount, a cache hit silently returning a non-instrumented artifact would produce a released image with no audit data and no error.A
cargo audit bin /app/target/release/${RBUILDER_BIN}(or areadelf -S | grep dep-v0) right after the build would turn that into a hard failure instead of a silent one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the image that backs the reproducible Linux release artifacts, and the PR changes what it emits without re-verifying determinism. Two things to confirm before merging:
cargo-auditablelinks an extra generated object into the binary. It's documented as sorted/deterministic, but this repo goes to unusual lengths for bit-identical output (-C metadata='',--build-id=none,--remap-path-prefix,SOURCE_DATE_EPOCH) β the object file is produced in a temp dir, so it's worth an actual two-run hash comparison rather than taking the docs' word for it.cargo install ... --lockedfrom crates.io is now the one un-snapshotted network fetch in the reproducible builder. It's pinned by version+lockfile so it should resolve identically, but it does mean the reproducible image's inputs are no longer sourced from a single snapshot.Also a minor cost: this compiles
cargo-auditableand its dependency tree from source on every cold build of this image, with no registry cache mount.Uh oh!
There was an error while loading. Please reload this page.