@@ -77,7 +77,7 @@ func (e *Evaluator) evaluateQuery(ctx context.Context, q models.QueryConfig) mod
7777 }
7878 }
7979
80- const evidenceLimit = 50
80+ const evidenceLimit = 10
8181 rawRows := res .Rows
8282 if len (rawRows ) > evidenceLimit {
8383 rawRows = rawRows [:evidenceLimit ]
@@ -140,26 +140,72 @@ func evaluateQueryRule(q models.QueryConfig, hits int) (models.QueryEvaluationSt
140140
141141func computeControlStatus (strategy models.ComplianceStrategy , results []models.QueryEvaluation ) models.ControlEvaluationStatus {
142142
143- switch strategy {
144- case models .StrategyAll :
145- for _ , r := range results {
146- if r .Status != models .QueryStatusCompliant {
147- return models .ControlStatusNonCompliant
148- }
143+ hasCompliant := false
144+ hasNonCompliant := false
145+ hasError := false
146+ allNotApplicable := true
147+
148+ applicableCount := 0
149+ errorCount := 0
150+
151+ for _ , r := range results {
152+ switch r .Status {
153+ case models .QueryStatusCompliant :
154+ hasCompliant = true
155+ allNotApplicable = false
156+ applicableCount ++
157+
158+ case models .QueryStatusNonCompliant :
159+ hasNonCompliant = true
160+ allNotApplicable = false
161+ applicableCount ++
162+
163+ case models .QueryStatusError :
164+ hasError = true
165+ allNotApplicable = false
166+ applicableCount ++
167+ errorCount ++
168+
169+ case models .QueryStatusNotApplicable :
149170 }
150- return models .ControlStatusCompliant
171+ }
172+
173+ if allNotApplicable {
174+ return models .ControlStatusNotApplicable
175+ }
151176
177+ if applicableCount > 0 && errorCount == applicableCount {
178+ return models .ControlStatusNotEvaluated
179+ }
180+
181+ switch strategy {
152182 case models .StrategyAny :
153- for _ , r := range results {
154- if r .Status == models .QueryStatusCompliant {
155- return models .ControlStatusCompliant
156- }
183+ if hasCompliant {
184+ return models .ControlStatusCompliant
185+ }
186+
187+ if hasError {
188+ return models .ControlStatusNonCompliant
157189 }
158- return models .ControlStatusNonCompliant
159190
160- default :
161191 return models .ControlStatusNonCompliant
192+
193+ case models .StrategyAll :
194+
195+ if hasNonCompliant {
196+ return models .ControlStatusNonCompliant
197+ }
198+
199+ if hasError {
200+ return models .ControlStatusNonCompliant
201+ }
202+
203+ if hasCompliant {
204+ return models .ControlStatusCompliant
205+ }
162206 }
207+
208+ return models .ControlStatusNonCompliant
163209}
164210
165211func patternExists (pattern int , active []models.IndexPattern ) bool {
0 commit comments