Skip to content

Commit

Permalink
fixing segfault when using a rule with only a path (#791)
Browse files Browse the repository at this point in the history
* fixing segfault when using a rule with only a path

* DRYing
  • Loading branch information
zricethezav committed Feb 22, 2022
1 parent db1b54b commit b91799a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions report/sarif.go
Expand Up @@ -54,12 +54,22 @@ func getRules(cfg config.Config) []Rules {
// TODO for _, rule := range cfg.Rules {
var rules []Rules
for _, rule := range cfg.Rules {
rules = append(rules, Rules{
ID: rule.RuleID,
Name: rule.Description,
Description: ShortDescription{
shortDescription := ShortDescription{
Text: rule.Description,
}
if rule.Regex != nil {
shortDescription = ShortDescription{
Text: rule.Regex.String(),
},
}
} else if rule.Path != nil {
shortDescription = ShortDescription{
Text: rule.Path.String(),
}
}
rules = append(rules, Rules{
ID: rule.RuleID,
Name: rule.Description,
Description: shortDescription,
})
}
return rules
Expand Down

0 comments on commit b91799a

Please sign in to comment.