Skip to content

Commit 221d30d

Browse files
committed
address comments
Signed-off-by: Ryan Leung <[email protected]>
1 parent 6b9bd1f commit 221d30d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.golangci.example.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ linters-settings:
372372
# Exclude generated files
373373
exclude-generated: true
374374
# Filter out the issues with a lower severity than the given value. Valid options are: low, medium, high.
375-
serveity: "high"
375+
severity: "high"
376376
# Filter out the issues with a lower confidence than the given value. Valid options are: low, medium, high.
377377
confidence: "medium"
378378
# To specify the configuration of rules.

pkg/golinters/gosec.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
7171
}
7272
severity, err := convertToScore(settings.Severity)
7373
if err != nil {
74-
lintCtx.Log.Warnf("Provided severity %s, use low instead. Valid options: low, medium, high", err)
74+
lintCtx.Log.Warnf("The provided severity %q is invalid, use low instead. Valid options: low, medium, high", err)
7575
}
7676

7777
confidence, err := convertToScore(settings.Confidence)
7878
if err != nil {
79-
lintCtx.Log.Warnf("Provided string %s, use low instead. Valid options: low, medium, high", err)
79+
lintCtx.Log.Warnf("The provided confidence %q is invalid, use low instead. Valid options: low, medium, high", err)
8080
}
8181
issues = filterIssues(issues, severity, confidence)
8282
res := make([]goanalysis.Issue, 0, len(issues))
@@ -137,6 +137,7 @@ func gosecRuleFilters(includes, excludes []string) []rules.RuleFilter {
137137
return filters
138138
}
139139

140+
// code borrowed from https://github.com/securego/gosec/blob/69213955dacfd560562e780f723486ef1ca6d486/cmd/gosec/main.go#L250-L262
140141
func convertToScore(str string) (gosec.Score, error) {
141142
str = strings.ToLower(str)
142143
switch str {
@@ -151,6 +152,7 @@ func convertToScore(str string) (gosec.Score, error) {
151152
}
152153
}
153154

155+
// code borrowed from https://github.com/securego/gosec/blob/69213955dacfd560562e780f723486ef1ca6d486/cmd/gosec/main.go#L264-L276
154156
func filterIssues(issues []*gosec.Issue, severity, confidence gosec.Score) []*gosec.Issue {
155157
res := make([]*gosec.Issue, 0)
156158
for _, issue := range issues {

test/testdata/configs/gosec.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ linters-settings:
33
includes:
44
- G306
55
- G101
6-
serveity: "low"
7-
confidence: "low"
86
config:
97
G306: "0666"
108
G101:

0 commit comments

Comments
 (0)