diff --git a/tests/utils/test_utils.go b/tests/utils/test_utils.go index f42c23e3..80f6213c 100644 --- a/tests/utils/test_utils.go +++ b/tests/utils/test_utils.go @@ -275,6 +275,15 @@ func convertScaSimpleJsonPathsForOS(potentialComponents *[]formats.ComponentRow, } } } + printCve(potentialCves) +} + +func printCve(potentialCves *[]formats.CveRow) { + for _, cve := range *potentialCves { + cveId := cve.Id + applicability := cve.Applicability + log.Output(fmt.Sprintf("Cve: %v, Applicability: %v", cveId, applicability)) + } } func ReadSarifResults(t *testing.T, path string) *sarif.Report { diff --git a/utils/validations/test_validate_sarif.go b/utils/validations/test_validate_sarif.go index 62d53dd6..7d282bf5 100644 --- a/utils/validations/test_validate_sarif.go +++ b/utils/validations/test_validate_sarif.go @@ -158,13 +158,21 @@ func validateSarifRun(t *testing.T, exactMatch bool, expected, actual *sarif.Run // validate results for _, expectedResult := range expected.Results { result := getResultByResultId(expectedResult, actual.Results) - if !assert.NotNil(t, result, fmt.Sprintf("Run tool %s: Expected result with rule ID %s not found in %v", expected.Tool.Driver.Name, sarifutils.GetResultRuleId(expectedResult), actual.Results)) { + if !assert.NotNil(t, result, fmt.Sprintf("Run tool %s: Expected result with rule ID %s not found in %v", expected.Tool.Driver.Name, sarifutils.GetResultRuleId(expectedResult), getResultsRuleIds(actual.Results))) { continue } validateSarifResult(t, exactMatch, expected.Tool.Driver.Name, expectedResult, result) } } +func getResultsRuleIds(results []*sarif.Result) []string { + var ruleIds []string + for _, result := range results { + ruleIds = append(ruleIds, sarifutils.GetResultRuleId(result)) + } + return ruleIds +} + func validateSarifRule(t *testing.T, exactMatch bool, toolName string, expected, actual *sarif.ReportingDescriptor) { ValidateContent(t, exactMatch, StringValidation{Expected: sarifutils.GetRuleFullDescription(expected), Actual: sarifutils.GetRuleFullDescription(actual), Msg: fmt.Sprintf("Run tool %s: Rule full description mismatch for rule %s", toolName, expected.ID)},