mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
lint (errorlint) (#2644)
This commit is contained in:
parent
c2c173ac7e
commit
08694adf1b
8 changed files with 27 additions and 33 deletions
|
@ -104,12 +104,12 @@ func CrowdsecCTI(params ...any) (any, error) {
|
|||
ctiResp, err := ctiClient.GetIPInfo(ip)
|
||||
ctiClient.Logger.Debugf("request for %s took %v", ip, time.Since(before))
|
||||
if err != nil {
|
||||
switch err {
|
||||
case cticlient.ErrUnauthorized:
|
||||
switch {
|
||||
case errors.Is(err, cticlient.ErrUnauthorized):
|
||||
CTIApiEnabled = false
|
||||
ctiClient.Logger.Errorf("Invalid API key provided, disabling CTI API")
|
||||
return &cticlient.SmokeItem{}, cticlient.ErrUnauthorized
|
||||
case cticlient.ErrLimit:
|
||||
case errors.Is(err, cticlient.ErrLimit):
|
||||
CTIBackOffUntil = time.Now().Add(CTIBackOffDuration)
|
||||
ctiClient.Logger.Errorf("CTI API is throttled, will try again in %s", CTIBackOffDuration)
|
||||
return &cticlient.SmokeItem{}, cticlient.ErrLimit
|
||||
|
|
|
@ -3,6 +3,7 @@ package exprhelpers
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -108,7 +109,7 @@ func smokeHandler(req *http.Request) *http.Response {
|
|||
|
||||
func TestNillClient(t *testing.T) {
|
||||
defer ShutdownCrowdsecCTI()
|
||||
if err := InitCrowdsecCTI(ptr.Of(""), nil, nil, nil); err != cticlient.ErrDisabled {
|
||||
if err := InitCrowdsecCTI(ptr.Of(""), nil, nil, nil); !errors.Is(err, cticlient.ErrDisabled) {
|
||||
t.Fatalf("failed to init CTI : %s", err)
|
||||
}
|
||||
item, err := CrowdsecCTI("1.2.3.4")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue