From 66976080ae049e782b2fdcf34265b2f712be75e0 Mon Sep 17 00:00:00 2001 From: Tomas Touceda Date: Tue, 1 Feb 2022 14:41:48 -0300 Subject: [PATCH] Just log the error if vulnerabilities fail (#3963) * Just log the error if vulnerabilities fail * Add explicit return for more secure future iterations --- cmd/fleet/serve.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cmd/fleet/serve.go b/cmd/fleet/serve.go index a9dda3f0dc..2de4e65255 100644 --- a/cmd/fleet/serve.go +++ b/cmd/fleet/serve.go @@ -706,19 +706,7 @@ func cronVulnerabilities( } if !vulnDisabled { - err := vulnerabilities.TranslateSoftwareToCPE(ctx, ds, vulnPath, logger, config) - if err != nil { - level.Error(logger).Log("msg", "analyzing vulnerable software: Software->CPE", "err", err) - sentry.CaptureException(err) - continue - } - - err = vulnerabilities.TranslateCPEToCVE(ctx, ds, vulnPath, logger, config) - if err != nil { - level.Error(logger).Log("msg", "analyzing vulnerable software: CPE->CVE", "err", err) - sentry.CaptureException(err) - continue - } + checkVulnerabilities(ctx, ds, logger, vulnPath, config) } if err := ds.CalculateHostsPerSoftware(ctx, time.Now()); err != nil { @@ -731,6 +719,22 @@ func cronVulnerabilities( } } +func checkVulnerabilities(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, vulnPath string, config config.FleetConfig) { + err := vulnerabilities.TranslateSoftwareToCPE(ctx, ds, vulnPath, logger, config) + if err != nil { + level.Error(logger).Log("msg", "analyzing vulnerable software: Software->CPE", "err", err) + sentry.CaptureException(err) + return + } + + err = vulnerabilities.TranslateCPEToCVE(ctx, ds, vulnPath, logger, config) + if err != nil { + level.Error(logger).Log("msg", "analyzing vulnerable software: CPE->CVE", "err", err) + sentry.CaptureException(err) + return + } +} + func cronWebhooks(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, identifier string, failingPoliciesSet fleet.FailingPolicySet) { appConfig, err := ds.AppConfig(ctx) if err != nil {