diff --git a/internal/controllers/analyzer/analyzer.go b/internal/controllers/analyzer/analyzer.go index 38e4305b3..af0a5acd3 100644 --- a/internal/controllers/analyzer/analyzer.go +++ b/internal/controllers/analyzer/analyzer.go @@ -250,6 +250,7 @@ func (a *Analyzer) setVulnerabilityType( func (a *Analyzer) setAnalysisFinishedData() *analysis.Analysis { a.analysis.FinishedAt = time.Now() + a.removeWarningsFromErrors() if a.analysis.HasErrors() { a.analysis.Status = enumsAnalysis.Error return a.analysis @@ -430,3 +431,26 @@ func (a *Analyzer) getAllConfigHashes() []string { return configHashes } + +// removeWarningsFromErrors workaround to separate warnings from errors until the formatters are refactored +func (a *Analyzer) removeWarningsFromErrors() { + var errors string + + for _, err := range strings.SplitAfter(a.analysis.Errors, ";") { + if a.isWarning(err) { + a.analysis.AddWarning(err) + } else { + errors += err + } + } + + a.analysis.Errors = errors +} + +// isWarning workaround to check if the message it's form a warning until the formatters are refactored +func (a *Analyzer) isWarning(err string) bool { + return strings.Contains(err, messages.MsgErrorPacketJSONNotFound) || + strings.Contains(err, messages.MsgErrorYarnLockNotFound) || + strings.Contains(err, messages.MsgErrorGemLockNotFound) || + strings.Contains(err, messages.MsgErrorNotFoundRequirementsTxt) +} diff --git a/internal/controllers/printresults/print_results.go b/internal/controllers/printresults/print_results.go index 97d271913..ed0f1426e 100644 --- a/internal/controllers/printresults/print_results.go +++ b/internal/controllers/printresults/print_results.go @@ -376,16 +376,8 @@ func (pr *PrintResults) checkIfExistsErrorsInAnalysis() { } } -func (pr *PrintResults) printErrors(errorMessage string) { - if strings.Contains(errorMessage, messages.MsgErrorPacketJSONNotFound) || - strings.Contains(errorMessage, messages.MsgErrorYarnLockNotFound) || - strings.Contains(errorMessage, messages.MsgErrorGemLockNotFound) || - strings.Contains(errorMessage, messages.MsgErrorNotFoundRequirementsTxt) { - logger.LogWarnWithLevel(strings.ReplaceAll(errorMessage, ";", "")) - return - } - - logger.LogStringAsError(strings.ReplaceAll(errorMessage, ";", "")) +func (pr *PrintResults) printErrors(err string) { + logger.LogStringAsError(strings.ReplaceAll(err, ";", "")) } func (pr *PrintResults) printResponseAnalysis() {