Skip to content

Commit

Permalink
internal/appsec/config.go: fix negative condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio-Guerra committed Jan 18, 2022
1 parent f8c29fd commit 9277d2a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/appsec/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 9277d2a

Please sign in to comment.