Skip to content

Commit 5a4bd0f

Browse files
authored
chore: ensure each test result gets a SARIF run (#481)
1 parent f8222b8 commit 5a4bd0f

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

internal/presenters/funcs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,13 @@ func getFindingTypesFromTestResult(testResults testapi.TestResult) []testapi.Fin
401401
}
402402
findingTypes[findings.Attributes.FindingType] = true
403403
}
404-
return slices.Collect(maps.Keys(findingTypes))
404+
405+
findingTypesList := slices.Collect(maps.Keys(findingTypes))
406+
if len(findingTypesList) == 0 {
407+
return []testapi.FindingType{"no findings type found"}
408+
}
409+
410+
return findingTypesList
405411
}
406412

407413
// getManifestPathFromTestResult extracts the manifest file path from test result

internal/presenters/presenter_ufm_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,19 +456,12 @@ func normalizeSarifForComparison(t *testing.T, sarifJSON string) map[string]inte
456456
return sarif
457457
}
458458

459-
// TODO: preserve SARIF runs even if there are no findings
460-
filteredRuns := make([]interface{}, 0)
461459
for _, runInterface := range runs {
462460
run, ok := runInterface.(map[string]interface{})
463461
if !ok {
464462
continue
465463
}
466464

467-
results, ok := run["results"].([]interface{})
468-
if !ok || len(results) == 0 {
469-
continue
470-
}
471-
472465
// Normalize automation ID (missing project name in actual output)
473466
normalizeAutomationID(run)
474467

@@ -483,11 +476,8 @@ func normalizeSarifForComparison(t *testing.T, sarifJSON string) map[string]inte
483476

484477
// Normalize suppressions (not included in original SARIF)
485478
normalizeSuppressions(run)
486-
487-
filteredRuns = append(filteredRuns, run)
488479
}
489480

490-
sarif["runs"] = filteredRuns
491481
return sarif
492482
}
493483

0 commit comments

Comments
 (0)