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

Update for CNB spec 0.8 (Including SBOM support) #489

Merged
merged 15 commits into from
Aug 30, 2022
Merged

Conversation

Malax
Copy link
Member

@Malax Malax commented Aug 23, 2022

Updates libcnb.rs to target CNB spec 0.8. Changes between 0.6 and 0.8 are minimal with the exception of SBOM support which takes up the majority of this PR. I opted to not open a 0.8 branch and target multiple PRs to it to speed up the process. Look at individual commits for easier review.

Relevant Documentation

Note on Cloud Native Buildpacks RFC 100

In version 0.8, a change has landed that added environment variables for values that were previously command line arguments to /bin/detect and /bin/build. This is an optional change since the classic command line arguments are still passed in and will never be removed (ref). I decided to not switch over to the environment variables for this PR to keep it smaller. We can easily decide later to make the switch. Right now, I see no benefits for libcnb.rs itself or its users.

Highlight: SBOM Support

Since the CNB specification supports multiple SBOM formats and there are many ways to generate and represent them, libcnb.rs treats them as raw bytes with attached metadata about the format.

This means there is no direct support for generating an SBOM file with libcnb.rs. Buildpack authors are expected to leverage external tooling such as build tool plugins or Rust crates to generate SBOM files.

We expect most buildpacks to use language specific tooling directly instead of implementing SBOM generation themselves. Examples are cyclonedx-maven-plugin, sbt-bill-of-materials, cyclone-dx-gradle-plugin, cyclonedx-ruby, cyclonedx-rust-cargo. Alternatively, syft has support for many ecosystems built-in: https://github.com/anchore/syft#supported-ecosystems.

libcnb.rs offers From implementations for Rust SBOM libraries (currently only cyclonedx-bom) so that these library types can be used directory with libcnb.rs without an explicit conversion step. Enable the appropriate features to gain access to them.

As the Rust SBOM ecosystem expands, we will add support for additional libraries. Support is quite sparse right now: crates.io: Crates with 'SBOM' keyword.

Highlight: SBOM Testing Support

libcnb-test was updated to allow downloading of SBOM files from a built OCI image. This feature uses pack sbom download under the hood and provides an easy way to lookup SBOM files in the rather complex directory structure pack sbom download creates.

TestRunner::default().build(
    BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
    |context| {
        context.download_sbom_files(|sbom_files| {
            assert!(sbom_files
                .path_for(
                    buildpack_id!("heroku/jvm"),
                    SbomType::Launch,
                    SbomFormat::SyftJson
                )
                .exists());
        });
    },
);

Fixes #270, Fixes #271, Fixes #299, Fixes #298, Fixes #294, Fixes #269, Fixes GUS-W-10502884

@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 6 times, most recently from 8415ad9 to 92df50f Compare August 23, 2022 14:02
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 5 times, most recently from e017a10 to d912f24 Compare August 24, 2022 09:51
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 11 times, most recently from 8fe7765 to bd66373 Compare August 24, 2022 13:42
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 2 times, most recently from 57362b1 to 5faabe4 Compare August 25, 2022 09:37
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 2 times, most recently from c74b51a to 412a2ef Compare August 25, 2022 10:02
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch 2 times, most recently from 6cb72fe to 6d679ef Compare August 25, 2022 10:24
@Malax Malax force-pushed the malax/cnb-spec-0.8 branch from 6d679ef to ffc4c0d Compare August 25, 2022 10:29
@Malax Malax marked this pull request as ready for review August 25, 2022 10:30
@Malax Malax requested a review from a team as a code owner August 25, 2022 10:30
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!

Requesting changes pending the discussion about the WorkingDirectory enum vs using Option<PathBuf>.

@Malax Malax enabled auto-merge (squash) August 30, 2022 09:38
@Malax Malax merged commit f6e7526 into main Aug 30, 2022
@Malax Malax deleted the malax/cnb-spec-0.8 branch August 30, 2022 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment