Skip to content

Commit

Permalink
Sarif results with empty rules now represents as [] instead of null/n…
Browse files Browse the repository at this point in the history
…il (#786)
  • Loading branch information
chriswolfdesign committed Feb 19, 2022
1 parent 9261f1c commit d1f642a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion report/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@ func getRuns(cfg config.Config, findings []Finding) []Runs {
}

func getTool(cfg config.Config) Tool {
return Tool{
tool := Tool{
Driver: Driver{
Name: driver,
SemanticVersion: version,
Rules: getRules(cfg),
},
}

// if this tool has no rules, ensure that it is represented as [] instead of null/nil
if hasEmptyRules(tool) {
tool.Driver.Rules = make([]Rules, 0)
}

return tool
}

func hasEmptyRules(tool Tool) bool {
return len(tool.Driver.Rules) == 0
}

func getRules(cfg config.Config) []Rules {
Expand Down

0 comments on commit d1f642a

Please sign in to comment.