From 18e8b89baf35b67d521470ea8128e24d96f299cc Mon Sep 17 00:00:00 2001 From: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com> Date: Thu, 20 Jan 2022 13:22:08 -0300 Subject: [PATCH] formatters/tfsec:bugfix - vulnerabilities were being ignored due missing severity (#934) 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 --- internal/services/formatters/hcl/tfsec/result.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/services/formatters/hcl/tfsec/result.go b/internal/services/formatters/hcl/tfsec/result.go index f284a9c04..9aebb3855 100644 --- a/internal/services/formatters/hcl/tfsec/result.go +++ b/internal/services/formatters/hcl/tfsec/result.go @@ -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) }