diff --git a/core/pkg/opaprocessor/cosign_has_signature_test.go b/core/pkg/opaprocessor/cosign_has_signature_test.go index f14f9799..317bd12b 100644 --- a/core/pkg/opaprocessor/cosign_has_signature_test.go +++ b/core/pkg/opaprocessor/cosign_has_signature_test.go @@ -7,15 +7,15 @@ import ( ) func Test_has_signature(t *testing.T) { - + tests := []struct { name string - img string + img string want bool }{ { name: "valid signature", - img: "quay.io/kubescape/gateway", + img: "quay.io/kubescape/gateway", want: true, }, } diff --git a/core/pkg/opaprocessor/cosign_verify.go b/core/pkg/opaprocessor/cosign_verify.go index 924265c6..4b3d4b52 100644 --- a/core/pkg/opaprocessor/cosign_verify.go +++ b/core/pkg/opaprocessor/cosign_verify.go @@ -15,7 +15,6 @@ import ( ) // VerifyCommand verifies a signature on a supplied container image -// nolint type VerifyCommand struct { options.RegistryOptions Annotations sigs.AnnotationsMap diff --git a/core/pkg/opaprocessor/processorhandler.go b/core/pkg/opaprocessor/processorhandler.go index b63ce24f..f835d0e2 100644 --- a/core/pkg/opaprocessor/processorhandler.go +++ b/core/pkg/opaprocessor/processorhandler.go @@ -74,6 +74,9 @@ func (opap *OPAProcessor) Process(ctx context.Context, policies *cautils.Policie ctx, span := otel.Tracer("").Start(ctx, "OPAProcessor.Process") defer span.End() opap.loggerStartScanning() + defer opap.loggerDoneScanning() + cautils.StartSpinner() + defer cautils.StopSpinner() if progressListener != nil { progressListener.Start(len(policies.Controls)) @@ -109,8 +112,6 @@ func (opap *OPAProcessor) Process(ctx context.Context, policies *cautils.Policie opap.Report.ReportGenerationTime = time.Now().UTC() - opap.loggerDoneScanning() - return nil } diff --git a/core/pkg/opaprocessor/processorhandlerutils.go b/core/pkg/opaprocessor/processorhandlerutils.go index 5d3bacef..8b3126eb 100644 --- a/core/pkg/opaprocessor/processorhandlerutils.go +++ b/core/pkg/opaprocessor/processorhandlerutils.go @@ -7,9 +7,11 @@ import ( "github.com/kubescape/k8s-interface/k8sinterface" "github.com/kubescape/k8s-interface/workloadinterface" "github.com/kubescape/kubescape/v2/core/cautils" + "github.com/kubescape/opa-utils/exceptions" "github.com/kubescape/opa-utils/reporthandling" "github.com/kubescape/opa-utils/reporthandling/apis" "github.com/kubescape/opa-utils/reporthandling/results/v1/reportsummary" + "github.com/kubescape/opa-utils/reporthandling/results/v1/resourcesresults" resources "github.com/kubescape/opa-utils/resources" "go.opentelemetry.io/otel" ) @@ -23,19 +25,27 @@ import ( func (opap *OPAProcessor) updateResults(ctx context.Context) { ctx, span := otel.Tracer("").Start(ctx, "OPAProcessor.updateResults") defer span.End() + // remove data from all objects for i := range opap.AllResources { removeData(opap.AllResources[i]) } + processor := exceptions.NewProcessor() + // set exceptions for i := range opap.ResourcesResult { - t := opap.ResourcesResult[i] - // first set exceptions + // first set exceptions (reuse the same exceptions processor) if resource, ok := opap.AllResources[i]; ok { - t.SetExceptions(resource, opap.Exceptions, cautils.ClusterName, opap.AllPolicies.Controls) + t.SetExceptions( + resource, + opap.Exceptions, + cautils.ClusterName, + opap.AllPolicies.Controls, // update status depending on action required + resourcesresults.WithExceptionsProcessor(processor), + ) } // summarize the resources