Skip to content

Commit f0ea294

Browse files
maratoriSeigeC
authored andcommitted
gosec: allow global config (golangci#2880)
1 parent d04bab0 commit f0ea294

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.golangci.reference.yml

+14
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,20 @@ linters-settings:
797797

798798
# To specify the configuration of rules.
799799
config:
800+
# Globals are applicable to all rules.
801+
global:
802+
# If true, ignore #nosec in comments (and an alternative as well).
803+
# Default: false
804+
nosec: true
805+
# Add an alternative comment prefix to #nosec (both will work at the same time).
806+
# Default: ""
807+
"#nosec": "#my-custom-nosec"
808+
# Define whether nosec issues are counted as finding or not.
809+
# Default: false
810+
show-ignored: true
811+
# Audit mode enables addition checks that for normal code analysis might be too nosy.
812+
# Default: false
813+
audit: true
800814
G101:
801815
# Regexp pattern for variables and constants to find.
802816
# Default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"

pkg/golinters/gosec.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
3434
filters = gosecRuleFilters(settings.Includes, settings.Excludes)
3535

3636
for k, v := range settings.Config {
37-
// Uses ToUpper because the parsing of the map's key change the key to lowercase.
38-
// The value is not impacted by that: the case is respected.
39-
conf.Set(strings.ToUpper(k), v)
37+
if k != gosec.Globals {
38+
// Uses ToUpper because the parsing of the map's key change the key to lowercase.
39+
// The value is not impacted by that: the case is respected.
40+
k = strings.ToUpper(k)
41+
}
42+
conf.Set(k, v)
4043
}
4144
}
4245

0 commit comments

Comments
 (0)