mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2026-10-12 02:12:31 +00:00
update golangci-lint v2.2 and config (#3713)
This commit is contained in:
@@ -58,6 +58,6 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v2.1
|
||||
version: v2.2
|
||||
args: --issues-exit-code=1 --timeout 10m
|
||||
only-new-issues: false
|
||||
|
||||
@@ -209,6 +209,6 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v2.1
|
||||
version: v2.2
|
||||
args: --issues-exit-code=1 --timeout 10m
|
||||
only-new-issues: false
|
||||
|
||||
+8
-1
@@ -15,6 +15,7 @@ linters:
|
||||
- gocognit # revive
|
||||
- gocyclo # revive
|
||||
- lll # revive
|
||||
- wsl # wsl_v5
|
||||
|
||||
# Disabled atm
|
||||
|
||||
@@ -36,6 +37,7 @@ linters:
|
||||
- tagalign # check that struct tags are well aligned
|
||||
- thelper # thelper detects tests helpers which is not start with t.Helper() method.
|
||||
- wrapcheck # Checks that errors returned from external packages are wrapped
|
||||
- embeddedstructfieldcheck
|
||||
|
||||
#
|
||||
# Recommended? (requires some work)
|
||||
@@ -53,7 +55,7 @@ linters:
|
||||
|
||||
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
|
||||
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
|
||||
- wsl # add or remove empty lines
|
||||
- wsl_v5 # add or remove empty lines
|
||||
|
||||
#
|
||||
# Well intended, but not ready for this
|
||||
@@ -75,6 +77,7 @@ linters:
|
||||
- tagliatelle # Checks the struct tags.
|
||||
- varnamelen # checks that the length of a variable's name matches its scope
|
||||
- prealloc
|
||||
- noinlineerr
|
||||
|
||||
settings:
|
||||
|
||||
@@ -260,6 +263,8 @@ linters:
|
||||
disabled: true
|
||||
- name: redundant-import-alias
|
||||
disabled: true
|
||||
- name: redundant-test-main-exit
|
||||
disabled: true
|
||||
- name: var-naming
|
||||
disabled: true
|
||||
- name: unchecked-type-assertion
|
||||
@@ -276,6 +281,8 @@ linters:
|
||||
- fmt.Printf
|
||||
- fmt.Println
|
||||
disabled: true
|
||||
- name: unnecessary-format
|
||||
disabled: true
|
||||
- name: unnecessary-stmt
|
||||
disabled: true
|
||||
- name: unused-parameter
|
||||
|
||||
@@ -126,7 +126,7 @@ func (s *HTTPPlugin) Notify(ctx context.Context, notification *protobufs.Notific
|
||||
|
||||
logger.Info(fmt.Sprintf("received signal for %s config", notification.Name))
|
||||
|
||||
request, err := http.NewRequest(cfg.Method, cfg.URL, bytes.NewReader([]byte(notification.Text)))
|
||||
request, err := http.NewRequestWithContext(ctx, cfg.Method, cfg.URL, bytes.NewReader([]byte(notification.Text)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (s *SentinelPlugin) Notify(ctx context.Context, notification *protobufs.Not
|
||||
return &protobufs.Empty{}, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, url, body)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
|
||||
if err != nil {
|
||||
logger.Error("failed to create request", "error", err)
|
||||
return &protobufs.Empty{}, err
|
||||
|
||||
@@ -62,7 +62,7 @@ func (s *Splunk) Notify(ctx context.Context, notification *protobufs.Notificatio
|
||||
return &protobufs.Empty{}, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, cfg.URL, strings.NewReader(string(data)))
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, cfg.URL, strings.NewReader(string(data)))
|
||||
if err != nil {
|
||||
return &protobufs.Empty{}, err
|
||||
}
|
||||
|
||||
@@ -147,6 +147,8 @@ func TestJA4H_B(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJA4H_C(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
cookies func() []*http.Cookie
|
||||
@@ -155,7 +157,7 @@ func TestJA4H_C(t *testing.T) {
|
||||
{
|
||||
name: "no cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
return req.Cookies()
|
||||
},
|
||||
expectedResult: "000000000000",
|
||||
@@ -163,7 +165,7 @@ func TestJA4H_C(t *testing.T) {
|
||||
{
|
||||
name: "one cookie",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
return req.Cookies()
|
||||
},
|
||||
@@ -172,7 +174,7 @@ func TestJA4H_C(t *testing.T) {
|
||||
{
|
||||
name: "duplicate cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar2"})
|
||||
return req.Cookies()
|
||||
@@ -182,7 +184,7 @@ func TestJA4H_C(t *testing.T) {
|
||||
{
|
||||
name: "multiple cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
req.AddCookie(&http.Cookie{Name: "bar", Value: "foo"})
|
||||
cookies := req.Cookies()
|
||||
@@ -206,6 +208,8 @@ func TestJA4H_C(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJA4H_D(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
cookies func() []*http.Cookie
|
||||
@@ -214,7 +218,7 @@ func TestJA4H_D(t *testing.T) {
|
||||
{
|
||||
name: "no cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
return req.Cookies()
|
||||
},
|
||||
expectedResult: "000000000000",
|
||||
@@ -222,7 +226,7 @@ func TestJA4H_D(t *testing.T) {
|
||||
{
|
||||
name: "one cookie",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
return req.Cookies()
|
||||
},
|
||||
@@ -231,7 +235,7 @@ func TestJA4H_D(t *testing.T) {
|
||||
{
|
||||
name: "duplicate cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar2"})
|
||||
return req.Cookies()
|
||||
@@ -241,7 +245,7 @@ func TestJA4H_D(t *testing.T) {
|
||||
{
|
||||
name: "multiple cookies",
|
||||
cookies: func() []*http.Cookie {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
|
||||
req.AddCookie(&http.Cookie{Name: "bar", Value: "foo"})
|
||||
cookies := req.Cookies()
|
||||
|
||||
@@ -272,6 +272,7 @@ func TestExtractQueryParam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJA4H(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -314,7 +315,7 @@ func TestJA4H(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
req, err := http.NewRequest(test.method, test.url, http.NoBody)
|
||||
req, err := http.NewRequestWithContext(ctx, test.method, test.url, http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create request: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user