Skip to content

Commit

Permalink
gosec: allow global config (#2880)
Browse files Browse the repository at this point in the history
  • Loading branch information
maratori committed Jun 6, 2022
1 parent 8d2eb67 commit c531fc2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .golangci.reference.yml
Expand Up @@ -797,6 +797,20 @@ linters-settings:

# To specify the configuration of rules.
config:
# Globals are applicable to all rules.
global:
# If true, ignore #nosec in comments (and an alternative as well).
# Default: false
nosec: true
# Add an alternative comment prefix to #nosec (both will work at the same time).
# Default: ""
"#nosec": "#my-custom-nosec"
# Define whether nosec issues are counted as finding or not.
# Default: false
show-ignored: true
# Audit mode enables addition checks that for normal code analysis might be too nosy.
# Default: false
audit: true
G101:
# Regexp pattern for variables and constants to find.
# Default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
Expand Down
9 changes: 6 additions & 3 deletions pkg/golinters/gosec.go
Expand Up @@ -34,9 +34,12 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter {
filters = gosecRuleFilters(settings.Includes, settings.Excludes)

for k, v := range settings.Config {
// Uses ToUpper because the parsing of the map's key change the key to lowercase.
// The value is not impacted by that: the case is respected.
conf.Set(strings.ToUpper(k), v)
if k != gosec.Globals {
// Uses ToUpper because the parsing of the map's key change the key to lowercase.
// The value is not impacted by that: the case is respected.
k = strings.ToUpper(k)
}
conf.Set(k, v)
}
}

Expand Down

0 comments on commit c531fc2

Please sign in to comment.