Skip to content

Commit

Permalink
use filtered instead
Browse files Browse the repository at this point in the history
Signed-off-by: David Wertenteil <dwertent@armosec.io>
  • Loading branch information
David Wertenteil committed Jan 9, 2024
1 parent c758261 commit bcd9396
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/relevancymanager/v1/relevancy_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (rm *RelevancyManager) handleRelevancy(ctx context.Context, watchedContaine
defer spanPostSBOM.End()

if watchedContainer.InstanceID == nil {
logger.L().Debug("ignoring container with empty instanceID", helpers.String("container ID", containerID), helpers.String("k8s workload", watchedContainer.K8sContainerID), helpers.Error(err))
logger.L().Debug("ignoring container with empty instanceID", helpers.String("container ID", containerID), helpers.String("k8s workload", watchedContainer.K8sContainerID))
return
}
fileList, err := rm.fileHandler.GetAndDeleteFiles(watchedContainer.K8sContainerID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/storage_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (sc *StorageHttpClientMock) GetSBOM(name string) (*v1beta1.SBOMSyft, error)
return sc.mockSBOM, nil
}

func (sc *StorageHttpClientMock) PatchFilteredSBOM(_ string, _ *spdxv1beta1.SBOMSPDXv2p3Filtered) error {
func (sc *StorageHttpClientMock) PatchFilteredSBOM(_ string, _ *spdxv1beta1.SBOMSyftFiltered) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/v1/storage_nocache.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ func (sc StorageNoCache) GetSBOM(name string) (*v1beta1.SBOMSyft, error) {
return sc.StorageClient.SBOMSyfts(sc.namespace).Get(context.Background(), name, metav1.GetOptions{})
}

func (sc StorageNoCache) PatchFilteredSBOM(name string, SBOM *v1beta1.SBOMSPDXv2p3Filtered) error {
func (sc StorageNoCache) PatchFilteredSBOM(name string, SBOM *v1beta1.SBOMSyftFiltered) error {
bytes, err := json.Marshal(SBOM)
if err != nil {
return err
}
_, err = sc.StorageClient.SBOMSPDXv2p3Filtereds(sc.namespace).Patch(context.Background(), name, types.StrategicMergePatchType, bytes, metav1.PatchOptions{})
_, err = sc.StorageClient.SBOMSyftFiltereds(sc.namespace).Patch(context.Background(), name, types.StrategicMergePatchType, bytes, metav1.PatchOptions{})
if err != nil {
return err
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/storage/v1/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestStorageNoCache_GetSBOM(t *testing.T) {
createSBOM bool
name string
args args
want *v1beta1.SBOMSPDXv2p3
want *v1beta1.SBOMSyft
wantErr bool
}{
{
Expand All @@ -57,7 +57,7 @@ func TestStorageNoCache_GetSBOM(t *testing.T) {
name: storage.NginxKey,
},
createSBOM: true,
want: &v1beta1.SBOMSPDXv2p3{
want: &v1beta1.SBOMSyft{
ObjectMeta: v1.ObjectMeta{
Name: storage.NginxKey,
Namespace: "kubescape",
Expand All @@ -76,7 +76,7 @@ func TestStorageNoCache_GetSBOM(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
sc, _ := CreateFakeStorageNoCache("kubescape")
if tt.createSBOM {
_, _ = sc.StorageClient.SBOMSPDXv2p3s("kubescape").Create(context.Background(), tt.want, v1.CreateOptions{})
_, _ = sc.StorageClient.SBOMSyfts("kubescape").Create(context.Background(), tt.want, v1.CreateOptions{})
}
got, err := sc.GetSBOM(tt.args.name)
if (err != nil) != tt.wantErr {
Expand All @@ -91,7 +91,7 @@ func TestStorageNoCache_GetSBOM(t *testing.T) {
func TestStorageNoCache_PatchFilteredSBOM(t *testing.T) {
type args struct {
name string
SBOM *v1beta1.SBOMSPDXv2p3Filtered
SBOM *v1beta1.SBOMSyftFiltered
}
tests := []struct {
name string
Expand All @@ -102,10 +102,10 @@ func TestStorageNoCache_PatchFilteredSBOM(t *testing.T) {
name: "TestPatchFilteredSBOM",
args: args{
name: storage.NginxKey,
SBOM: &v1beta1.SBOMSPDXv2p3Filtered{
Spec: v1beta1.SBOMSPDXv2p3Spec{
SPDX: v1beta1.Document{
Files: []*v1beta1.File{{FileName: "test"}},
SBOM: &v1beta1.SBOMSyftFiltered{
Spec: v1beta1.SBOMSyftSpec{
Syft: v1beta1.SyftDocument{
Files: []v1beta1.SyftFile{v1beta1.SyftFile{ID: "test"}},
},
},
},
Expand All @@ -115,18 +115,18 @@ func TestStorageNoCache_PatchFilteredSBOM(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sc, _ := CreateFakeStorageNoCache("kubescape")
filteredSBOM := &v1beta1.SBOMSPDXv2p3Filtered{
filteredSBOM := &v1beta1.SBOMSyftFiltered{
ObjectMeta: v1.ObjectMeta{
Name: tt.args.name,
},
}
_, _ = sc.StorageClient.SBOMSPDXv2p3Filtereds("kubescape").Create(context.Background(), filteredSBOM, v1.CreateOptions{})
_, _ = sc.StorageClient.SBOMSyftFiltereds("kubescape").Create(context.Background(), filteredSBOM, v1.CreateOptions{})
if err := sc.PatchFilteredSBOM(tt.args.name, tt.args.SBOM); (err != nil) != tt.wantErr {
t.Errorf("PatchFilteredSBOM() error = %v, wantErr %v", err, tt.wantErr)
}
got, err := sc.StorageClient.SBOMSPDXv2p3Filtereds("kubescape").Get(context.Background(), tt.args.name, v1.GetOptions{})
got, err := sc.StorageClient.SBOMSyftFiltereds("kubescape").Get(context.Background(), tt.args.name, v1.GetOptions{})
assert.NoError(t, err)
assert.Equal(t, 1, len(got.Spec.SPDX.Files))
assert.Equal(t, 1, len(got.Spec.Syft.Files))
})
}
}
8 changes: 4 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ type WatchedContainerData struct {
InstanceID instanceidhandler.IInstanceID
UpdateDataTicker *time.Ticker
SyncChannel chan error
FilteredSpdxData *v1beta1.SBOMSPDXv2p3Filtered
FilteredSpdxData *v1beta1.SBOMSyftFiltered
RelevantRealtimeFilesBySPDXIdentifier map[v1beta1.ElementID]bool
RelevantRealtimeFilesByPackageSourceInfo map[string]*PackageSourceInfoData
K8sContainerID string
ContainerID string
RelevantSyftFilesByIdentifier map[string]bool
ParentResourceVersion string
ContainerID string
ImageTag string
ImageID string
Wlid string
TemplateHash string
K8sContainerID string
SBOMResourceVersion int
ContainerType ContainerType
ContainerIndex int
NsMntId uint64
InitialDelayExpired bool
RelevantSyftFilesByIdentifier map[string]bool
}

func Between(value string, a string, b string) string {
Expand Down

0 comments on commit bcd9396

Please sign in to comment.