Skip to content

Commit

Permalink
Merge pull request #2 from aquasecurity/liamg-default-severity
Browse files Browse the repository at this point in the history
Handle default severity inside the result set
  • Loading branch information
liamg authored Aug 23, 2021
2 parents fcde756 + bc326b5 commit 608a2f4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions result/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package result

import (
"github.com/aquasecurity/defsec/provider"
"github.com/aquasecurity/defsec/severity"
)

type Set interface {
Expand All @@ -14,6 +15,7 @@ type Set interface {
WithImpact(impact string) Set
WithResolution(resolution string) Set
WithLinks(links []string) Set
WithSeverity(severity.Severity) Set
All() []*Result
}

Expand All @@ -30,6 +32,7 @@ type resultSet struct {
impact string
resolution string
links []string
severity severity.Severity
}

func (s *resultSet) Add(r *Result) {
Expand All @@ -42,9 +45,18 @@ func (s *resultSet) Add(r *Result) {
WithRuleProvider(s.ruleProvider).
WithLinks(s.links)

if r.Severity == severity.None {
r.WithSeverity(s.severity)
}

s.results = append(s.results, r)
}

func (s *resultSet) WithSeverity(severity severity.Severity) Set {
s.severity = severity
return s
}

func (s *resultSet) AddResult() *Result {
result := New().
WithRuleID(s.ruleID).
Expand Down

0 comments on commit 608a2f4

Please sign in to comment.