Skip to content

Commit

Permalink
try debug
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Oct 1, 2024
1 parent 6c0b4b6 commit a8ae841
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/utils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 9 additions & 1 deletion utils/validations/test_validate_sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down

0 comments on commit a8ae841

Please sign in to comment.