-
Notifications
You must be signed in to change notification settings - Fork 209
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?
Changes from all commits
c78209d
7f66753
c39059f
3def517
d5b0b6a
05afbfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0.7.5 |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -156,25 +156,36 @@ curl http://localhost:5555/relay/v1/data/bidtraces/proposer_payload_delivered | |||||||||||||
|
|
||||||||||||||
| ### Reproducible builds | ||||||||||||||
|
|
||||||||||||||
| You only need to set the `SOURCE_DATE_EPOCH` environment variable to ensure that the build is reproducible: | ||||||||||||||
| `make build` produces reproducible binaries on x86_64: it sets the `SOURCE_DATE_EPOCH` | ||||||||||||||
|
shashial marked this conversation as resolved.
|
||||||||||||||
| environment variable (last commit timestamp) and the required compiler flags automatically: | ||||||||||||||
|
Comment on lines
+159
to
+160
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still unaddressed from the last round: "sets
Suggested change
Also, |
||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| # Use last commit timestamp as the build date | ||||||||||||||
| $ export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) | ||||||||||||||
|
|
||||||||||||||
| # build #1 | ||||||||||||||
| $ rm -rf target/ | ||||||||||||||
| $ cargo build --release | ||||||||||||||
| $ sha256sum target/release/rbuilder | ||||||||||||||
| d92ac33b94e16ed4a035b9dd52108fe78bd9bb160a91fced8e439f59b84c3207 target/release/rbuilder | ||||||||||||||
| $ make build | ||||||||||||||
| $ sha256sum target/x86_64-unknown-linux-gnu/reproducible/rbuilder | ||||||||||||||
| <hash> target/x86_64-unknown-linux-gnu/reproducible/rbuilder | ||||||||||||||
|
|
||||||||||||||
| # build #2 | ||||||||||||||
| $ rm -rf target/ | ||||||||||||||
| $ cargo build --release | ||||||||||||||
| $ sha256sum target/release/rbuilder | ||||||||||||||
| d92ac33b94e16ed4a035b9dd52108fe78bd9bb160a91fced8e439f59b84c3207 target/release/rbuilder | ||||||||||||||
| $ make build | ||||||||||||||
| $ sha256sum target/x86_64-unknown-linux-gnu/reproducible/rbuilder | ||||||||||||||
| <hash> target/x86_64-unknown-linux-gnu/reproducible/rbuilder | ||||||||||||||
|
|
||||||||||||||
| # the two hashes are identical | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| ### Auditable builds | ||||||||||||||
|
|
||||||||||||||
| Release builds (`make build`, the Docker images, and the released binaries) go through | ||||||||||||||
| [`cargo auditable`](https://github.com/rust-secure-code/cargo-auditable), which embeds the full | ||||||||||||||
| dependency list into each binary. The embedded data can be read by scanners such as | ||||||||||||||
| `cargo audit bin`, `trivy`, `grype`, and `syft`, so both the binaries and the container images | ||||||||||||||
| built from them can be scanned for Rust dependencies. | ||||||||||||||
|
|
||||||||||||||
| The pinned `cargo-auditable` version used by all build paths lives in | ||||||||||||||
| [`.cargo-auditable-version`](./.cargo-auditable-version). | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Release Stability and Development Process | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,10 @@ RUN set -eux; \ | |
| rm -rf /tmp/sccache.tar.gz /tmp/sccache-v0.8.2-${ARCH_TAG} | ||
|
|
||
| RUN cargo install cargo-chef --version ^0.1 | ||
| COPY .cargo-auditable-version /tmp/cargo-auditable-version | ||
| RUN v="$(cat /tmp/cargo-auditable-version)"; \ | ||
| [ -n "$v" ] || { echo "ERROR: could not read cargo-auditable version from .cargo-auditable-version"; exit 1; }; \ | ||
| cargo install cargo-auditable@"$v" --locked | ||
|
|
||
|
|
||
| ENV CARGO_HOME=/usr/local/cargo | ||
|
|
@@ -72,14 +76,18 @@ ARG FEATURES | |
| RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
| --mount=type=cache,target=/usr/local/cargo/git \ | ||
| --mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
| cargo build --release --features="$FEATURES" --package=${RBUILDER_BIN} | ||
| cargo auditable build --release --features="$FEATURES" --package=${RBUILDER_BIN} | ||
|
shashial marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This stage has Minor: line 39 leaves |
||
| RUN readelf -S /app/target/release/${RBUILDER_BIN} | grep -q '\.dep-v0' \ | ||
| || { echo "ERROR: .dep-v0 audit section missing from ${RBUILDER_BIN}"; exit 1; } | ||
|
|
||
| FROM builder AS test-relay | ||
| ARG FEATURES | ||
| RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
| --mount=type=cache,target=/usr/local/cargo/git \ | ||
| --mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
| cargo build --release --features="$FEATURES" --package=test-relay | ||
| cargo auditable build --release --features="$FEATURES" --package=test-relay | ||
| RUN readelf -S /app/target/release/test-relay | grep -q '\.dep-v0' \ | ||
| || { echo "ERROR: .dep-v0 audit section missing from test-relay"; exit 1; } | ||
|
|
||
|
|
||
| # Runtime container for test-relay | ||
|
|
||
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
Verify audit data embedded (Mac)step that followed this build in the previous commit was dropped infix review, so the Mac release artifacts are now the only build path in this PR with no.dep-v0assertion βdocker/Dockerfile.rbuilder:80anddocker/Dockerfile.reproducible:20both check, this doesn't.That's the wrong path to drop it from. The two Docker checks exercise ELF section emission; Mach-O is the one object format nothing here covers. If
cargo auditablesilently no-ops on darwin β linker dropping the__DATA,.dep-v0section, a toolchain change, a badcargo installβ six darwin release binaries ship without embedded data and the release is green.If it was removed because it can only ever fail during a real release,
cargo audit binis the better version of the check: it errors on a binary with no embedded data rather than grepping a tool-specific section rendering, and it doubles as the vulnerability scan. Otherwise, re-add theotool -lstep and confirm it once with aworkflow_dispatchrun (build-mac: true,draft-release: false) before merging.