From 73e53b948dc14f0da001aad5156a636c8b029986 Mon Sep 17 00:00:00 2001 From: Nathan Martins Date: Wed, 19 Jan 2022 12:56:51 -0300 Subject: [PATCH] formatters/tfsec:bugfix - vulnerabilities were being ignored due missing 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 --- 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) }