diff --git a/go.mod b/go.mod index 24a7418f..57e5b062 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/kubescape/backend v0.0.16 github.com/kubescape/go-logger v0.0.22 github.com/kubescape/k8s-interface v0.0.162 - github.com/kubescape/storage v0.0.67 + github.com/kubescape/storage v0.0.70-0.20240326141707-6bd88c6857f3 github.com/panjf2000/ants/v2 v2.9.0 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 @@ -41,11 +41,11 @@ require ( github.com/acobaugh/osrelease v0.1.0 // indirect github.com/adrg/xdg v0.4.0 // indirect github.com/anchore/clio v0.0.0-20231016125544-c98a83e1c7fc // indirect - github.com/anchore/fangs v0.0.0-20231103141714-84c94dc43a2e // indirect + github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b // indirect github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a // indirect github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501 // indirect - github.com/anchore/stereoscope v0.0.0-20231117203853-3610f4ef3e83 // indirect - github.com/anchore/syft v0.98.0 // indirect + github.com/anchore/stereoscope v0.0.0-20240118133533-eb656fc71793 // indirect + github.com/anchore/syft v0.101.1 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/armosec/armoapi-go v0.0.329 // indirect github.com/armosec/gojay v1.2.15 // indirect @@ -96,7 +96,7 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-containerregistry v0.16.1 // indirect + github.com/google/go-containerregistry v0.18.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect @@ -195,7 +195,7 @@ require ( golang.org/x/crypto v0.19.0 // indirect golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.20.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/term v0.17.0 // indirect diff --git a/go.sum b/go.sum index e8f3e162..4b03fc00 100644 --- a/go.sum +++ b/go.sum @@ -78,18 +78,18 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/anchore/clio v0.0.0-20231016125544-c98a83e1c7fc h1:A1KFO+zZZmbNlz1+WKsCF0RKVx6XRoxsAG3lrqH9hUQ= github.com/anchore/clio v0.0.0-20231016125544-c98a83e1c7fc/go.mod h1:QeWvNzxsrUNxcs6haQo3OtISfXUXW0qAuiG4EQiz0GU= -github.com/anchore/fangs v0.0.0-20231103141714-84c94dc43a2e h1:O8ZubApaSl7dRzKNvyfGq9cLIPLQ5v3Iz0Y3huHKCgg= -github.com/anchore/fangs v0.0.0-20231103141714-84c94dc43a2e/go.mod h1:yPsN3NUGhU5dcBtYBa1dMNzGu1yT5ZAfSjKq9DY4aV8= +github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b h1:L/djgY7ZbZ/38+wUtdkk398W3PIBJLkt1N8nU/7e47A= +github.com/anchore/fangs v0.0.0-20231201140849-5075d28d6d8b/go.mod h1:TLcE0RE5+8oIx2/NPWem/dq1DeaMoC+fPEH7hoSzPLo= github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a h1:nJ2G8zWKASyVClGVgG7sfM5mwoZlZ2zYpIzN2OhjWkw= github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a/go.mod h1:ubLFmlsv8/DFUQrZwY5syT5/8Er3ugSr4rDFwHsE3hg= github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04 h1:VzprUTpc0vW0nnNKJfJieyH/TZ9UYAnTZs5/gHTdAe8= github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04/go.mod h1:6dK64g27Qi1qGQZ67gFmBFvEHScy0/C8qhQhNe5B5pQ= github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501 h1:AV7qjwMcM4r8wFhJq3jLRztew3ywIyPTRapl2T1s9o8= github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501/go.mod h1:Blo6OgJNiYF41ufcgHKkbCKF2MDOMlrqhXv/ij6ocR4= -github.com/anchore/stereoscope v0.0.0-20231117203853-3610f4ef3e83 h1:mxGIOmj+asEm8LUkPTG3/v0hi27WIlDVjiEVsUB9eqY= -github.com/anchore/stereoscope v0.0.0-20231117203853-3610f4ef3e83/go.mod h1:GKAnytSVV1hoqB5r5Gd9M5Ph3Rzqq0zPdEJesewjC2w= -github.com/anchore/syft v0.98.0 h1:mPDah48zZCFeSiGweqPd2C2++rOUh3/cAZylEy1VPwU= -github.com/anchore/syft v0.98.0/go.mod h1:FMj8zZFF3mP4IAuTxb6n14CZ6ouWXpI9RZqXpnkLK+Y= +github.com/anchore/stereoscope v0.0.0-20240118133533-eb656fc71793 h1:wji+qdjsV7ooolBwb3faVZnEK3WtY/kcT5473kxVZS4= +github.com/anchore/stereoscope v0.0.0-20240118133533-eb656fc71793/go.mod h1:IylG7ofLoUKHwS1XDF6rPhOmaE3GgpAgsMdvvYfooTU= +github.com/anchore/syft v0.101.1 h1:PTh7XBdtXq3BYhuPz67rrC6AFPZxC1Rt8jgqv7Z75rA= +github.com/anchore/syft v0.101.1/go.mod h1:6rbrRWQN16TFENxXG1uFQOh9RCIp/UHJqPAJnHSKhjQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= @@ -347,8 +347,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-containerregistry v0.16.1 h1:rUEt426sR6nyrL3gt+18ibRcvYpKYdpsa5ZW7MA08dQ= -github.com/google/go-containerregistry v0.16.1/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ= +github.com/google/go-containerregistry v0.18.0 h1:ShE7erKNPqRh5ue6Z9DUOlk04WsnFWPO6YGr3OxnfoQ= +github.com/google/go-containerregistry v0.18.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -493,8 +493,8 @@ github.com/kubescape/go-logger v0.0.22 h1:gle7wH6emOiGv9ljdpVi82pWLQ3jGucrUucvil github.com/kubescape/go-logger v0.0.22/go.mod h1:x3HBpZo3cMT/WIdy18BxvVVd5D0e/PWFVk/HiwBNu3g= github.com/kubescape/k8s-interface v0.0.162 h1:tIXwuB7073GJV3OPgGMS4kXBh7N709NscVYiePMCvU4= github.com/kubescape/k8s-interface v0.0.162/go.mod h1:oF+Yxug3Kpfu9Yr2j63wy7gwswrKXpiqI0mLk/7gF/s= -github.com/kubescape/storage v0.0.67 h1:j/EaREEf37V1Ga+x75O93xOo26RZ4/32xI6znOK+8Dw= -github.com/kubescape/storage v0.0.67/go.mod h1:U27QNwTwRrOoFRQL7Whz6WC5rxonytuwHg4G/wEvH/A= +github.com/kubescape/storage v0.0.70-0.20240326141707-6bd88c6857f3 h1:GJWpIuUdMYE+XD9uHLxDin4BcUleEqw5aaz4wYiOB9U= +github.com/kubescape/storage v0.0.70-0.20240326141707-6bd88c6857f3/go.mod h1:ttwWSuxDyckuB014uPHBs23zSdFZx6TMD0MZHlwuw+0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= @@ -939,8 +939,8 @@ golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= diff --git a/pkg/applicationprofilemanager/v1/applicationprofile_manager.go b/pkg/applicationprofilemanager/v1/applicationprofile_manager.go index 00ad3ef5..e733a09c 100644 --- a/pkg/applicationprofilemanager/v1/applicationprofile_manager.go +++ b/pkg/applicationprofilemanager/v1/applicationprofile_manager.go @@ -439,24 +439,6 @@ func (am *ApplicationProfileManager) saveProfile(ctx context.Context, watchedCon helpers.Int("container index", watchedContainer.ContainerIndex), helpers.String("container ID", watchedContainer.ContainerID), helpers.String("k8s workload", watchedContainer.K8sContainerID)) - // profile summary - summary := &v1beta1.ApplicationProfileSummary{ - ObjectMeta: metav1.ObjectMeta{ - Name: slug, - Annotations: map[string]string{ - helpersv1.WlidMetadataKey: watchedContainer.Wlid, - helpersv1.StatusMetadataKey: helpersv1.Ready, - }, - Labels: utils.GetLabels(watchedContainer, true), - }, - } - if err := am.storageClient.CreateApplicationProfileSummary(summary, namespace); err != nil { - logger.L().Ctx(ctx).Error("ApplicationProfileManager - failed to save application profile summary", helpers.Error(err), - helpers.String("slug", slug), - helpers.Int("container index", watchedContainer.ContainerIndex), - helpers.String("container ID", watchedContainer.ContainerID), - helpers.String("k8s workload", watchedContainer.K8sContainerID)) - } } } } diff --git a/pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go b/pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go index 2296ec49..a15f34f9 100644 --- a/pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go +++ b/pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go @@ -75,7 +75,6 @@ func TestApplicationProfileManager(t *testing.T) { sort.Strings(storageClient.ApplicationActivities[0].Spec.Syscalls) assert.Equal(t, []string{"dup", "listen"}, storageClient.ApplicationActivities[0].Spec.Syscalls) assert.Equal(t, 2, len(storageClient.ApplicationProfiles)) - assert.Equal(t, 2, len(storageClient.ApplicationProfileSummaries)) // check the first profile sort.Strings(storageClient.ApplicationProfiles[0].Spec.Containers[0].Capabilities) assert.Equal(t, []string{"NET_BIND_SERVICE"}, storageClient.ApplicationProfiles[0].Spec.Containers[1].Capabilities) diff --git a/pkg/storage/storage_interface.go b/pkg/storage/storage_interface.go index 9f3561bb..10c19b50 100644 --- a/pkg/storage/storage_interface.go +++ b/pkg/storage/storage_interface.go @@ -10,7 +10,6 @@ type StorageClient interface { CreateApplicationProfile(profile *v1beta1.ApplicationProfile, namespace string) error PatchApplicationProfile(name, namespace string, patch []byte, channel chan error) error GetApplicationProfile(namespace, name string) (*v1beta1.ApplicationProfile, error) - CreateApplicationProfileSummary(profile *v1beta1.ApplicationProfileSummary, namespace string) error CreateFilteredSBOM(SBOM *v1beta1.SBOMSyftFiltered) error GetFilteredSBOM(name string) (*v1beta1.SBOMSyftFiltered, error) GetSBOM(name string) (*v1beta1.SBOMSyft, error) diff --git a/pkg/storage/storage_mock.go b/pkg/storage/storage_mock.go index 09fe83eb..5883d067 100644 --- a/pkg/storage/storage_mock.go +++ b/pkg/storage/storage_mock.go @@ -21,15 +21,14 @@ const ( ) type StorageHttpClientMock struct { - ApplicationActivities []*spdxv1beta1.ApplicationActivity - ApplicationProfiles []*spdxv1beta1.ApplicationProfile - ApplicationProfileSummaries []*spdxv1beta1.ApplicationProfileSummary - FilteredSyftSBOMs []*spdxv1beta1.SBOMSyftFiltered - NetworkNeighborses []*v1beta1.NetworkNeighbors - ImageCounters map[string]int - nginxSBOMSpdxBytes *spdxv1beta1.SBOMSPDXv2p3 - mockSBOM *v1beta1.SBOMSyft - failedOnce bool + ApplicationActivities []*spdxv1beta1.ApplicationActivity + ApplicationProfiles []*spdxv1beta1.ApplicationProfile + FilteredSyftSBOMs []*spdxv1beta1.SBOMSyftFiltered + NetworkNeighborses []*v1beta1.NetworkNeighbors + ImageCounters map[string]int + nginxSBOMSpdxBytes *spdxv1beta1.SBOMSPDXv2p3 + mockSBOM *v1beta1.SBOMSyft + failedOnce bool } func (sc *StorageHttpClientMock) GetApplicationActivity(_, _ string) (*spdxv1beta1.ApplicationActivity, error) { @@ -120,11 +119,6 @@ func (sc *StorageHttpClientMock) PatchApplicationProfile(name, _ string, patchJS return nil } -func (sc *StorageHttpClientMock) CreateApplicationProfileSummary(summary *spdxv1beta1.ApplicationProfileSummary, _ string) error { - sc.ApplicationProfileSummaries = append(sc.ApplicationProfileSummaries, summary) - return nil -} - func (sc *StorageHttpClientMock) CreateNetworkNeighbors(networkNeighbors *v1beta1.NetworkNeighbors, _ string) error { sc.NetworkNeighborses = append(sc.NetworkNeighborses, networkNeighbors) return nil diff --git a/pkg/storage/v1/storage_nocache.go b/pkg/storage/v1/storage_nocache.go index ede64d47..d94f733b 100644 --- a/pkg/storage/v1/storage_nocache.go +++ b/pkg/storage/v1/storage_nocache.go @@ -172,14 +172,6 @@ func (sc StorageNoCache) GetApplicationProfile(namespace, name string) (*v1beta1 return sc.StorageClient.ApplicationProfiles(namespace).Get(context.Background(), name, metav1.GetOptions{}) } -func (sc StorageNoCache) CreateApplicationProfileSummary(profile *v1beta1.ApplicationProfileSummary, namespace string) error { - _, err := sc.StorageClient.ApplicationProfileSummaries(namespace).Create(context.Background(), profile, metav1.CreateOptions{}) - if err != nil { - return err - } - return nil -} - func (sc StorageNoCache) CreateFilteredSBOM(SBOM *v1beta1.SBOMSyftFiltered) error { _, err := sc.StorageClient.SBOMSyftFiltereds(sc.namespace).Create(context.Background(), SBOM, metav1.CreateOptions{}) if err != nil {