From ead7d15f3828424c82208fef9d2d1a904539e4e7 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 30 Jun 2025 12:15:49 +0200 Subject: [PATCH] Fix SOA risk Signed-off-by: Bryan Frimin --- pkg/probo/framework_service.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/probo/framework_service.go b/pkg/probo/framework_service.go index b0d1a1130..86afe36e5 100644 --- a/pkg/probo/framework_service.go +++ b/pkg/probo/framework_service.go @@ -658,7 +658,7 @@ func (s FrameworkService) buildSOARowData(ctx context.Context, conn pg.Conn, con return soaRowData{}, fmt.Errorf("cannot load policies: %w", err) } - hasEvidence := false + hasRisks := false for _, measure := range measures { if measure == nil { continue @@ -679,10 +679,22 @@ func (s FrameworkService) buildSOARowData(ctx context.Context, conn pg.Conn, con continue } - if len(evidences) > 0 { - hasEvidence = true - break + risks := coredata.Risks{} + risksCursor := page.NewCursor( + maxItemsLimit, + nil, + page.Head, + page.OrderBy[coredata.RiskOrderField]{ + Field: coredata.RiskOrderFieldCreatedAt, + Direction: page.OrderDirectionAsc, + }, + ) + + if err := risks.LoadByMeasureID(ctx, conn, s.svc.scope, measure.ID, risksCursor, coredata.NewRiskFilter(nil)); err != nil { + continue } + + hasRisks = len(risks) > 0 } rowData := soaRowData{ @@ -695,7 +707,7 @@ func (s FrameworkService) buildSOARowData(ctx context.Context, conn pg.Conn, con rowData.regulatory = "YES" rowData.bestPractice = "YES" - if hasEvidence { + if hasRisks { rowData.riskAssessment = "YES" }