Skip to content

Commit

Permalink
fix: don't map the image name in sbom reports (#647)
Browse files Browse the repository at this point in the history
fixes: #645

Co-authored-by: Zbigniew BARANOWSKI <[email protected]>
  • Loading branch information
zbaranow and Zbigniew BARANOWSKI authored Jun 1, 2024
1 parent aaf78a5 commit 1aa9c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 0 additions & 11 deletions internal/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

libk8s "github.com/ckotzbauer/libk8soci/pkg/kubernetes"
liboci "github.com/ckotzbauer/libk8soci/pkg/oci"
"github.com/ckotzbauer/libstandard"
"github.com/ckotzbauer/sbom-operator/internal"
"github.com/ckotzbauer/sbom-operator/internal/job"
"github.com/ckotzbauer/sbom-operator/internal/kubernetes"
Expand Down Expand Up @@ -185,11 +184,6 @@ func (p *Processor) executeSyftScans(pods []libk8s.PodInfo, allImages []*liboci.
targetImages := t.LoadImages()
removableImages := make([]*liboci.RegistryImage, 0)
for _, t := range targetImages {
err := kubernetes.ApplyProxyRegistry(t, false, libstandard.ToMap(internal.OperatorConfig.RegistryProxies))
if err != nil {
logrus.WithError(err).Debugf("Could not parse image")
}

if !containsImage(allImages, t.ImageID) {
removableImages = append(removableImages, t)
delete(p.imageMap, t.ImageID)
Expand Down Expand Up @@ -287,11 +281,6 @@ func (p *Processor) cleanupImagesIfNeeded(removedContainers []*libk8s.ContainerI
for _, po := range allPods {
pod := po.(*corev1.Pod)
info := p.K8s.Client.ExtractPodInfos(*pod)
err := kubernetes.ApplyProxyRegistry(c.Image, false, libstandard.ToMap(internal.OperatorConfig.RegistryProxies))
if err != nil {
logrus.WithError(err).Debugf("Could not parse image")
}

found = found || containsContainerImage(info.Containers, c.Image.ImageID)
}

Expand Down
9 changes: 9 additions & 0 deletions internal/syft/syft.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ func (s Syft) WithSyftVersion(version string) Syft {

func (s *Syft) ExecuteSyft(img *oci.RegistryImage) (string, error) {
logrus.Infof("Processing image %s", img.ImageID)

oriImage := img.Image
oriImageID := img.ImageID

err := kubernetes.ApplyProxyRegistry(img, true, s.proxyRegistryMap)
if err != nil {
return "", err
}

opts := &image.RegistryOptions{Credentials: oci.ConvertSecrets(*img, s.proxyRegistryMap)}
src, err := getSource(context.Background(), opts, img.ImageID)

// revert image info to the original value - we want to register with original names
img.Image = oriImage
img.ImageID = oriImageID

if err != nil {
logrus.WithError(fmt.Errorf("failed to construct source from input registry:%s: %w", img.ImageID, err)).Error("Source-Creation failed")
return "", err
Expand Down

0 comments on commit 1aa9c4b

Please sign in to comment.