Just log the error if vulnerabilities fail (#3963)

* Just log the error if vulnerabilities fail

* Add explicit return for more secure future iterations
This commit is contained in:
Tomas Touceda 2022-02-01 14:41:48 -03:00 committed by GitHub
parent ab8cb8ceb5
commit 66976080ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {