Skip to content
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

document sbom requirements #11

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ RUN cargo build --release
RUN cargo sbom > sbom.spdx.json
```

## SBoM

All EVE packages **must** have an SBoM. When the packages are built using `linuxkit pkg build`, which
itself calls buildkit, the SBoM is automatically generated and included in the package. It only scans the
final stage of the image. In the case of rust-generated binaries, the final binary does **not**
contain any information about dependencies, so the SBoM must be generated manually.

When building a package, you must:

1. Generate the sbom using `cargo sbom > sbom.spdx.json`
1. Copy the `sbom.spdx.json` into the final image

Hence, the following are **mandatory** stages:

```Dockerfile
# in the build stage FROM eve-rust, before or after `cargo build`
RUN cargo sbom > target/sbom.spdx.json

# in the final FROM scratch stage
COPY --from=rust /src/foo/target/sbom.spdx.json /sbom.spdx.json
```

The above will go away when the sbom generation is a built-in part of cargo,
to be enabled by configuration. See [this RFC](https://github.com/rust-lang/rfcs/pull/3553).


## Cross-compilation

To enable cross-compilation we need few extra steps. By default cargo builds for host platform so the target must be specified explicitly either using `--target <target>` or by setting `CARGO_BUILD_TARGET` environment variable. See [Cargo docs](https://doc.rust-lang.org/cargo/reference/environment-variables.html?highlight=CARGO_BUILD_TARGET#configuration-environment-variables)

```Dockerfile
Expand Down