Skip to content

feat(SBOM): implement new storage model#93

Open
reyreavman wants to merge 2 commits into
mainfrom
feat/sbom/implementation-new-storage-version
Open

feat(SBOM): implement new storage model#93
reyreavman wants to merge 2 commits into
mainfrom
feat/sbom/implementation-new-storage-version

Conversation

@reyreavman
Copy link
Copy Markdown
Collaborator

No description provided.

@reyreavman reyreavman force-pushed the feat/sbom/implementation-new-storage-version branch 7 times, most recently from da043f9 to ca6aef9 Compare May 27, 2026 09:30
Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
@reyreavman reyreavman force-pushed the feat/sbom/implementation-new-storage-version branch from ca6aef9 to 5a362fc Compare May 27, 2026 09:36
Comment thread pkg/oci/artifact/store.go Outdated
func (s *OCIStore) remoteOptions(ctx context.Context) []remote.Option {
return []remote.Option{
remote.WithContext(ctx),
remote.WithAuthFromKeychain(authn.DefaultKeychain),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use Container Registry auth from werf.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remoteOpts := append(api.defaultRemoteOptionsForHost(ctx, ref.String()), remote.WithProgress(c))

Comment thread cmd/werf/sbom/get/get.go
"bytes"
"context"
"fmt"
"io"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread pkg/oci/artifact/store.go
return Attach(ctx, s.repo, parentDigest, artifactDesc, artifactType, s.imageName)
}

func (s *OCIStore) GetAttached(ctx context.Context, parentDigest, artifactType string) (v1.Descriptor, bool, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's document: two equal image digests -> one (same) SBOM

Comment thread pkg/build/sbom_step.go Outdated

if err = step.containerBackend.Tag(ctx, sbomImgId, sbomImageName, container_backend.TagOpts{}); err != nil {
return fmt.Errorf("unable to tag sbom image: %w", err)
digestHex := strings.TrimPrefix(parentDigest, "sha256:")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use move robust approach (hash alg could change in future) or a library for digest parsing.

For example: https://pkg.go.dev/github.com/opencontainers/go-digest#Digest.Encoded

Comment thread pkg/build/sbom_step.go Outdated
}); err != nil {
return nil, fmt.Errorf("unable to pull image SBOM: %w", err)
store := step.artifactStore
if store == nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we create store here? I think we have to require store here and we should return the error if store is nil.

I mean no need lazy store initialization

Comment thread pkg/oci/artifact/fallback.go Outdated
func RemoteOptions(ctx context.Context) []remote.Option {
return []remote.Option{
remote.WithContext(ctx),
remote.WithAuthFromKeychain(authn.DefaultKeychain),
Copy link
Copy Markdown
Collaborator

@nervgh nervgh Jun 1, 2026

Choose a reason for hiding this comment

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

The same here question with using credentials

Comment thread pkg/sbom/image/dsse.go

// WrapInInTotoStatement wraps the predicate into an in-toto v1 statement.
func WrapInInTotoStatement(predicate []byte, predicateType, repo, digestHex string) ([]byte, error) {
stmt := inTotoStatement{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we use specific Go pkg https://github.com/in-toto/in-toto-golang ?

Comment thread pkg/sbom/image/dsse.go Outdated
"fmt"
)

type dsseEnvelope struct {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread pkg/sbom/image/image.go Outdated
func BaseImageName(repo, tag string) string {
return ImageName(fmt.Sprintf("%s:%s", repo, tag))
func PushSBOM(ctx context.Context, bomJSON []byte, repo, parentDigest, imageName, checksum string) error {
digestHex := strings.TrimPrefix(parentDigest, "sha256:")
Copy link
Copy Markdown
Collaborator

@nervgh nervgh Jun 1, 2026

Choose a reason for hiding this comment

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

The same question with parsing digests

Comment thread pkg/storage/repo_stages_storage.go Outdated

parentTag := strings.TrimSuffix(tag, sbomImage.TagSuffix)
if _, exists := tagSet[parentTag]; exists {
parentDigest := strings.Replace(tag, artifact.FallbackTagPrefix, "sha256:", 1)
Copy link
Copy Markdown
Collaborator

@nervgh nervgh Jun 1, 2026

Choose a reason for hiding this comment

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

The same question with parsing digests

@reyreavman reyreavman force-pushed the feat/sbom/implementation-new-storage-version branch 2 times, most recently from f157558 to e4978e9 Compare June 3, 2026 06:43
Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
@reyreavman reyreavman force-pushed the feat/sbom/implementation-new-storage-version branch from e4978e9 to 369e7df Compare June 3, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants