Closed vladklokun closed 11 months ago
PR Description updated to latest commit (https://github.com/kubescape/kubevuln/commit/e728100d125f77bea4bf426ceff198943516a13f)
๐ฏ Main theme: Refactoring and enhancement of Software Bill of Materials (SBOMs) generation and storage using Syft
๐ PR summary: This PR introduces significant changes to the generation and storage of Software Bill of Materials (SBOMs) using Syft. The changes include refactoring of the CreateSBOM
function, introduction of new utility functions for handling hash algorithms, modification of the SBOM
struct to use SyftDocument
instead of Document
, and updates to import paths and dependencies.
๐ Type of PR: Enhancement
๐งช Relevant tests added: No
โฑ๏ธ Estimated effort to review [1-5]: 4, because the PR involves significant changes to the codebase, including refactoring of functions and changes to data structures. The PR also introduces new utility functions and modifies import paths and dependencies, which requires careful review to ensure compatibility and correctness.
๐ Security concerns: No security concerns found
๐ก General suggestions: The PR introduces significant changes and enhancements to the generation and storage of SBOMs. It would be beneficial to include unit tests for the new utility functions and the refactored CreateSBOM
function to ensure their correctness. Additionally, it would be helpful to provide more context or documentation about the changes in the PR description, especially for those not familiar with the project or the specific functionalities being modified.
Type
Enhancement
Description
This Pull Request introduces significant changes to the generation and storage of Software Bill of Materials (SBOMs) using Syft. The main updates include:
CreateSBOM
function inadapters/v1/syft.go
to improve the generation of SBOMs.adapters/v1/syft_utils.go
for handling hash algorithms.SBOM
struct incore/domain/sbom.go
to useSyftDocument
instead ofDocument
.adapters/v1/domain_to_syft.go
to reflect changes in the Syft library.go.mod
andgo.sum
.PR changes walkthrough
3 files
syft.go
adapters/v1/syft.go
The `CreateSBOM` function has been significantly refactored
to improve the generation of SBOMs. The function now uses
the `detectSource` and `generateSBOM` helper functions to
simplify the process of generating SBOMs. The `detectSource`
function uses the Syft library's `Detect` function to
determine the source of the image, and the `generateSBOM`
function uses the `RunTask` function from the Syft library's
`eventloop` package to generate the SBOM.
syft_utils.go
adapters/v1/syft_utils.go
This new file introduces utility functions for handling hash
algorithms. The `Hashers` function returns a list of hash
algorithms based on the provided names, and the
`CleanDigestAlgorithmName` function cleans the name of a
digest algorithm.
sbom.go
core/domain/sbom.go
The `SBOM` struct has been modified to use `SyftDocument`
instead of `Document` for its `Content` field. This change
reflects the use of the Syft library for generating SBOMs.
3 files
domain_to_syft.go
adapters/v1/domain_to_syft.go
The import paths have been updated to reflect changes in the
Syft library. The `spdxhelpers` package is now imported from
`github.com/anchore/syft/syft/format/common/spdxhelpers`
instead of
`github.com/anchore/syft/syft/formats/common/spdxhelpers`.
go.mod
go.mod
The dependencies have been updated, likely to reflect
changes in the Syft library.
go.sum
go.sum
The dependencies have been updated, likely to reflect
changes in the Syft library.
User description
Overview