From 9277d2a811d425c2741fe587c246149618ca0abf Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Tue, 18 Jan 2022 10:57:56 +0100 Subject: [PATCH] internal/appsec/config.go: fix negative condition --- internal/appsec/config.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/appsec/config.go b/internal/appsec/config.go index 25febc01ef..25a1929f22 100644 --- a/internal/appsec/config.go +++ b/internal/appsec/config.go @@ -66,11 +66,12 @@ func newConfig() (*config, error) { cfg.wafTimeout = defaultWAFTimeout if wafTimeout := os.Getenv(wafTimeoutEnvVar); wafTimeout != "" { - timeout, err := time.ParseDuration(wafTimeout) - if err == nil { - cfg.wafTimeout = timeout - } else if timeout <= 0 { - log.Error("appsec: unexpected configuration value of %s=%s: expecting a strictly positive duration. Using default value %s.", wafTimeoutEnvVar, wafTimeout, cfg.wafTimeout) + if timeout, err := time.ParseDuration(wafTimeout); err == nil { + if timeout <= 0 { + log.Error("appsec: unexpected configuration value of %s=%s: expecting a strictly positive duration. Using default value %s.", wafTimeoutEnvVar, wafTimeout, cfg.wafTimeout) + } else { + cfg.wafTimeout = timeout + } } else { log.Error("appsec: could not parse the value of %s %s as a duration: %v. Using default value %s.", wafTimeoutEnvVar, wafTimeout, err, cfg.wafTimeout) }