diff --git a/core/core/scan.go b/core/core/scan.go index 1af6a847..46b065ba 100644 --- a/core/core/scan.go +++ b/core/core/scan.go @@ -15,7 +15,6 @@ import ( "github.com/kubescape/kubescape/v2/core/pkg/opaprocessor" "github.com/kubescape/kubescape/v2/core/pkg/policyhandler" "github.com/kubescape/kubescape/v2/core/pkg/resourcehandler" - "github.com/kubescape/kubescape/v2/core/pkg/resourcesprioritization" "github.com/kubescape/kubescape/v2/core/pkg/resultshandling" "github.com/kubescape/kubescape/v2/core/pkg/resultshandling/printer" "github.com/kubescape/kubescape/v2/core/pkg/resultshandling/reporter" @@ -153,11 +152,15 @@ func (ks *Kubescape) Scan(scanInfo *cautils.ScanInfo) (*resultshandling.ResultsH return resultsHandling, fmt.Errorf("%w", err) } - // ======================== prioritization =================== - priotizationHandler := resourcesprioritization.NewResourcesPrioritizationHandler(true) - if err := priotizationHandler.PrioritizeResources(scanData); err != nil { - return resultsHandling, fmt.Errorf("%w", err) - } + /* + + // ======================== prioritization =================== + priotizationHandler := resourcesprioritization.NewResourcesPrioritizationHandler(true) + if err := priotizationHandler.PrioritizeResources(scanData); err != nil { + return resultsHandling, fmt.Errorf("%w", err) + } + + */ // ========================= results handling ===================== resultsHandling.SetData(scanData) diff --git a/core/pkg/resultshandling/printer/v2/utils.go b/core/pkg/resultshandling/printer/v2/utils.go index e14c93e3..4933c09e 100644 --- a/core/pkg/resultshandling/printer/v2/utils.go +++ b/core/pkg/resultshandling/printer/v2/utils.go @@ -38,7 +38,7 @@ func finalizeResults(results []resourcesresults.Result, resourcesResult map[stri // Add prioritization information to the result if v, exist := prioritizedResources[resourceID]; exist { - results[index].PrioritizedResource = v + results[index].PrioritizedResource = &v } index++ } diff --git a/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go b/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go index 8f8da4f5..809825ee 100644 --- a/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go +++ b/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go @@ -139,21 +139,24 @@ func (report *ReportEventReceiver) sendResources(host string, opaSessionObj *cau func (report *ReportEventReceiver) setResults(reportObj *reporthandlingv2.PostureReport, results map[string]resourcesresults.Result, allResources map[string]workloadinterface.IMetadata, resourcesSource map[string]reporthandling.Source, prioritizedResources map[string]prioritization.PrioritizedResource, counter, reportCounter *int, host string) error { for _, v := range results { - // set result.RawResource - resourceID := v.GetResourceID() - if _, ok := allResources[resourceID]; !ok { - return fmt.Errorf("expected to find raw resource object for '%s'", resourceID) - } - resource := reporthandling.NewResourceIMetadata(allResources[resourceID]) - if r, ok := resourcesSource[resourceID]; ok { - resource.SetSource(&r) - } - v.RawResource = *resource + /* - // set result.PrioritizedResource - if _, ok := prioritizedResources[resourceID]; ok { - v.PrioritizedResource = prioritizedResources[resourceID] - } + // set result.RawResource + resourceID := v.GetResourceID() + if _, ok := allResources[resourceID]; !ok { + return fmt.Errorf("expected to find raw resource object for '%s'", resourceID) + } + resource := reporthandling.NewResourceIMetadata(allResources[resourceID]) + if r, ok := resourcesSource[resourceID]; ok { + resource.SetSource(&r) + } + v.RawResource = resource + + // set result.PrioritizedResource + if resource, ok := prioritizedResources[resourceID]; ok { + v.PrioritizedResource = &resource + } + */ r, err := json.Marshal(v) if err != nil { @@ -184,10 +187,14 @@ func (report *ReportEventReceiver) setResults(reportObj *reporthandlingv2.Postur func (report *ReportEventReceiver) setResources(reportObj *reporthandlingv2.PostureReport, allResources map[string]workloadinterface.IMetadata, resourcesSource map[string]reporthandling.Source, results map[string]resourcesresults.Result, counter, reportCounter *int, host string) error { for resourceID, v := range allResources { - // process only resources which have no result because these resources will be sent on the result object - if _, hasResult := results[resourceID]; hasResult { - continue - } + /* + + // process only resources which have no result because these resources will be sent on the result object + if _, hasResult := results[resourceID]; hasResult { + continue + } + + */ resource := reporthandling.NewResourceIMetadata(v) if r, ok := resourcesSource[resourceID]; ok { diff --git a/go.mod b/go.mod index 0d805c75..af064f47 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/johnfercher/maroto v0.37.0 github.com/kubescape/go-logger v0.0.6 github.com/kubescape/k8s-interface v0.0.83 - github.com/kubescape/opa-utils v0.0.181 + github.com/kubescape/opa-utils v0.0.183 github.com/kubescape/rbac-utils v0.0.17 github.com/libgit2/git2go/v33 v33.0.9 github.com/mattn/go-isatty v0.0.14 diff --git a/go.sum b/go.sum index 83f970a4..4308189c 100644 --- a/go.sum +++ b/go.sum @@ -839,8 +839,8 @@ github.com/kubescape/go-logger v0.0.6 h1:ynhAmwrz0O7Jtqq1CdmCZUrKveji25hVP+B/FAb github.com/kubescape/go-logger v0.0.6/go.mod h1:DnVWEvC90LFY1nNMaNo6nBVOcqkLMK3S0qzXP1fzRvI= github.com/kubescape/k8s-interface v0.0.83 h1:yQ1kWNZmKfBim/+NmxpPI/j7L9ASDq2h3mCNdmYgzqY= github.com/kubescape/k8s-interface v0.0.83/go.mod h1:ihX96yqar+xogHl45mFE8zT9DLI06iy7XQPAP+j5KJE= -github.com/kubescape/opa-utils v0.0.181 h1:At3/4+yS7NqIKYXRj4iwdLmrGOR6B6SyYMALme9axAI= -github.com/kubescape/opa-utils v0.0.181/go.mod h1:jC5QrhS6WiFj/tXP2/YSDBnFlGsYUQokDGbKwMBgMpw= +github.com/kubescape/opa-utils v0.0.183 h1:Qiosb2dV6QIIM8vIbjiIRkxYNiHFbDTvcOVfKa8u5mE= +github.com/kubescape/opa-utils v0.0.183/go.mod h1:jC5QrhS6WiFj/tXP2/YSDBnFlGsYUQokDGbKwMBgMpw= github.com/kubescape/rbac-utils v0.0.17 h1:B78kjlTKqjYK/PXwmi4GPysHsFxIwVz1KFb4+IGT29w= github.com/kubescape/rbac-utils v0.0.17/go.mod h1:pBwjpcrVeuH/no+DiCZWvlhYtCDzd3U0o/hEZKi+eM8= github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= diff --git a/httphandler/go.mod b/httphandler/go.mod index 92ab1559..c283493f 100644 --- a/httphandler/go.mod +++ b/httphandler/go.mod @@ -12,7 +12,7 @@ require ( github.com/gorilla/schema v1.2.0 github.com/kubescape/go-logger v0.0.6 github.com/kubescape/kubescape/v2 v2.0.0-00010101000000-000000000000 - github.com/kubescape/opa-utils v0.0.181 + github.com/kubescape/opa-utils v0.0.183 github.com/stretchr/testify v1.8.0 k8s.io/utils v0.0.0-20220706174534-f6158b442e7c ) diff --git a/httphandler/go.sum b/httphandler/go.sum index 4bb05236..49c20842 100644 --- a/httphandler/go.sum +++ b/httphandler/go.sum @@ -895,8 +895,8 @@ github.com/kubescape/go-logger v0.0.6 h1:ynhAmwrz0O7Jtqq1CdmCZUrKveji25hVP+B/FAb github.com/kubescape/go-logger v0.0.6/go.mod h1:DnVWEvC90LFY1nNMaNo6nBVOcqkLMK3S0qzXP1fzRvI= github.com/kubescape/k8s-interface v0.0.83 h1:yQ1kWNZmKfBim/+NmxpPI/j7L9ASDq2h3mCNdmYgzqY= github.com/kubescape/k8s-interface v0.0.83/go.mod h1:ihX96yqar+xogHl45mFE8zT9DLI06iy7XQPAP+j5KJE= -github.com/kubescape/opa-utils v0.0.181 h1:At3/4+yS7NqIKYXRj4iwdLmrGOR6B6SyYMALme9axAI= -github.com/kubescape/opa-utils v0.0.181/go.mod h1:jC5QrhS6WiFj/tXP2/YSDBnFlGsYUQokDGbKwMBgMpw= +github.com/kubescape/opa-utils v0.0.183 h1:Qiosb2dV6QIIM8vIbjiIRkxYNiHFbDTvcOVfKa8u5mE= +github.com/kubescape/opa-utils v0.0.183/go.mod h1:jC5QrhS6WiFj/tXP2/YSDBnFlGsYUQokDGbKwMBgMpw= github.com/kubescape/rbac-utils v0.0.17 h1:B78kjlTKqjYK/PXwmi4GPysHsFxIwVz1KFb4+IGT29w= github.com/kubescape/rbac-utils v0.0.17/go.mod h1:pBwjpcrVeuH/no+DiCZWvlhYtCDzd3U0o/hEZKi+eM8= github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=