Skip to content

Commit 27d0992

Browse files
authored
update golangci-lint v2.2 and config (#3713)
1 parent fba9a83 commit 27d0992

File tree

8 files changed

+27
-15
lines changed

8 files changed

+27
-15
lines changed

.github/workflows/go-tests-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ jobs:
5858
- name: golangci-lint
5959
uses: golangci/golangci-lint-action@v7
6060
with:
61-
version: v2.1
61+
version: v2.2
6262
args: --issues-exit-code=1 --timeout 10m
6363
only-new-issues: false

.github/workflows/go-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,6 @@ jobs:
209209
- name: golangci-lint
210210
uses: golangci/golangci-lint-action@v7
211211
with:
212-
version: v2.1
212+
version: v2.2
213213
args: --issues-exit-code=1 --timeout 10m
214214
only-new-issues: false

.golangci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ linters:
1515
- gocognit # revive
1616
- gocyclo # revive
1717
- lll # revive
18+
- wsl # wsl_v5
1819

1920
# Disabled atm
2021

@@ -36,6 +37,7 @@ linters:
3637
- tagalign # check that struct tags are well aligned
3738
- thelper # thelper detects tests helpers which is not start with t.Helper() method.
3839
- wrapcheck # Checks that errors returned from external packages are wrapped
40+
- embeddedstructfieldcheck
3941

4042
#
4143
# Recommended? (requires some work)
@@ -53,7 +55,7 @@ linters:
5355

5456
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
5557
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
56-
- wsl # add or remove empty lines
58+
- wsl_v5 # add or remove empty lines
5759

5860
#
5961
# Well intended, but not ready for this
@@ -75,6 +77,7 @@ linters:
7577
- tagliatelle # Checks the struct tags.
7678
- varnamelen # checks that the length of a variable's name matches its scope
7779
- prealloc
80+
- noinlineerr
7881

7982
settings:
8083

@@ -260,6 +263,8 @@ linters:
260263
disabled: true
261264
- name: redundant-import-alias
262265
disabled: true
266+
- name: redundant-test-main-exit
267+
disabled: true
263268
- name: var-naming
264269
disabled: true
265270
- name: unchecked-type-assertion
@@ -276,6 +281,8 @@ linters:
276281
- fmt.Printf
277282
- fmt.Println
278283
disabled: true
284+
- name: unnecessary-format
285+
disabled: true
279286
- name: unnecessary-stmt
280287
disabled: true
281288
- name: unused-parameter

cmd/notification-http/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (s *HTTPPlugin) Notify(ctx context.Context, notification *protobufs.Notific
126126

127127
logger.Info(fmt.Sprintf("received signal for %s config", notification.Name))
128128

129-
request, err := http.NewRequest(cfg.Method, cfg.URL, bytes.NewReader([]byte(notification.Text)))
129+
request, err := http.NewRequestWithContext(ctx, cfg.Method, cfg.URL, bytes.NewReader([]byte(notification.Text)))
130130
if err != nil {
131131
return nil, err
132132
}

cmd/notification-sentinel/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (s *SentinelPlugin) Notify(ctx context.Context, notification *protobufs.Not
7979
return &protobufs.Empty{}, err
8080
}
8181

82-
req, err := http.NewRequest(http.MethodPost, url, body)
82+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
8383
if err != nil {
8484
logger.Error("failed to create request", "error", err)
8585
return &protobufs.Empty{}, err

cmd/notification-splunk/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *Splunk) Notify(ctx context.Context, notification *protobufs.Notificatio
6262
return &protobufs.Empty{}, err
6363
}
6464

65-
req, err := http.NewRequest(http.MethodPost, cfg.URL, strings.NewReader(string(data)))
65+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, cfg.URL, strings.NewReader(string(data)))
6666
if err != nil {
6767
return &protobufs.Empty{}, err
6868
}

pkg/appsec/ja4h/ja4h_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ func TestJA4H_B(t *testing.T) {
147147
}
148148

149149
func TestJA4H_C(t *testing.T) {
150+
ctx := t.Context()
151+
150152
tests := []struct {
151153
name string
152154
cookies func() []*http.Cookie
@@ -155,15 +157,15 @@ func TestJA4H_C(t *testing.T) {
155157
{
156158
name: "no cookies",
157159
cookies: func() []*http.Cookie {
158-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
160+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
159161
return req.Cookies()
160162
},
161163
expectedResult: "000000000000",
162164
},
163165
{
164166
name: "one cookie",
165167
cookies: func() []*http.Cookie {
166-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
168+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
167169
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
168170
return req.Cookies()
169171
},
@@ -172,7 +174,7 @@ func TestJA4H_C(t *testing.T) {
172174
{
173175
name: "duplicate cookies",
174176
cookies: func() []*http.Cookie {
175-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
177+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
176178
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
177179
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar2"})
178180
return req.Cookies()
@@ -182,7 +184,7 @@ func TestJA4H_C(t *testing.T) {
182184
{
183185
name: "multiple cookies",
184186
cookies: func() []*http.Cookie {
185-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
187+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
186188
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
187189
req.AddCookie(&http.Cookie{Name: "bar", Value: "foo"})
188190
cookies := req.Cookies()
@@ -206,6 +208,8 @@ func TestJA4H_C(t *testing.T) {
206208
}
207209

208210
func TestJA4H_D(t *testing.T) {
211+
ctx := t.Context()
212+
209213
tests := []struct {
210214
name string
211215
cookies func() []*http.Cookie
@@ -214,15 +218,15 @@ func TestJA4H_D(t *testing.T) {
214218
{
215219
name: "no cookies",
216220
cookies: func() []*http.Cookie {
217-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
221+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
218222
return req.Cookies()
219223
},
220224
expectedResult: "000000000000",
221225
},
222226
{
223227
name: "one cookie",
224228
cookies: func() []*http.Cookie {
225-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
229+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
226230
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
227231
return req.Cookies()
228232
},
@@ -231,7 +235,7 @@ func TestJA4H_D(t *testing.T) {
231235
{
232236
name: "duplicate cookies",
233237
cookies: func() []*http.Cookie {
234-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
238+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
235239
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
236240
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar2"})
237241
return req.Cookies()
@@ -241,7 +245,7 @@ func TestJA4H_D(t *testing.T) {
241245
{
242246
name: "multiple cookies",
243247
cookies: func() []*http.Cookie {
244-
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
248+
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://example.com", http.NoBody)
245249
req.AddCookie(&http.Cookie{Name: "foo", Value: "bar"})
246250
req.AddCookie(&http.Cookie{Name: "bar", Value: "foo"})
247251
cookies := req.Cookies()

pkg/exprhelpers/waf_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func TestExtractQueryParam(t *testing.T) {
272272
}
273273

274274
func TestJA4H(t *testing.T) {
275+
ctx := t.Context()
275276

276277
tests := []struct {
277278
name string
@@ -314,7 +315,7 @@ func TestJA4H(t *testing.T) {
314315

315316
for _, test := range tests {
316317
t.Run(test.name, func(t *testing.T) {
317-
req, err := http.NewRequest(test.method, test.url, http.NoBody)
318+
req, err := http.NewRequestWithContext(ctx, test.method, test.url, http.NoBody)
318319
if err != nil {
319320
t.Fatalf("Failed to create request: %s", err)
320321
}

0 commit comments

Comments
 (0)