Skip to content

Commit

Permalink
formatters/tfsec:bugfix - vulnerabilities were being ignored due miss…
Browse files Browse the repository at this point in the history
…ing severity

Tfsec func resposable por getting the severeties of the vulnerabilities
was in a wrong format, leading to vulnerablities without severity and
this vulnerabilities were being ignored. This pull request fixes this
error by updating the func to match the correct tfsec severities
https://github.com/aquasecurity/tfsec/blob/master/pkg/severity/severity.go.

Signed-off-by: Nathan Martins <nathan.martins@zup.com.br>
  • Loading branch information
nathanmartinszup committed Jan 19, 2022
1 parent bfb07e6 commit 73e53b9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/services/formatters/hcl/tfsec/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ func (r *tfsecResult) getFilename() string {
return r.Location.Filename
}

// getSeverity this func will get the TfSec severity and parse to the Horusec severity. TfSec can return the following
// severities: CRITICAL, HIGH, MEDIUM, LOW and NONE which is represented by an empty string.
func (r *tfsecResult) getSeverity() severities.Severity {
return r.mapSeverityValues()[r.Severity]
}

func (r *tfsecResult) mapSeverityValues() map[string]severities.Severity {
return map[string]severities.Severity{
"ERROR": severities.High,
"WARNING": severities.Medium,
"": severities.Low,
if r.Severity == "" {
return severities.Unknown
}

return severities.Severity(r.Severity)
}

0 comments on commit 73e53b9

Please sign in to comment.