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

Adds support for DependencyLayerContributor and HelperLayerContributor to generate SBOMs #105

Merged
merged 1 commit into from Nov 19, 2021

Conversation

dmikusa
Copy link
Contributor

@dmikusa dmikusa commented Nov 19, 2021

  • DependencyLayerContributor will write an SBOM with the dependency's metadata
  • HelperLayerContributor will write an SBOM entry with the helper's metadata
  • Both are written to the layer's SBOM file
  • The DependencyLayerContributor support adds two new metadata fields to the BuildpackDependency object: purl and cpes.
    • purl is a string for the package URL, based on https://github.com/package-url/purl-spec
    • cpes is a list of strings for multiple CPE, or Common Platform Enumeration, identifiers
    • the values for these two fields are loaded from dependencies entries in buildpack.toml
    • if not specified, they default to the Go empty values
    • a single artifact entry is added for each dependency
  • The HelpLayerContributor support generates a SBOM file with the following information. It is automatic and no additional metadata is required.
    • Name is helper
    • Version is the buildpack version
    • Licenses contains the buildpack's license
    • Locations contains a list of the helper names that are setup for this helper
    • CPEs is a list of cpe:2.3:a:<buildpack-id>:<helper-name>:<buildpack-version:*:*:*:*:*:*:*
    • PURL is pkg:generic/<buildpack-id>@<buildpack-version>
  • ID hashes for all artifacts are calculated using github.com/mitchellh/hashstructure/v2 and are a hash of the SyftArtifact object before setting the ID.

This functionality requires buildpack API 0.7, for older buildpack versions you may call these methods and they will function properly, however, the lifecycle will not persist any of the information generated.

Other incidental changes in this commit:

  • Fixes a bug with syft packages. There was a typo in the command and th -q argument was missing.
  • Moves SBOM functionality from the sherpa package into its own package sbom.
  • Bumps to libcnb 1.25.0, which is required for the buildpack API 0.7 support.

Signed-off-by: Daniel Mikusa dmikusa@vmware.com

@dmikusa dmikusa added type:enhancement A general enhancement semver:minor A change requiring a minor version bump labels Nov 19, 2021
@dmikusa dmikusa requested a review from a team November 19, 2021 02:15
@dmikusa dmikusa force-pushed the sbom-deps branch 2 times, most recently from 625cfd3 to 2b9b558 Compare November 19, 2021 19:48
…r to generate SBOMs

- DependencyLayerContributor will write an SBOM with the dependency's metadata
- HelperLayerContributor will write an SBOM entry with the helper's metadata
- Both are written to the layer's SBOM file
- The DependencyLayerContributor support adds two new metadata fields to the BuildpackDependency object: `purl` and `cpes`.
  - purl is a string for the package URL, based on https://github.com/package-url/purl-spec
  - cpes is a list of strings for multiple CPE, or Common Platform Enumeration, identifiers
  - the values for these two fields are loaded from dependencies entries in buildpack.toml
  - if not specified, they default to the Go empty values
  - a single artifact entry is added for each dependency
- The HelpLayerContributor support generates a SBOM file with the following information. It is automatic and no additional metadata is required.
  - Name is `helper`
  - Version is the buildpack version
  - Licenses contains the buildpack's license
  - Locations contains a list of the helper names that are setup for this helper
  - CPEs is a list of `cpe:2.3:a:<buildpack-id>:<helper-name>:<buildpack-version:*:*:*:*:*:*:*`
  - PURL is `pkg:generic/<buildpack-id>@<buildpack-version>`
- ID hashes for all artifacts are calculated using `github.com/mitchellh/hashstructure/v2` and are a hash of the SyftArtifact object before setting the ID.
- NewDependencyLayerContributor will return an empty BOMEntry if the dependency in question has an empty PURL and an empty CPEs list. This prevents old style and new style BOM entries from both being written, which causes an error under buildpacks API 0.7 and platform API 0.8 but allows for backwards compatibility.
- NewHelperLayerContributor will also return an empty BOMEntry but it is based on the API version for the buildpack that contributes the helpers. If that is 0.7, it will be empty. If it's 0.6 or less, it'll return an entry as before. This prevents old style and new style BOM entries from both being written, which causes an error under buildpacks API 0.7 and platform API 0.8 but allows for backwards compatibility.
- Old style BOM entries are deprecated and will be removed in a future version of libpak.

This functionality requires buildpack API 0.7, for older buildpack versions you may call these methods and they will function properly, however, the lifecycle will not persist any of the information generated.

Other incidental changes in this commit:

- Fixes a bug with `syft packages`. There was a typo in the command and th `-q` argument was missing.
- Moves SBOM functionality from the `sherpa` package into its own package `sbom`.
- Bumps to libcnb 1.25.0, which is required for the buildpack API 0.7 support.

Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
@dmikusa dmikusa merged commit 5cea674 into main Nov 19, 2021
@dmikusa dmikusa deleted the sbom-deps branch November 19, 2021 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants