Skip to content

Commit 952b2ca

Browse files
Merge pull request #258 from cerberauth/upgrade-golangci-lint
Upgrade golangci lint
2 parents 9c3d92c + a62520d commit 952b2ca

File tree

7 files changed

+38
-29
lines changed

7 files changed

+38
-29
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
go-version: ${{ env.GO_VERSION }}
3535

3636
- name: Lint
37-
uses: golangci/golangci-lint-action@v6
37+
uses: golangci/golangci-lint-action@v7
3838

3939
- name: Build
4040
run: go build -v ./...

.golangci.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1+
version: "2"
12
linters:
23
enable:
3-
- errcheck
44
- goconst
55
- gocritic
6+
- gosec
7+
settings:
8+
gosec:
9+
excludes:
10+
- G101
11+
- G107
12+
exclusions:
13+
generated: lax
14+
presets:
15+
- comments
16+
- common-false-positives
17+
- legacy
18+
- std-error-handling
19+
paths:
20+
- .+_test.go
21+
- third_party$
22+
- builtin$
23+
- examples$
24+
formatters:
25+
enable:
626
- gofmt
727
- goimports
8-
- gosec
9-
- gosimple
10-
- govet
11-
- ineffassign
12-
- staticcheck
13-
- typecheck
14-
- unused
15-
16-
linters-settings:
17-
gosec:
18-
excludes:
19-
- G101
20-
- G107
21-
22-
issues:
23-
exclude-files:
24-
- ".+_test.go"
25-
26-
28+
exclusions:
29+
generated: lax
30+
paths:
31+
- .+_test.go
32+
- third_party$
33+
- builtin$
34+
- examples$

internal/operation/operation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (operation *Operation) IsReachable() error {
114114
}
115115
}
116116

117-
_, err := net.DialTimeout("tcp", host, operation.Client.Timeout)
117+
_, err := net.DialTimeout("tcp", host, operation.Timeout)
118118
return err
119119
}
120120

openapi/operation.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ func (openapi *OpenAPI) Operations(client *request.Client, securitySchemes auth.
7171
name := h.Value.Name
7272
value := getParameterValue(h.Value)
7373

74-
if h.Value.In == "header" {
74+
switch h.Value.In {
75+
case "header":
7576
header.Add(name, value)
76-
} else if h.Value.In == "cookie" {
77+
case "cookie":
7778
cookies = append(cookies, &http.Cookie{
7879
Name: name,
7980
Value: value,

report/issue_report.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ func (vr *IssueReport) WithBooleanStatus(status bool) *IssueReport {
9696

9797
func (vr *IssueReport) Fail() *IssueReport {
9898
_, span := tracer.Start(context.Background(), "Issue.Failed", trace.WithAttributes(
99-
attribute.String("id", vr.Issue.ID),
100-
attribute.String("name", vr.Issue.Name),
101-
attribute.Float64("CVSS", vr.Issue.CVSS.Score),
99+
attribute.String("id", vr.ID),
100+
attribute.String("name", vr.Name),
101+
attribute.Float64("CVSS", vr.CVSS.Score),
102102
attribute.String("securityScheme", auth.GetSecuritySchemeUniqueName(vr.SecurityScheme)),
103103
))
104104
span.End()

report/reporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (rr *Reporter) HasHighRiskOrHigherSeverityIssue() bool {
146146

147147
func (rr *Reporter) HasHigherThanSeverityThresholdIssue(threshold float64) bool {
148148
for _, r := range rr.GetFailedIssueReports() {
149-
if r.Issue.CVSS.Score >= threshold {
149+
if r.CVSS.Score >= threshold {
150150
return true
151151
}
152152
}

scan/broken_authentication/jwt/weak_secret/weak_secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var issue = report.Issue{
3535
}
3636

3737
func ShouldBeScanned(securityScheme *auth.SecurityScheme) bool {
38-
if !(securityScheme != nil && securityScheme.GetType() != auth.None && securityScheme.GetTokenFormat() != nil && *securityScheme.GetTokenFormat() == auth.JWTTokenFormat) {
38+
if securityScheme == nil || securityScheme.GetType() == auth.None || securityScheme.GetTokenFormat() == nil || *securityScheme.GetTokenFormat() != auth.JWTTokenFormat {
3939
return false
4040
}
4141

0 commit comments

Comments
 (0)